Home
W5100E01-AVR User`s Manual
Contents
1. Kill Timer for DHCP Client kill timer N y Check dhcp_ state dhcp_state x check DHCP state Y Y RETURN success q RETURN Fail b Fig 3 29 getlP DHCPS getIP_DHCPS initializes W5100 using setIP setMACAddr and etc and it initializes dhcp_state variable as DHCP client program state to STATE DHCP DISCOVER After the initialization it calls send DHCP DISCOVER to transfer a DHCP DISCOVERY message to DHCP server After transmitting DISCOVERY DHCP message it initializes timer variables which are the leased time of network information received from DHCP server by calling reset_DHCP_time and uses DHCP Timer for 1 sec interval using set_timer After the initialization of DHCP_Timeout with 0 it waits for DHCP message to be received from DHCP server as long as the DHCP_WAIT_TIME defines and as many as the MAX DHCP RETRY defines While waiting for DHCP WAIT TIME amp MAX DHCP RETRY time it continuously checks if dhcp state is changed to STATE DHCP LEASED through check DHCP state STATE DHCP LEASED state represents the network information and means that getIP_DHCP is done successfully If network information is not obtained from DHCP Server during the waiting time for DHCP WAIT TIME amp MAX DHCP RETRY check DHCP state sets DHCP Timeout to 1 When Copyrig
2. Declare Local Variables Declare Local Variables SOCKET s SOCKET s Get the network information of EVB Get the network information of EVB get netconf amp NetConf get netconf amp NetConf NetConf dns 0 DNS Server IP NetConf dns 0 DNS Server IP Addess is not Addess is not TT Sg N Find a Free channel Find a Free channel RETURN 0 gr C gt getSocket SOCK_CLOSED Sinn N Not found a Free d found a Socket di Socket Y Communicate with the DNS Server Communicate with the DNS Server dns_query s T dns query s amp hostip BYIP Fail to Fail to eg B Server Sei Ze SN RETURN 1 T RETURN o RETURN 1 RETURN d lt Fig 3 38 gethostbyaddr amp gethostbyname gt dns_query initializes the buffer that is needed for DNS inter working and creates QNAME of Question Section based on Query Type BYNAME and BYIP If the Query Type is BYNAME that is when querying the Domain Name with IP Address Domain Name can be used as QNAME without transformation When Query Type is BYIP that is when querying the Domain Name with IP Address change IP Address to IP Address String and QNAME is used after adding in addr arpa to the changed IP Address String After the creation of QNAME UDP Socket is created for DNS i
3. Update the Network Information set DHCP network Y Reset timeout amp retry count reset DHCP time STATE DHCP RELEASE Reset timeout amp retry count reset DHCP time dhcp state STATE DHCP DISCOVER dhcp state STATE DHCP LEASED Check timeout check DHCP Timeout Fig 3 31 check DHCP state gt E IEIUEN S J9Sf HAV LO300LGSM check DHCP state processes correspondingly with DHCP client state through the series of processes shown in Fig 3 31 If we take a look at DHCP STATE LEASED state at check DHCP state the Lease Copyright 2007 WIZnet Co 73 Inc All rights reserved WIZnet Time received from DHCP server is finite in case that half of the Lease Time passed it sends DHCP REQEUST Message to DHCP Server and changes it as DHCP STATE REREQUEST after it backs up the source IP As it continuously transmits DHCP REQUEST to the server network information is maintained HarseDHCPh Sta Declare amp Initialize Local variables u char svr addr 5 u short evr port pRIPMSG u char RX BUF u int len i 1 u char p e u chartvpe opt len Receive a DHCP Message recvfrom amp pRIPMSG syr addr amp svr port ere DHCP SERVER Porro Y STA P MEG dradd SRC MAC IDD R TY M H DHCP_SIP pRIPMSG gt siaddr GET_SIP pRIPMSG gt yiadar 7 Y type 0 lt SIBTE pHcr_REREGUES
4. JenuEy S A9SN HAV LO300LGSM 48 WIZnet 3 2 6 Applications Its a network application using W5100 It includes Loopback program Web Server and DHCP Client Application is selected by Manager Program 3 2 6 1 Loopback TCP Server The Loopback TCP Server program of EVB B D works as server mode and AX1 program of the testing PC works as client mode AX1 tries to connect to EVB B D and if the connection is successful AX1 transmits the data stream through the TCP channel EVB B D returns back the data stream from AX1 without processing through the TCP channel Loopback TCP Server Program uses loopback_tcps and lt Fig 3 14 gt shows the process procedure of loopback tcps loopback teps Y Declare amp Initialize Local Variables u_char data_buf TX BUF Y Select Socket Status getSn SR OCK ESTABLISHED Select Recieved Size en gt 0 gt len getSn RX RSR Receive the Data recv ch data buf len Send the Received Data send ch data buf len Y Ki Close Socket close ch Y Create a TCP Socket SOCK_CLOSED socket ch SOCK STREAM port flag Y Wait a connetion with a client NBlisten ch RETURN Da lt Fig 3 14 loopback_tcps gt Copyright 2007 WIZnet Co Inc All rights reserved JenuEny S J9S
5. AVR ISP Internal Flash Programming Tool Option Software CD Accessory Table 1 2 Contents of Software CD AVR Datasheet All sorts of Datasheet Application Note AVR Tool Gudie ISP Gender Guide All sorts of schematics Part List All sorts of Part List PAL Logic Source amp JED File EVB B D Firmware E Utility All sorts of Tool Program The contents of Software CD could be changed by version Please check ReadMe txt of CD Copyright 2007 WIZnet Co Inc All rights reserved JeNnuEN S A9SN HAV LO300LGSM WIZnet 1 2 Feature 1 2 1 H W Features W5100E01 AVR B D is composed of 2 type B Ds OG PM A1 MCU ATmega128 8MHz RAM 32KB SRAM External ROM 128KB Flash Atmega128 Internal Flash ICE I F JTAG ISP Support W5100E01 AVR Power DC5V 2A Adaptor UART Two 232 Serial Port default 57600 Baud Rate LCD Display 16 X 2 Text LCD PAL Address Decoder W5100 Hardwired TCP IP Chip embedded PHY chip MagJack RD1 125BAG1A UDE Integrated Transformer 1 1 Link amp ACT amp FDX LEDs 1 2 2 F W Feature The F W of EVB B D is made up of two parts Manager mode Network Config MAC Source IP G W IP S N DNS IP Setup Channel Config W5100 Test Application Setup for each channel Ping Test Ping Request Test with DNS Application mode Loopback TCP Server TCP Server Mode Test Application Loopback TCP Client TCP Client Mode Test Applicatio
6. typedef struct st http request u_char METHOD request method METHOD_GET u_char TYPE request type PTYPE HTML char URI MAX URI SIZE request file name p ist http request parse htt req vest Get a Method Token nexttok strtok buf SP request gt method request gt method request gt method METHOD_GET METHOD_HEAD METHOD POST Y Get a Request URI Token Get a Request URI Token nexttok strtok NULL SP nexttok strtok NULL win Y Y request gt method METHOD ERR N Copy nexttok to request gt URI RETURN Jj Fig 3 20 parse http request gt 61 Copyright 2007 WIZnet Co Inc All rights reserved WIZnet find http uri typell RETURN lt Fig 3 21 find http uri type gt Request URI which is saved in URI MAX URI SIZE of st http request has URI Name before symbol and Query String after sign When Request URI is transferred from Web Browser to Web Server SP Space text is transmitted in the form of and other Reserved Texts are transmitted in the form of HEXHEX Accordingly Reserved Texts in Request URI needs to be decoded to the previous value from to SP and from HEXHEX to related ASCII vales For the details of Request URI decoding refer to RFC1738 URI name of Request URI is extracted wit
7. lt Fig 3 18 web_server gt Since web_server is TCP server program it is built in the similar way as loopback_tcps as explained in Chapter 3 2 6 1 Difference between web_server and loopback_tcps is in the data communication codes web server calls proc http that processes HTTP request message from web browser at SOCK ESTABLISHED of the http socket After calling function proc http it waits until the HTTP response message to HTTP request from web browser and then calls disconnect to close the http socket This socket close is called Active Close and in the case EVB B D requests the close to the client first For your reference Passive Close is where client requests disconnection first The reason why web server program supports Active Close is that EVB B D supports the connection with other clients Copyright 2007 WIZnet Co Inc All rights reserved nuEpy S J9Sf HAV LO300LGSM 58 LZnet prac http Declare amp Initialize Local Variables prag char contents chars name param u int file len send len http response tu chas TX BUF Analyze the HTTP request parse Hip reqeust amp request buf equest Method METHOD ERR send Hegeust Error Page sendi ERROR REQUEST PAGE RETURN M reduest TYPE PTYPE TGH Ke Y ame NETCONFIG CG Processing ame LCDNLED ETON Fe S Find a file in the ROKMFILE search_file name amp content amp file_len send Un
8. which controls text LCD D1 D2 LED of EVB B D lt Fig 3 23 gt and lt Fig 3 24 gt shows both CGI processing Processing ME CONF l Extract the value of sip param get hitp param _value http request gt ui sip lt param I NUL Update Source IP Address NetConf sip htonllinet addriparam Extract the value of qwip param get_http_param_value http_request gt uri gwip W Update Gateway IP Address geram t NUCL MetConf gwip htonllinet_addrparam M Extract the value af sn param get hitp param value Hitp request uri sm ae Update Sbunet Mask Value NetC ont ene htonllinet_addrparam M Extract the value af dns param ge hitp param value hitp request gt uri dns Lex X Update DNS Server IP Address NetConf dns htonliinet addriparam cave the Network Information ta EEPROM set netconf amp NetCont send a Cal Success Page send EVB B D Auto Reset evb soft rese END lt Fig 3 23 NETCONF CGI Processing gt Copyright 2007 WIZnet Co Inc All rights reserved JeNnuEy S J9Sf HAV LO300LGSM 63 WIZnet Processing Extract the value of lcd param get hitp param value hitp request uri lcd Display the Value On Text LCD Iparam 16 0 eub set ted text 1 param JeNnuEN S A9SN HAV LO300LGSM Tum the D1 LED an Tum the D1 LED aff led ont OU le off D Extract the value of ledi param get hitp param value hiip re
9. Copyright 2007 WIZnet Co Inc All rights reserved jenuen J195N YAV LOAOOLSM 19 WIZnet lt Table 3 1 Device MAP Definition gt define DEF IINCHIP MAP BASE 0x8000 mcu types h Hif DEF IINCHIP BUS DEF IINCHIP DIRECT MODE define COMMON BASE DEF IINCHIP MAP BASE else define COMMON_BASE 0x0000 endif define DEF IINCHIP MAP TXBUF COMMON BASE 0x4000 define DEF IINCHIP MAP RXBUF COMMON BASE 0x6000 Text LCD define LCD BASEADDR 0x9000 evb lcd h 312 AVR Internal EEPROM MAP lt Fig 3 2 gt lt Table 3 2 gt are representations of AVR Internal EEPROM Mao Refer to evb config h and evb config c IAU Oxe 0x30 NET SN NET DNS NET MEMALLOGC H A iA 0x50 CH TEST HDEST IPU TYPE D PORT Dx BI Fig 3 2 AVR Internal EEPROM Map gt Copyright 2007 WIZnet Co Inc All rights reserved JENUEIN S J9Sf HAV L030016M WIZnet System Information Network Information Channel Information define SYS INFO define SYS TEST define SYS VER define SYS AUTORESET define SYS ANY PORT define NET CONF define NET TEST define NET MAC define NET SIP define NET GWIP define NET SN define NET DNS define NET MEMALLOC define CH CONF define CH TEST define CH TYPE 0 define CH PORT 0 define CH DESTIP 0 define CH TYPE 1 define CH PORT 1 define CH DESTIP 1 define CH TYPE 2 define CH PORT 2 define CH DESTIP 2 define CH TYPE 3 define CH
10. AX1 on the server set any channel of W5100 as Loopback TCP Client application type using Manager gt gt Channel Config menu of EVB B D When setting up the Loopback TCP Client Application type of EVB B D set the Server IP as the IP Address of the Test PC and set Server Port as the waiting Server Port Number 3000 Refer to Chapter 2 4 1 2 After setting up EVB B D is complete exit from the manager program and run EVB Test Application If EVB B D is connected to AX1 successfully loop back the desired data Refer to AAT Manual Vx x pdf Source IP 192 168 0 2 Gateway IP 192 158 0 1 Subnet Mask EE 255 255 0 DNS Server IP 0 0 0 0 Loop Back TCP Server Started Connected by 192 168 0 3 0 28527 Peer Connection Information in 1 channel of W5100 lt Fig 2 16 Loopback TCP Client gt 2 4 2 4 Loopback UDP Loopback UDP Application is an application that loops back any file and packet data through UDP Channel connected with AX1 Program of Test PC First of all to test Loopback UDP set up any channel of W5100 as Loopback UDP Application Type using Manager gt gt Channel Config Menu of EVB B D In setting up Loopback UDP Application type set Source Port as any value Here it s set with 3000 Refer to Chapter 2 4 1 2 After EVB B D setup is over loop back desired data with IP Address and UDP Source Port of EVB B D using menu or Icon related to UDP Refer to AX1 Manual Vx x pdf
11. Copyright 2007 WIZnet Co Inc All rights reserved IEIUEN S J9Sf HAV LO300LGSM 15 Ww LZnet source IP 192 168 0 2 Gateway IP 192 168 0 1 Subnet Mask 255 255 255 0 DNS Server IP 0 0 0 0 MAC Addr OxOO 0x08 0xDC 0x00 0x00 0x35 EEE EEE EEE EEE EEE ARR RRR RRR RRR RRR RRR RRB Dr Loop Back TCP Server Started Ao p started 4 DD bach i 2 Loop Back UDP Started Loopback UDP Application Log oop Bac LE erver arted lt Fig 2 17 Loopback UDP Test gt 2 4 2 5 Web Server Web Server Application sends and receives web pages and EVB B D control data through HTTP Channel connected with web browser For Web Server testing set up any channel of W5100 as Web Server Application Type using Manager gt gt Channel Config menu of EVB B D When setting up Web Server Application Type of EVB B D set HTTP port as any value Here it s set to 80 the default value Refer to Chapter 2 4 1 2 After setup for EVB B D run Web browser in the Test PC type the URL hitp 192 168 0 2 of the EVB B D in the address field and connect to EVB B D Source IP 192 168 0 2 Gateway IP S 192 166 0 1 Subnet Mask S 295 255 255 000 DNS Server IP 0 0 0 0 MAC Addr Ox00 0x08 O0xDC 0x00 0x00 HHHHHESHHSHSHHESEHSHHHHHEHHHHHHHSHEHHHHHHH O Loop Back TCP Server Started 1 Loop Back TCP Client Started 2 Loop Back UDP Started 3 Web Server Started Web Server Application Log an
12. destination related socket addr u int port void close SOCKET s Close related socket iinChip socket c If the udp socket is in SOCK CLOSED status socket is called using SOCK DGRAM Port Number and Option Flag as the elements to create the UDP socket UDP communication as opposed to TCP is a datagram communication without the requirement of connection process So direct data communication is possible immediately after socket creation After creation of UDP socket the udp socket status will be changed from SOCK CLOSED to SOCK UDP Here not like TCP for data communication which uses send and recv sendto and recvfrom are used This is because TCP is 1 to 1 communication method of which destination is known but UDP is 1 to many communication without connection procedure sendto sends data to specific port of specific destination that is sent as an element recvfrom is used to receive the incoming data from temporary port Destination information from recvfrom is informed to user using destip and destport which are sent as elements In loopback udp there is no example of using close but in case that the UDP communication is not needed anymore close can be always called to close the udp socket 3 2 6 4 Web Server Web Server program is a TCP server program using HTTP protocol which is used on TCP protocol Before building Web server program message structure of HTTP protocol that is transmitted between Web
13. f it is defined the source files md5 h md5 c must be included in your project 1 delay h Otherwize the source files must be removed in your project dhcp h e ele define DEF I INCHIP DIRECT MODE 1 define DEF I INCHIP INDI RECT MODE 2 b eeprom h define DEF IINCHIP SPI MODE 3 5 evb h define DEF ITNCHIP BUS DEF I INCHIP DIRECT MODE P httpd h define DEF I INCHIP_BUS__ DEF I NCHIP_INDIRECT_MODE__ F interrupt h define DEF INCHIP BUS DEF I INCHIP SPI MODE Enable SPI mode 1 inttypes h io h j 2 iom128 h brief DEF IINCHIP MAP xxx gt define memory map for iinchip D e GEAR define _DEF_ NCHIP_MAP_BASE__ 0x8000 M ied if __DEF_ INCHIP_BUS__ DEF I INCHIP DI RECT MODE H loopback h define COMMON BASE _DEF_ INCHIP MAP BASE P manage h Helse h efine B x md5 h def i COMMON_BASE 0x0000 B E Hendif B DEEN Hdefine DEF INCHIP MAP TXBUF COMMON BASE Ox400D Internal Tx buffer address of the iinchip etine eal eem Ux Interna x buffer address of the iinchip Errem def i DEF INCHIP MAP RXBUF COMMON BASE Ox6000 Fx buff dd f the iinchi vi ping E ping app h gt Bos 8 D WIZNET news 100ED1 AVRSWSIODEVB FWimaintfmain c E DEWWIZNETWMY WW5100E01 AVR WW5100EVB FW WmcuWtypes h 4 b romfs h 1 searchfile h Build x IN serial h avr objcopy 0 ihex R eeprom WS1O0EO01 AVR elf W5lO00
14. 4 2 ISP Pin Description gt vm mg Commands and oara rom AVRISP io EVE BD sb o ou DataromEVBBDIAVRISP Copyright 2007 WIZnet Co Inc All rights reserved JeNnuEN S A9SN HAV LO300LGSM 96 WIZnet 4 2 2 LCD LCD is used for debugging and system status display Pin Description of LCD Interface JP3 is as follows lt Table 4 3 LCD PIN Description gt EVB B D PIN NAME Description LCD PIN NAME a ww mge OOOO 2 ww Ilres a ww whetricawe a ms i Dbmwmemcknrgsersied AO RW Read Write e AB E E mM Enable signal start data read write Z 4 I O Data Bus Line 14 D7 DB7 15 NC1 LED A O LEDAnodepowersuplye LED Anode power up Anode power supply EN ae K O LED Cathode ground OV It uses minimum 0 3V and maximum 13V of VDD VO at Specification Document of LC 1624 To fit the data R6 5V Pull Up maximum 10K and R7 Gnd Pull Down 820R are used and in real application LCD Display became clear when R6 was adjusted For details on LC 1624 refer to LC1624 Specifications document Copyright 2007 WIZnet Co Inc All rights reserved JeNnuEN S A9SN HAV LO300LGSM 97 WIZnet 4 2 3 PAL PAL is used to make enable signal of various chip or module that are used for EVB B D The PAL element that is used in the product is ATF16V8B 15PL from ATMEL co It uses 10 input pins and 8 I O Pins It makes Chip Select or Enable Signal about SRAM CS RAM L
15. AX1 Program and EVB B D 2 4 EVB B D Test The firmware of EVB B D can be divided into Manage Program and EVB B D Test Application Copyright 2007 WIZnet Co Inc All rights reserved JenuEy S J9Sf HAV LO300LGSM Ww LZnet Manage Program performs system configuration to run EVB B D and EVB B D Test Application is Network Application Program for W5100 Test 2 4 1 Manage Program Manage Program is a program that is executed upon receiving character M or m from the terminal program within 7 seconds when doing the manual reset of EVB B D and EVB B D power on This program sets up the channel application of W5100 to be tested and perform certain ping request test with DNS server Mini Term File E Configure C Transfer T Help tH Press M to enter the manager mode Network Contig Channel Contig Ping App Test Factory Reset lt Fig 2 6 Manage Program Execution gt 2 4 1 1 Network Configuration It selects Network Information that is used in EVB B D When choosing 1 at terminal Program of Fig 2 6 gt Network Information of EVB B D can be set as desired The default Network Information of EVB B D is shown in lt Table 2 2 gt lt Table 2 2 EVB B D Default Network Information gt Network Information Default Value MAC Address 00 08 DC 00 00 00 Source IP Address 192 168 0 2 Gateway IP Address 192 168 0 1 Subnet Mask 255 255 255 0 DNS Server IP Address 0 0 0 0 If
16. B D Firmware EVB main can be divided into two parts Manage Program that sets up various environments for running EVB B D and Loopback Programs that tests W5100 performance There are Internet Application using Internet Protocols such as DHCP HTTP DNS and ICMP Let s look at the source list of which EVB B D is composed and then look at each application source Copyright 2007 WIZnet Co Inc All rights reserved jJenuEN S 49Sf HAV LO300LSM 26 WIZnet 3 2 1 Sources lt Table 3 13 EVB B D Sources gt Classification l ae Files Description Directory ping app h ping app c Ping Request App implementation loopback h loopback c TCP UDP Loopback Apps implementation Webserver App implementation MCU Delay Function wait xxx EVB B D initialization EVB B D LED D3 D4 control EE util h util c Utilities W5100 h w5100 c I O Functions of W5100 socket h socket c Socket APIs for W5100 Copyright 2007 WIZnet Co Inc All rights reserved nugpy S J9Sf HAV L03001LGM 27 Wiznet 3 2 2 Sources of Chapter 3 2 1 compile in bundle after arranging SRC items Compiling of W5100E01 AVR B D firmware can be processed by using WINAVR and AVRSTUDIO First install the WINAVR and AVRSTUDIO at the PC Then open the firmware file sw fw W5100E01 AVR aps through AVRSTUDIO project file to perform the compiling easily How to Compile Be sure to check compile setting detail at the Configuration
17. Client LB UDP Loopback UDP WEB_SEVER Web Server CH PORT X Source Destination Little Endian Port number of No a LB TCPS Default Source Port 0x5000 LB TCPC Default Destination Port 0x3000 LB UDP Default Source Port 0x3000 WEB SERVER 80 CH DESTIP X Destination IP addres of OxCO A80003 192 168 0 3 No X channel Channel Information is used for recording application type for 4 channels of W5100 Channel application type includes Loopback TCP Server Loopback TCP Client Loopback UDP DHCP Client Web Server Channel Information is defined as APPTYPE enumeration type lt Table 3 10 Channel Application Type gt typedef enum APPTYPE NOTUSE DHCP_CLIENT LB TCPS LB TCPC LB UDP WEB SERVER JAPPTYPE Copyright 2007 WIZnet Co Inc All rights reserved JenuEy S J9Sf HAV LO300LGSM 24 WIZnet Channel Information is accessed as CHCONF Data Type lt Table 3 11 CHCONF Data Type Definition gt Type Definition Global Instance typedef struct CHCONF CHCONF ChConf 3 u int test struct CH CONF u_char type u int port u long destip jch 4 JCHCONF Table 3 12 Channel Information Access Function void set chconf CHCONF pChConf Save the channel information void get chconf CHCONF pChConf Get the channel information Copyright 2007 WIZnet Co Inc All rights reserved IEIUEN S J9Sf HAV LO300LGSM 25 WIZnet 3 2 EVB B D Firmware EVB
18. Error Count Tg UnreachableldS Shen Sl NE M a Y Display the Time Exceeded t50 rimeExceedM SG Massage Count M Display the ARP Error Count Display the Receive Timeout Count Display the PingReply Count log PingReply gt 0 M lt Fig 3 12 DisplayPingStatistics gt Ping request program is as explained previously a program that uses ICMP protocol which is running on IP Protocol In case of using ICMP channel at W5100 as shown in lt Fig 3 11 gt and lt Fig 3 13 gt IP protocol to be used must be decided The socket must be created after calling setlPProtocol s IPPROT ICMP IP RAW channel must be created by calling socket s SOCK_IPL_RAW port flag when creating the socket In case of closing ICMP Socket setlPProtocol s 0x00 should be called after close s and clear the ICMP Flag which was previously set Copyright 2007 WIZnet Co Inc All rights reserved JeNnuEN S A9SN HAV LO300LGSM 46 WIZnet Fail to Send a Ping Reply Packet SendPingReply Declare amp Initialize Local variables SOCKET PingReplySocket u int size len size PINGBUF LEN size PINGBUF LEN Find a Free Socket Call getSocket SOCK CLOSED S Assign the socket to PingReplySocket ingReplySocket AX SOCK NU b Create Error Guan Make a PingReply Packet pingr
19. Inc All rights reserved JeNnuEN S A9SN HAV LO300LGSM 29 Ww LZnet If DHCP client exists in the application the DHCP client obtains the network information from DHCP server by calling get IP DHCPS function If DHCP client application does not exist or fails to obtain network information from DHCP server the EVB B D is initialized with previously set network information After the initialization it runs test applications of EVB B D by calling each registered application handler For further details on DHCP client program refer to Chapter 3 2 6 5 DHCP Client Copyright 2007 WIZnet Co Inc All rights reserved IEIUEW S 49Sf HAV LO300LSM 30 WIZnet lt Table 3 15 Reference Functions in EVB B D s main gt int main void EVB B D main void evb init void AMR Text LCD evb evb c UART initialization void net init void EVB B D Network initialization void check manage void Manage Program action wait and evb manage c execution void register channel handler Channel Application Handler evb channel c u char ch void registration handler u char X void unregister channel handler Channel Application Handler evb channel c u char ch cancellation void init dhcp client SOCKET s DHCP Client Program initialization inet dhcp c void ip update void void ip conflict void u int getlP DHCPS void Network Information acquisition from inet dhcp c void check DHCP state SOCKET C
20. JP5 Pin description of Interface is shown in Table 4 1 PM A1 MODULE Pin Copyright 2007 WIZnet Co Inc All rights reserved IEIUEN S J9Sf HAV LO300LGSM 93 WIZnet Description gt lt Table 4 1 PM A1 MODULE Pin Description gt PM A1 MODULE Description Header UO Databus 0 7 or PA 0 7 VO PB 0 7 JP4 3 AO UO Address bus 0 7 UO Address bus 8 15 PC 0 7 A15 PC7 PDO SCL I O PD 0 7 PD1 SDA PD2 RXD1 PD3 TXD1 PD4 PD5 PD6 PD7 RXDO UO RXDO is connected with PEO PE1 TXDO PE2 PE3 PEA I2CHIP IRQ PE5 PE6 PE7 through 1K ohm resistor PE 1 7 VO PF 0 7 20 PF7 Copyright 2007 WIZnet Co Inc All rights reserved JeNnuENy S J9Sf HAV LO300LGSM 94 WIZnet JP4 4 WR PGO JP4 42 RD PG1 JP5 40 PG3 LED 0 JP5 41 PG4 LED 1 CE JP5 10 12 21 JP5 22 45 47 JP5 48 49 50 JP4 23 24 49 50 JP5 3 5 9 11 RESO JP4 19 20 21 22 33 34 35 36 RES18 37 38 39 40 43 44 NC JP5 25 NC 39 NC Copyright 2007 WIZnet Co lO PG 0 4 without ALE PG2 Reset Signal Input process generated a by EVB B D s Reset Switch SW3 3 3V Power Input 3 S3VPowerlnt Power Input 1 SV PowerinputNot Used Ce Signal Ground 1 RESERVED LINE Inc All rights reserved nuEpy S J9Sf HAV LO300LGSM 95 WIZnet AVR ISP JP3 Pin Mapping POO VLC GAD GAD CPU RESET GAD SCR GHD HD GAD lt Table
21. PC to EVB B D using serial cable directly Connect 5V power adaptor to EVB B D 2 Confirm the network information of Test PC as the following Source IP Address 192 168 0 3 Gateway IP Address 192 168 0 1 Subnet Mask 255 255 255 0 3 Install AX1 on Test PC Refer to Chapter 2 2 2 1 4 After the execution of serial terminal program like Hyperterminal set up the properties as the following lt Table 2 1 Terminal Properties Setting gt Properties Setting Value Bits Per second Baud Rate 57600 bps After the completion of terminal setup connect to EVB B D and wait 5 Turn on the power switch SW1 of EVB B D Following items should be checked upon power on Check lighting on power LED D2 of EVB B D when powering on Check if LEDs of D3 and D4 blink three times by turns Check if Text LCD display of EVB B D outputs in the way shown in Fig 2 3 and shown in Fig 2 4 on the Terminal Program Fig 2 3 EVB B D Text LCD Display Copyright 2007 WIZnet Co Inc All rights reserved IEIUEN S J9Sf HAV LO300LGSM WIZnet CR L j p min eT e E Configure C Transter I Help tH VE BAY Press H to enter the manager mode FEE Mini Term W516GE61 AUR Test in Direct Mode File F Configure C Transfer T Help H THEIEIETTEHIETEHTEIETEHTEIETEHTETSETEHTETETEHTETETEHETETERETETETEREHE IEEE HHH Copyright WIZnet Inc 2887 cH ap SC Homepage http
22. Server p QE LE A lt Fig 3 33 Domain Name System Structure amp DNS Message Flow gt CLIENT 53 For As seen in lt Fig 3 33 gt DNS Query and DNS Answer Message transmittable between DNS Resolver and Name Server are composed of 5 Sections in lt Fig 3 34 gt Copyright 2007 WIZnet Co Inc All rights reserved nuEpy S J9Sf HAV LO300LGSM 76 WIZnet 12 Bytes o mm Resource Records RR 4 Variable Length Authority Additional JeNnuEN S A9SN HAV LO300LGSM lt Fig 3 34 DNS Message Format gt Header Section has fixed 12 Bytes length and the other 4 sections have variable lengths Answer Authority Additional Section other than Header and Question Section are called Resource Records RRs Each of Header Question and RRs has different format ODEON AMCOUNT MSCOUNT Emp exem Tm mTe m zs T sexes ARCOUNT lt Fig 3 35 Header Section Format gt variable Length 2 Bytes 2 Bytes lt Fig 3 36 Question Section Format gt 71 Copyright 2007 WIZnet Co Inc All rights reserved WIZnet Length Length lt Fig 3 37 Recode Resources Format gt Header Section of DNS Message holds type of Message DNS Query type and count information on variable length section In lt Fig 3 35 Header Section Format gt QR field gets 0 when DNS Message is a request from Resolver to Name Server and gets 1 when it s from Name Server to Resolver Opcode Field gets 0
23. after it changes DHCP Client State as shown DHCP Message Flow of lt Fig 3 30 gt 72 Copyright 2007 WIZnet Co Inc All rights reserved WIZnet check DHCP stated Y u intlen u_char type 0 Declare amp Initialize Local Variables Y len getSn RX RSR s type parseDHCPMSG Receive amp Analyze i type DHCP_OFFER i N Broadcast DHCP REQUEST send DHCP REQUEST Check timeout check DHCP Timeout END STATE DHCP REQUEST dhcp state STATE DHCP REQUEST 1type DHCP_ACK N N LE pe DHCP NAK y Reset timeout amp retry count reset DHCP time Reset timeout amp retry count reset DHCP time Check timeout Check IP Conflict check leasedlP Y lt P Conti N dhcp state STATE_DHCP_DISCOVER Update the Network Information set_DHCP_network END dhcp state check_DHCP_Timeout STATE_DHCP_LEASED STATE_DHCP_LEASED type 0 OLD SIP GET SIP DHCP XID Broadcast DHCP REQUEST send DHCP REQUEST Reset timeout amp retry count reset DHCP time dhcp state STATE DHCP REREQUEST na eae
24. clients as many as the number of repeated ports Display Config Oth Channel START D manage channel D 1th Channel 2 eth Channel Dei the Channel Information 3 3th Channel get chconft amp ChConf F Factory Reset E Exit Display Channel Contig Menu Get the pressed key sel uart0_getchard Y Display Channel Information ES display cheoanf M eben oS Y Select Apps Type sel D EE sel 3 i select Ch app Factory Reset load factory cheonfO sel F orse Y np Cum js Update Channel Information LETE or sel E or sel e i set chconfi amp chCont d lt Fig 3 7 manage_channel gt Copyright 2007 WIZnet Co Inc All rights reserved JeNnuEN S J9Sf HAV LO3I00LGM 38 WIZn et lt Table 3 19 Reference Functions in manage channel gt u_char manage_channel void Configure Channel Information void select_ch_app Select available Application Type and Setup evb manage c CHCONF pChConf u_char ch required factors void get chconf Get Channel Information evb config c CHCONF pChConf void set chconf Update Channel Information evb config c CHCONF pChConf void display chconf Output Channel Information through Terminal evb config c CHCONF pChConf void load factory chconf void Factory Reset Channel Information evb config c char uartO getchar void Read one character from UARTO mcu serial c 3 2 5 3 Ping Request Program Ping Request Prog
25. hostName specifies a list of DNS servers available to the client specifies the name of the client dhecpReaquestedlPaddr request that a particular IP address be assigned by the server dhcplPaddrLease Time a lease time for the IP address dhcpMessage Type used to convey the type of the DHCP message dhcpServerldentifier the IP address of the selected server dhcpParamRequest request values for specified configuration parameters 255 dhcpClientldentifier specify client unique identifier endOption marks the end of valid information In the Option Field of 312 Bytes the unused bytes are denoted with O s padding Table 3 34 is defined as enumeration data type in inet dhcp h and shows most common Option Codes that are used in DHCP Client Program Other codes that are not defined in Table 3 34 are skipped from DHCP Client Program Copyright 2007 WIZnet Co Inc All rights reserved IEIUEN S J9Sf HAV LO300LGSM 68 WIZnet The operation of DHCP Client Program is displayed in EVB B D s main Refer to lt Fig 3 3 gt First set up the MAC address to be used by DHCP Client at the initialization MAC address is unique address for all the devices in the network MAC address is most basic address in Network communication and necessary information to recognize DHCP Clients in DHCP Server For MAC Address of DHCP Client program it sets up SRC_MAC_ADDR which is global variable of
26. lt TABLE 3 22 REFERENCE FUNCTIONS IN PING REQUEST cccccsssssccceesssseeceeessseecceeessseeceeeesseeeeeeens 48 lt TABLE 3 23 REFERENCE FUNCTIONS IN LOOPBACK TC 50 lt TABLE 3 24 REFERENCE FUNCTIONS IN LOOPBACK_TCOPC gt s sssssssssssssesssseresssesressserressssrressssseressss 52 lt TABLE 3 25 REFERENCE FUNCTIONS IN LOOPBACK_UDP gt ss ssssssssssssssssrsssserrrssserresssseressssrresssserressss 54 W5100E01 AVR User s Manual IX w L net lt TABLE 3 26 WEB BROWSER S HTTP REQUEST OPERATION PROCEDURE gt mnnnnnvnnvarververvrrrennennensrvenne 55 lt TABLE 3 27 HTTP MESSAGE FORMAT essere teen tnn the tnt tn trenes trenes the th tnnt tn estas tns tn stets 56 lt TABLE 3 28 HTTP MESSAGE BETWEEN EVB B D AND WEB BROWSER gt nsere 57 lt TABLE 3 29 SYSTEM ENVIRONMENT VARIABLES USAGE AT EVBCTRL HTML zs 60 lt TABLE 3 30 ST HP REQUEST DATAS egetenegieebtete eet eege 61 lt TABLE 3 31 REFERENCE FUNCTIONS IN WER SERVER iisssssesssseeeeeeee nennen nennen enne nrnn nennen 65 lt TABLE 3 32 DHCP MESSAGE DATA Ip eene enne enne tnn ennt 67 TABLE 3 33 DHCP MESSAGE OPTION CODE DEFINITION essere enne 68 TABLE 3 34 DHCP CLIENT STATE amp TIMEOUT DEEINITTION enne 71 lt TABLE 3 35 DHCP MESSAGE FLAG FIELD SETUP5 sees nnns rn ntn n nannten nnns 71 lt TABLE 3 36 REFERENCE FUNCTIONS IN DHCP CLIENTS c cccscecssscsseeesseeesseesseeesseeeeseeensee
27. option of Project menu of AVRSTUDIO For the setting method refer to AVR Studio User Guide As the firmware provided by WlZnet is based on AVR GCC 3 4 6 it can not be operated correctly at another version of the comiler AVR Studio D AWIZNETYMYYW5100E01 AVRYW5100EVB FAYWmcuWtypes h File Project Build Edit View Tools Debug Window Help FX D c io amp Bm boo d A gt M gu on ES ER x AVR GCC kA EE EE k AR kk kek ko EE EE EE EE EE EE EE BR BG B B G BG EE E EE EN include mcu_define h c 5 ping c define MOL AIR I S ping app c define MCU TVPE MCUL AVR romfs c searchfile c Refer Rom File Maker Manual Vx x pdf S serial c include lt avr pgmspace h gt E socket c define ENDIAN LITTLE O This must be defined if system is little endian alignment sockutil c define ENDIAN BIG 1 7 timer c define SYSTEM_ENDI AN ENDI AN_LITTLE_ util c define MAX SOCK NUM 4 Maxmium number of socket E define CLK CPU 8000000 lt BMhz for serial webserver c Header Files AN DEF I INCHIP xxx define option for iinchip driver ktkkkkekkkkke 5 6 External Dependencies Hdefine __DEF_ INCHIP_DBG__ involve debug code in driver socket c E channel h Hdefine DEF_ NCHIP_INT__ involve interrupt service routine socket c ot Hdefine DEF INCHIP PPP involve pppoe routine socket c config h
28. r VGA ee 3 2 1 1 EVB B D Layout amp Configuration c cece cece cece cece ene eee tenet eaeeneeas 3 2 2 PO COC RC B8 99 BR BRI 4 2 2 1 Development Program Insrall ccc ccc ccc cence cence ence tenes eenaeeeeaeeeeas 4 ec EVB B D Test PC Program Install URRA E 4 2 3 Quick Start d 18 f6 B 5 2 4 EVB B D Test SE W E GRP 6 2 4 1 Neetu en ef f 2 4 2 E B D Test ABBlIESllbnsB EEN SI 13 2 5 TrougledheatingfGuide NEEERER EEN 18 29 1 Eh 3 EBERT o 18 252 Misc JR TEE 18 SNR SEE 19 3 1 EOS MaD EEE EN 19 3 1 1 Code amp Data Memory Man 19 3 1 2 AVR Internal EEPROM MAP 20 3 2 By DNA 26 3 2 1 SEENEN 2 3 2 8 OW TO GONDE ETE 28 3 23 How to download 29 3 2 4 EV EDS TMA LEE 29 3 2 5 Manage Program cccccccc cece cee e eee II HH ehe e re eene 33 3 2 6 A ele Wee E 49 4 Hardware Designer s Guide ccccccccceeceeeeeeceeeeeesaaeseeeeeeeeeeeeeseeeeeesesseaseseeeeeesseaaasseeeeeees 92 4 1 EOC LOI ENE E 92 4 2 Block IS eg e le AE 93 4 2 1 Pl NN 93 W5100E01 AVR User s Manual V w LZnet 4 3 4 4 4 5 4 6 4 2 2 EN 97 4 2 3 Ul 98 4 2 4 TN 98 4 2 5 PN 98 4 2 6 Expanded Board Interface 00 c ccc ccc cece cence cent eee e teense me 98 4 2 7 Power Heoulat
29. server and Web client Web browser are needed to be understood Copyright 2007 WIZnet Co Inc All rights reserved nugpy S J9Sf HAV L03001LGM 54 Ww LZnet HTTP which stands for Hyper Text Transfer Protocol is a protocol used in Internet for transferring between Web server and client browsers lt Table 3 26 Web Browser s HTTP Request Operation Procedure gt Request of Client Web Browser gt URL Analysis Transforming Domain Name to IP Address at DNS gt Connection to server at the other end gt Client Web Browser requests document wanted from URL gt Sending Document Server Receiving Document Client gt Displays received document on the browser Web Server program analyzes method and URI Uniform Resource Identifier of HTTP Request message received from web browser In case the related URI simply requests for web page the page will be sent If it requests an action such as CGI Common Gateway Interface it takes the action and the result is informed in web page lt Fig 3 17 gt shows HTTP message flow between web server and web client lt Table 3 28 gt shows structure of HTTP message HTTP Request Web Browser EVB B D Web Server Fig 3 17 HTTP Message Flow Copyright 2007 WIZnet Co Inc All rights reserved IEIUEW S J9Sf YAV LOSOOLSM 55 WIZnet HTTP message Simple Request lt Table 3 27 HTTP Message Format gt Simple Response Full Requ
30. success of change is decided by checking the RCODE Field value of Header Section lt Table 3 42 gt is definition of constants that are used in RCODE Field lt Table 3 41 Constant Definition at Header Section s RCODE Field gt define RC FORMAT ERROR 1 Format error The name server was unable to interpret define RC SERVER FAIL 2 Server failure The name server was unable to process W E S 8 define RC_NAME_ERROR 3 Name Error Meaningful only for responses from an authoritative name server this code signifies that the domain name referenced in the query does not exist define RC_NOT_IMPL 4 Not Implemented The name server does not support Fw wWwr w define RC REFUSED 5 Refused The name server refuses to perform the um VB specified operation for policy reasons If the RCODE is RC NO ERROR variable length sections such as Question Answer Authority and Additional Section are analyzed Since the necessary information is set in Answer Section it s analyzed and processed and other section analysis and process are not performed If you need information on Authority and Additional Section you can get them easily on your own Question Section is processed as many as QDCOUNT of Header Section by calling dns parse question Answer Section is processed as many as ANCOUNT of Header Section by calling dns parse question Copyright 2007 WIZnet Co Inc All rights reserved JenuEy S J9Sf HAV LO300LGSM
31. when it queries Domain Name as IP Address and gets 2 when it queries Name Server status QDCOUNT ANCOUNT NSCOUNT and ARCOUNT Field count information for variable length represent Block Count that is composed of Question Answer Authority and additional section Question section is made of blocks shown in lt Fig 3 36 Question Section Format gt Answer Authority and Additional Sections are composed of blocks shown in lt Fig 3 37 gt For example if QDCOUNT is 1 ANCOUNT is 10 NSCOUNT is 10 and ARCOUNT is 10 then Question Section is composed of block 1 of lt Fig 3 36 Question Section Format gt Answer Authority and Additional Section are composed of 10 blocks shown in lt Fig 3 37 gt NAME of lt Fig 3 37 gt QNAME Filed of lt Fig 3 36 gt and RDDATA Field also get variable lengths QNAME and NAME are variable length fields which are composed of lt Fig 3 36 gt Format and they process each field RDDATA variable length field processes using the data length of RDLENGTH Field For further details refer to RFC1034 and RFC1035 DNS Message is operated by Data Type defined in Table 3 38 Refer to inet dns h Copyright 2007 WIZnet Co Inc All rights reserved JeNnuEN S A9SN HAV LO300LGSM 78 WIZnet lt Table 3 37 DNS Message Data Type gt Header Section typedef struct DHDR u int id Identification u_char flagO u_char flag1 u_int qdcount Question count u int ancount Answer cou
32. ww wiznet co kr t LX After about seconds Support supportQwiznet co kr Sales sales wiznet co kr Press M to enter the manager mode F W Version 1 6 6 6 H W Version 1 8 8 8 MAC Addr 66 68 DC Op Op Dn Source IP z 192 168 0 2 Gateway IP 192 168 0 1 Subnet Mask z 255 255 255 0 DNS Server IP 0 0 0 8 Hem alloc 55 BEH Loop Back TCP Server Started Loop Back TCP Server Started Loop Back TCP Server Started Loop Back TCP Server Started aon sch c lt Fig 2 4 Output of Terminal Program gt 6 Execute Ping test with EVB B D C H gt ping 192 168 60 2 Pinging 192 168 60 2 with 32 bytes of data Reply from 172 168 8 2 hytes 32 time lt ifims Reply from 172 168 8 2 hytes 32 time lt ifims Reply from 172 168 8 2 hytes 32 time lt ifims Reply from 192 168 0 2 bytes 32 time iims Ping statistics for 192 168 0 2 Packets Sent 4 Received 4 Lost 0x loss gt Approximate round trip times in milli seconds Minimum Hms Maximum ims Average 2ms lt Fig 2 5 EVB B D Ping Reply Test gt Execute AX1 program Refer to AX1 Manaul Vx x pdf Test the operation of AX1 program with TCP Client Refer to AX1 Manaul Vx x pdf After setting the Server IP Address as 192 168 0 2 and port Number as 5000 by clicking TCP gt gt Connect Menu then click TCP gt gt Send Menu or Ts Tr Icons 9 Test the loopback with any file or packet between
33. 0 Copy the Destinator list to qname Ping rgsFlags 0x20 Fig 3 8 ping request gt Copyright 2007 WIZnet Co Inc All rights reserved ein 10 9 nugpy S J9Sf HAV L03001LGM 40 LZnet Eing amp rmsFlags Tt Mo Arguments M ER get EOE END of Processing TTPTAGA ra sFlags amp Uu 20 tt Mo Destination ist M icc Convert the IP Address String inta a 32 Bit Address E 1 M TPIngArgsFlags amp 0x0 A I tr Convert the Internet IP Address into a Internet Domain Name Call gethastbyaddr peeip qnam Convert the Internet Domain Name into a Internet IP Address di Unknown Ho Call gethostbyname qname sutressed to Cath IP Address h AT N SUttessed to Can END of Processing H END of Ping rgsFlags 0x40 Convert the 32 Bit Address into the IP Address String ee Display the IP Address String M TEMGArgsklags amp Mid I Tr Display the Internet Domain Mame send the Ping Request To the destination Call pingt amp Pingl nq Fail ta Ping Request M Uccessed ta Carp Display the Result of Ping Request Call DisplayPingStatistic4Pinglog END of Processing Fig 3 9 ping request Continue Copyright 2007 WIZnet Co Inc All rights reserved IEIUEN S J9Sf HAV LO300LGSM 41 WIZnet Let s take a brief look at Ping message before we proceed to Ping program Ping message has the value of 0 Pi
34. 0E01 AVR PARTLIST PDF in the CD 4 5 2 PM A1 Parts List Please refer to PM A1 PARTLIST PDF in the CD jJenuEN S 49Sf HAV L030016M 106 Copyright 2007 WIZnet Co Inc All rights reserved Ww LZnet 4 6 Physical Specification 4 6 1 Power Consumption Power consumption of each component of EVB B D is as in the following table lt Table 4 5 EVB B D Power Consumption gt Power Level 3 3V Total Power consumption is 243mA X 5V 1215mW Copyright 2007 WIZnet Co Inc All rights reserved IEIUEW S J9Sf HAV LO300LSM 107
35. 1 LOOPBACK TCP CLIENT APPLICATION SETTING EXAMPLE cccsccsssseeseseeseeeesseeesseesseeens 11 lt FIG 2 128 9 E SGE OF PING APPLICATION gt E A o 12 lt FIG 2 AEBING APPLICATION TER BR e EE IPs ul 13 lt Fic AEF DHCP CLIENT TEST Ze A ER EE 14 FieiEuI LoeBESSIATCP SERIE M EE eg 15 HEBR 6 Loor RREME P CLAT gt MA 1 B R mn EEN 15 lt Me 7 LOOPBANE E gt uff 16 GERE 0 NR EEN 16 lt FIG 2 19 DEFAULT WEB PAGE OF EVB BD 17 lt FIG 2 20 WEB PAGE OF EVB B D CONTROLS c ccccccsesecsscsssecsetecssceseceseescnsceseeeseteesserseetsetsensenseees 17 lt FIG 3 1 EVB B D MEMORY OT 19 lt FIG 3 2 AVR INTERNAL EEPROM Map 20 lt FIG 3 3 EVB B D S MAIN 32 FLERE NR UT m 33 e le ee MANAGE CONFIG mM V ii 34 FIG 3 6 MANAGE NETWORK 36 lt FIG 3 7 MANAGE_CHANNEL gt vr 38 e meh om PING REQUEST P SEEREN 40 lt FIG 3 9 PING_REQUEST CONTINUE gt vvs 41 lt FIG 3 10 ICMP MESSAGE VS PING MEGA 42 FINN 45 Fio 3 12 DISPLAYING STATISTICS Parr 46 FE INE 47 FT 49 W5100E01 AVR User s Manual vii w L net FIG 31S LOOPBACK TN ne 52 eFC OO LOOPBACK NN 53 FEIN 7 AT TP MESSAGE FLOW EE 55 NG 313 WEB EE 58 eoo eem NC 59 lt FIG 3 20 PARSE ATIP EET A KE 61 Fs ANO ATIR MM icr UU m TU MT 62 lt FIG 3 22 GET HTTP URI
36. 122 and for further inter working the value is incremented by 1 QR Opcode AA TC RD Field are set as OH QUERY OP QUERY OP IQUERY 0 0 1 respectively through MAKE FLAGO and RA Z RCODE Field are set as 0 0 0 respectively through MAKE FLAG1 lt Table 3 39 Constants and MACRO used in Header Section gt define QR QUERY define QR RESPONSE define OP QUERY a standard query QUERY define OP IQUREY an inverse query IQUERY define OP STATUS a server status request STATUS define MAKE FLAGO qr op aa tc rd qr amp 0x01 lt lt 7 op amp 0x0F lt lt 3 aa amp 0x01 lt lt 2 tc amp 0x01 lt lt 1 rd amp 0x01 define MAKE FLAG1 ra z rcode ra amp 0x01 lt lt 7 z amp 0x07 lt lt 4 rcode amp OxOF Since the count fields QDCOUNT ANCOUNT NSCOUNT and ARCOUNT have only one question each is set as 1 0 0 0 respectively Let s look at Question Section QNAME Field is the field that sets IP Address string Domain Name and IP Address string are composed of label length of 1 byte and label of MAX 63 Byte The end of QNAME is always set with 0 to find out the variable length of QNAME Fig 3 41 is actual example of transformation of Domain Name www wiznet co kr in QNAME field p E Tt a Daep Tw OOo w Tze 5 T3 92 To our K 7 oOo Label Length Label ero Terminated lt Fig 3 41 Example of QNAME Field transformation of Q
37. 2 4 1 2 lt Fig 2 14 gt is the screen that DHCP Client successfully obtains network information Note that DHCP Client will be set with default network information if DHCP Server does not exist or is not able to obtain network information from DHCP Server Copyright 2007 WIZnet Co Inc All rights reserved jJenuEN S J9Sf HAV LO300LSM 13 Ww LZnet Mini Term E x File F Configure C Transfer T Help H m sc lt Check the IP Conflict Ho Conflict gt DHCP Client Start Log Get network information from DHCP Server TH HH HOER H HIER HH HH HEHE WO1G8GEG1 AUR Test in Direct Mode TEHETETETEHETETETERHETETETETEHETETETETETETETETEHETETETEHTETETETETETETETEIETETETEHTEH THE Copyright VI2net Inc 2667 Homepage http wuw uiznet co kr Support SupportBuiznet co kr sales Sales wiznet co kr F W Version 1 8 8 H U Uersion 1 8 8 8 HAC Addr DR HS DE DH DH 88 source IP 192 168 8 2 Gateway IP 192 168 0 1 Network Information received from DHCP Server Subnet Mask 1255 255 255 DNS Server IP UR RR 8 Hem alloc 55 HH TETETETETETETETETETETETETETEIETERE TET TETERETETEIETHIE B Loop Back TCP Server Started 1 Loop Back TCP Server Started 2 Loop Back TCP Server Started 3 Loop Back TCP Server Started Connected 57500 8 None l None Capture OFF rx Q TX Fig 2 14 DHCP Client Test 2 4 2 2 Loopback TCP Server Loopback TCP Server Application is an a
38. 86 WIZnet dns parse question Declare amp Initialize Local Variables Declares Initialize Local Variables dns answer u intlen char name MAX ONAME LEN int len type char qname MAX GNAME LER u lang tip Extract amp convart the ONAME field In Question Sectio lenz parse named name i Extract convert the NAME field In Answer ii len parse name qnama Extract the IP Address in cp RETURN cp and then assign itto tip ra OO charf amp tip cp KA mr mm eng data BPM KC uchar amp tip 1 p Y t chafj amp tip 2 p PEN Od charj amp tip 3 p get domain ip tip Extract amp convert the RODATA field In Answer Section len parse nama nameg RETUR i NULL cene len cp RETUR Ep len len cp Copy qname to getdomain name strep get domain name qname RETURN N Y RETUR c id fen zm NULL vm er N T RETUR len parse name qname op sien e ns Ne en E Fig 3 43 dns parse question amp dns answer dns parse question analyses and processes Question Section There is no information that actually used in the Question Section of DNS Request Message but it must be processed to get the starting position of Answer Section Since QNAME Field of Question Section gets variable length parse name processes Copyright 2007 WIZnet Co Inc All rights reserved nuEpy S J9Sf HAV LO300LGSM WIZnet QNAME Field to process t
39. 93 PD5 89 PD6 90 PD7 Port E 2 3 Port E 5 7 1 2 4 6 RESO RES3 Not Available 1 75 42 76 RES4 RES7 43 81 49 83 RES8 RES11 50 84 51 85 RES12 RES15 02 04 87 RES16 RES18 Power Interface 5V Power Supply 3 3V Power Supply Ground No 8 Pin and GND became Short in AVR Module Expanded Board Interface Connector which is PCN10BK 96S 2 54DS of Hirose co is a Din Connector 96Pin Female Rightangle Type Connector of Male Type that is mated here is PCN10 96P 2 54DS Copyright 2007 WIZnet Co Inc All rights reserved IEIUEN S J9Sf HAV LO300LGSM Wiznet 4 2 7 Power Regulator EVB B D gets 5V DC power through power adaptor The powers used inside the board are 5V and 3 3 V The regulator is LT1963EST 3 3 U1 To shut down the regulator Toggle Switch SW1 is used 4 2 8 3 3V Power On System Reset Manual reset and Power On Reset is implemented using RC analog circuit IEIUEW S J9Sf YAV LOSOOLSM 100 Copyright 2007 WIZnet Co Inc All rights reserved Wiznet 4 3 Schematic 4 3 1 W5100E01 AVR Please refer to W5100E01 AVR DSN in the CD 4 3 2 PM A1 Please refer to PM A1 DSN in the CD jJenuEN S 49Sf HAV L030016M 101 Copyright 2007 WIZnet Co Inc All rights reserved WIZnet 4 4 PAL In EVB B D PAL creates Chip Select Module Enable The address map of EVB B D is same as Fig 3 1 EVB B D Memory Map The EVB B D supports 3 enable signal Ch
40. CD LCD E and W5100 CS IINCHIP The output PAL OUT 0 PAL OUT A are set aside for expansion through Expanded Interface 4 2 4 SRAM SRAM with the size of 32Kbytes is used as external data memory of Atmega128 4 2 5 RS232 Port It s a interface for Dual Serial USARTS that is supported by Atmega1 28 EVB B D uses 9Pin DSUB male Type P1 P2 connector 4 2 6 Expanded Board Interface Expanded board interface is designed to be developed easily using EVB B D Most of the port pin of Atmega128 output sinal of PAL PAL OUT 0 PAL OUT 4 power and many reserved pin are connected to Expanded Board Interface The Signals of Atmega128 that are not connected to Expanded Board Interface are 7 RXD1 PD2 TXD1 PD3 RXDO PEO TXDO PE1 LEDO PG3 LED1 PG4 I2CHIP IRQ PEA Table 4 4 Expanded Board Interface Pin Description gt wes Pinnae De Dein Bus Interface 66 34 67 35 AO A1 A2 A3 Parallel Address Bus 0 15 68 36 69 37 A4 A5 A6 AT 70 38 71 39 A8 A9 A10 A11 73 40 74 41 A12 A13 A14 A15 77 45 78 46 DO D1 D2 D3 I O Parallel Data Bus 0 7 pene pase Parallel Bus Read Strobe 4 m eR PAL OUT 0 Reserved Parallel Bus Chip Select Enable N PAL OUT 4 SDA PDO GC Bus Data Line Port DO Copyright 2007 WIZnet Co Inc All rights reserved JeNnuEN S A9SN HAV LO300LGSM 98 WIZnet SCL PD1 o I2C Bus Clock Line Port D1 Atmega128 Port Interface Port B 0 7 VO PD4 Port D 4 7
41. DHCP client using the MAC Address of EVB B D By calling init dhcp client after setup of SRC MAC ADDR it can register two functions to be called in case of collision of the IP received from DHCP Server and in case of renewal the IP from DHCP Server When calling init_dhcp_client if each function is not specified set DHCP network and proc ip conflict of DHCP Client Program respectively init dhcp Chen Haram s ip update ip conflict Assgn the Socket for DHCP Client DHCPC SOCK 8 Assign the User Handler for IP Update dhcp_ip_update ip_update 5 update I NULL Assign the Default Handler for IP Update dhcp ip update set DHCP network i M Assign the Default Handler for IP Conflict dhcp ip canflict ip canflict END Assign the User Handler for IP Conflict dhep ip update proc ip conflict lt Fig 3 28 init dhcp client gt When network information is renewed or IP collision occurs register evb soft reset to run auto reset for EVB B D Second Network Information acquirement can be done through getIP_DHCPS Copyright 2007 WIZnet Co Inc All rights reserved JeNnuEN S J9Sf HAV LO300LGSM WIZnet getP DHCPSQ Y Find a DHCP Server send DHCP DISCOVER Y dhcp state STATE DHCP DISCOVER Y Reset timeout value amp retry count reset DHCP time Y Set Timer for DHCP Client set timer 1s Y DHCP Timeout 0 dhcp state STATE DHCP LEASED
42. E01 AVR hex BE avr objcopy j eeprom set section flags eeprom alloc load change section lma eeprom 0 0 ihex WSlOO0EO01 AVR elf WSlOO0E01 AVR eep socket h B send AVR Memory Usage hjstdargh 0 2222222222222 per Device atmegal238 stdint E Program 82334 bytes 62 8 Full 5 timer h text data bootloader Kit wh Bam Data 2154 bytes 52 6 Full P version h data bast noinit B w5100 h 1 webserver h 3 Other Files E Build succeeded with 0 Warnings w D a Ji Or Ou IF Bb ATmega128 438 Co 1 NUM After compile is completed a hex file will be created in the folder that user defined before This file will be programmed in Atmega128 Copyright 2007 WIZnet Co Inc All rights reserved IEIUEW S J9Sf HAV LO300LSM 28 WIZnet define ENDIAN LITTLE 0 define _ENDIAN BIG 1 define SYSTEM ENDIAN ENDIAN LITTLE define DEF IINCHIP DIRECT MODE define DEF IINCHIP INDIRECT MODE Table 3 14 W5100 s DEFINE Option types h amp define DEF IINCHIP SPI MODE define DEF IINCHIP BUS DEF IINCHIP DIRECT MODE define DEF IINCHIP BUS DEF IINCHIP INDIRECT MODE define DEF IINCHIP BUS DEF IINCHIP SPI MODE Since EVB B D is Little Endian system SYSTEM ENDIAN should be defined ENDIAN LITTLE and used If the target system is Big Endian the defined items should be defined ENDIAN BIG If W5100 is intended to be used as different mode other th
43. NAME amp GET HITTP DPARSE VALUEIl 62 FiG 3 23 NETCONF CGI DESSESSISESNEEENM cessssseeeennnennnennnnnn nnne nnn lll WEN 63 FiG 3 24 LODNLED GIEBERESSESSING BRA P T ERE sss 64 lt FIG 3 25 DHCP IdESSSSPT LOW 99888 ga Ree 66 lt FIG 3 26 DH RMIESSAGE FORMAT 9 98 95 PERI 67 Fia 3 27 DHCP MESSAGE S OPTION FIELD FORMAT 68 lt FIG 3 299 mI m DHCP CLIENT gt 202089 2880 PAL 69 Fia 3259 EETIP DHCPS dem HEED GER LAM ZEN 70 Fia 3 30 DHCP MESSAGE FLOW BY DHCP CLIENT DATE 72 FIEESEN Cus tSIPLICP Gro SIS nen GR ef 73 lt FIG 3 32 PARSE DHCPMSG A CHECK DHCP Two 74 lt FIG 3 33 DOMAIN NAME SYSTEM STRUCTURE amp DNS MESSAGE EULOwWw eene 76 lt FIG 3 34 DNS MESSAGE FORMAT gt ccccccssscsssscsssscsssccssseesssecssseeseseeseseesseesseesseeeeseeessneessesessenessneeess TI lt FIG 3 35 HEADER SECTION FORMAT 77 FIG SR QUESTION SECTIONBBORMAT gt ccccccsscsrcsscsscssssssccescnscsscsscnsonssssecesscscnsosososssssccsncnscesonsons 17 Fie ERE SEN 78 lt FIG 3 38 GETHOSTBYADDR amp GETHOSTBYNAMEN eese eene enne een ennnn sentent n seen nens 80 FM EN 81 FIG 3 40 DNS EELER 82 lt FIG 3 41 EXAMPLE OF QNAME FIELD TRANSFORMATION OF QUESTION SECTION gt 83 FIG 3 42 DNS PARSE RESPONSE gt sssccccccosssssscccesssnsecceesscsseccessssseccesssnseeceessas
44. Network Config menu is selected on Manage Program menu shown in lt Fig 2 7 gt can be displayed and each function is described in lt Table 2 3 gt Copyright 2007 WIZnet Co Inc All rights reserved IEIUEW S J9Sf HAV LO300LSM WIZnet Display contig Source IP Gateway IP Subnet Mask DNS Server IF HAC address memory Allocation Factory reset lt Fig 2 7 Network Config gt lt Table 2 3 Menu of Network Config gt mem Seene 4 DNS Server IP Sets up DNS Server IP Address Warning DNS Server is information needed for Ping Request test and transformation of Domain Name into IP address Therefore it must be set up as Static IP Address F Factory Reset Initialization of the system with the default value Refer to Table 2 2 M or m Sets up MAC Address Warning This value is not changed when Factory Reset A or a Sets up Memory Allocation W5100 Memory Size Register RMSR TMSR Refer to W5100 Datasheet pdf Copyright 2007 WIZnet Co Inc All rights reserved JeNnuEN S A9SN HAV LO300LGSM WIZnet lt Fig 2 8 gt is an example of setting the Source IP of EVB B D in Network Config NETWORK CONFIG Display contig Source IP Gateway IF Subnet Mask DNS Server IP MAC address memory Allocation Factory reset Source IP 192 168 0 100 lt Fig 2 8 Source IP Address Setup Example gt lt Fig 2 9 gt is an examp
45. PORT 3 define CH DESTIP 3 lt Table 3 2 AVR Internal EEPROM MAP Definition gt 0x00 SYS_INFO SYS_TEST 2 SYS_VER 4 SYS AUTORESET 1 0x20 NET CONF NET TEST 2 NET MAC 6 NET SIP 4 NET GWIP 4 NET SN 4 NET DNS 4 0x50 CH CONF CH TEST 2 CH TYPE 0 1 CH PORT 0 2 CH DESTIP 0 4 CH TYPE 1 1 CH PORT 1 2 CH DESTIP 1 4 CH TYPE 2 1 CH PORT 2 2 CH DESTIP 2 4 CH TYPE 3 1 CH PORT 3 2 Copyright 2007 WIZnet Co Inc All rights reserved IEIUEN S J9Sf HAV L03001LGM 21 WIZnet 3 1 2 1 System Information System Information area is used in recording System Information such as Firmware Version of EVB B D lt Table 3 3 System Information gt SYS TEST Valid Check of System Information OxA5SA5 Valid Others Invalid SYS VER F W Version OxAABBCCDD AA BB CC DD SYS AUTORESET Auto reset check in case of setting up 0x01 System Auto Reset Tess ees SYS ANY PORT Using Any Port Number at Socket 1000 65535 West o System Information is accessed as SYSINFO Data Type lt Table 3 4 SYSINFO Data Type Definition gt Reeg typedef struct SYSINFO SYSINFO Syslnfo J u_int test u_long ver u char auto reset u int any port SYSINFO lt Table 3 5 System Information Access Functions gt void set sysinfo SYSINFO pSysinfo Save the System Information void get_sysinfo S
46. REQEUST or DHCP BOOTREPLY u_char htype DHCP HTYPE10MB u_char hlen DHCP HLENETHERNET u_char hops DHCP HOPS u long xid DHCP_XID u int Secs DHCP SECS u int flags DHCP FLAGSBROADCAST u_char ciaddr 4 u_char yiaddr 4 u_char siaddr 4 u_char giaddr 4 u_char chaddr 16 u_char sname 64 u char file 128 u_char OPT 312 RIP_MSG DHCP Message of lt Fig 3 26 gt is managed by RIP_MSG Data Type defined in lt Table 3 33 gt Refer to inet dhcp h To take a brief look at the Option Field of DHCP Message Option Field has the format of Fig 3 27 it contains Magic Cookie Field a Lease Identification Cookie with the size of 4 Byte and Code Set ranged from Code 0 to Code 255 From Code1 to Code 254 codes are composed of pairs of Code Len Value and Copyright 2007 WIZnet Co Inc All rights reserved JenuEy S J9Sf HAV LO300LGSM WIZn et Code 0 and Code 255 are composed of Code only For further explanation of each Code of Option Field refer to RFC1533 D 7 B 15 Magic Cookie 4 Code 1 Len 1 um m eh p Mi to Zero Padding lt Fig 3 27 DHCP Message s Option Field Format gt lt Table 3 33 DHCP Message Option Code Definition gt padOption used to cause subsequent fields to align on word boundaries subnetMask specifies the client s subnet mask routersOnSubnet a list of IP addresses for routers on the client s subnet 0 1 3 6 dns
47. SR SOCKET s Informs status of socket iinChip w5100 c uint16 getSn RX RSR SOCKET s size of data transmittable and iinChip w5100 c received data u_char socket SOCKET s Creates sockets as TCP UDP IP linChip socket c u_char protocol u_int port u_char flag u int sendto SOCKET s const Transmits data through specific port iinChip socket c u_char buf u_int len u_char addr of specific Destination u int port u int recvfrom SOCKET s u_char Receives data through any port of iinChip socket c buf any destination u intlen u char addr u int port void close SOCKET s Closes the Socket iinChip socket c 3 2 6 6 DNS Client Let s take a brief look at the DNS Domain Name System before DNS Client setup is introduced DNS is a system that transforms Internet Domain Name to Internet IP Address or Internet IP Address to Internet Domain Name DNS is composed of Name Server that contains mapping table between IP Address and Domain Name and DNS resolver that receives query results by transmitting query to Name Server DNS resolver queries IP address or Domain Name to be transformed to local Name Server Local Name Server which received the Query searches its DB and answers back to the Resolver If Resolver cannot find the information it looks up Local Name Server sends the received query to Name Server at higher layer and the received answer can be sent to the Resolver d uerg SS Local RESOLVER Mame
48. T p amp PRIPMSG 0p M check DHCP Timenut min m nest tim e my timexDHCP WAT TIME retry count dhcp state STATE DHCP DISCOVER Broadcast DHEP REGUEST send DHCP REGUEST Broadcast DHF REQUEST send DHCP REGUEST p 240 g p len 240 END e E RETURN 0 Y B endoptiarr i RETURN type MN HadOption Y opt len 0 4 M Y dhcpMessageTypg opt len apt len apt len p opt len opt len apt len type p Set GET SN MASKE mermcpyiGET SN MASK p SELGET Ow IP memcpyiGET Gy P p Skip Other DMS pr 4 opt len 4 Set GET DNS IP memcpyiGET ONS IP p Set Lease Time lease time iu lancd p set DHCP SIP mermcpyiDHCP SIP p 4 p opt len Fig 3 32 parse DHCPMSG amp check DHCP Timeout gt Copyright 2007 WIZnet Co Inc All rights reserved JenuEy S J9Sf HAV LO300LGSM 14 WIZnet parseDHCPMSG receives DHCP message from DHCP server categorizes Type of DHCP Message and saves network information When performing check DHCP state check DHCP Timeout is called in case that DHCP message is not received during the DHCP WAIT TIME or received DHCP message from DHCP server is not expected to retransmit DHCP message to DHCP server If the retransmission of DHCP message is repeated as much as MAX_DHCP_RETRY it transmits DHCP_DISCOVER message to DHCP serv
49. TEM INFORMATION AE RR 5 PEE 22 lt TABLES AT SYSINFO DATA TYPEGDEFINITION gt 2 cc00Geeueteeenhscsssesesessesesecfauetegenecesssscesssceessseeadgn 22 TABLE 3 5 SYSTEM INFORMATION ACCESS FUNCTIONS ccccsccsscsscescesceseeseeseesecsessecesceseeseeseesseseenes 22 lt TABLE 3 6 NETWORK INFORMATION 0 cc cccseccccsescceserecetanensnatedesesesssereefunseseneeliicssecssseeessneeesenenens 23 TABLE 3 7 NETCONF DATA TYPE DEFINITION seserecserisenessslscsetessetesseressenessenersenesseneess 23 lt TABLE 3 8 NETWORK INFORMATION ACCESS FUNCTIONS esses eene eene enne 23 TABLE 3 9 CHANNEL INFORMATION 24 TABLE 3 10 CHANNEL APPLICATION TP 24 lt TABLE 3 11 CHCONF DATA TYPE DEFINITION EE 25 lt TABLE 3 12 CHANNEL INFORMATION ACCESS FUNCTION gt ener 25 STABLE 3 13 EVB RE e 2 lt TABLE 3 14 W5100 s DEFINE OPTION TYPES H zs 29 lt TABLE 3 15 REFERENCE FUNCTIONS IN EVB B D S MAIN gt essen 31 TABLE 3 16 CALLER FUNCTION AT MANAGE PROGRAM 35 lt TABLE 3 17 REFERENCE FUNCTIONS IN MANAGE CONFIG essen nennen eene nens 37 TABLE 3 18 CONSTRAINT BY APPLICATION TYPES c cccccsccssessessessesscsscesceseeseesecsecsecsecscsscessesseseeneens 38 lt TABLE 3 19 REFERENCE FUNCTIONS IN MANAGE CHANNEL zs 39 TABLE 3 20 PINGMSG DATA TYPE DEFINITION gt enne enne ener nennen entes 43 TABLE 3 21 PINGLOG DATA TYPE DEEINTTIONS 43
50. W5100E01 AVR User s Manual Version 1 0 K a Eat II X en rri 4 o fa p af NEE o man o a NEEN _ po o 0 3 clo 8010 WIZnet Uia iii Kr NE vr Dod EG uni Ww IZnet 02007 WlZnet Co Inc All Rights Reserved For more information visit our website at http www wiznet co kr w LZnet Document History Information Ver 1 0 Febrary 1 2007 Original Document S W5100E01 AVR User s Manual ii w LZnet WIZnet s Online Technical Support If you have something to ask about WIZnet Products Write down your question on Q amp A Board in WIZnet website www wiznet co kr WlZnet Engineer will give an answer as soon as possible WiZnet Products Tachnolngy Spec Haw to buy aw Partners About wii Hf vou find the best network H re is Wam VEE net provides the cieupvest ma manirs mernet conmectms uge eon dade FORT cig ard oneness m les Products ppthap HM TOR Ge TOP EP Ethernet Module HBP DIDA he mai neram marbais bee VG 1 OC Ville ach m TCP sg t DMT itd oon luc leges H cas bs ved EGO EX SK TIOUA EVH Deeg iid 736693 Eegen Baard SPA OS pm al musa rufa recta geht VCTTUCU Sar heri el Legd bes How i TCPAP ihip ERerzel PHT and olfres glue logea can be ve ANGA Denies VIDET CALA LE M
51. YSINFO pSyslinfo Get the System Information Copyright 2007 WIZnet Co Inc All rights reserved nuEpy S J9Sf HAV LO300LGSM 22 WIZnet 3 1 2 2 Network Information Network Information is used in recording Network Configuration information to be used for EVB B D Table 3 6 Network Information gt NET TEST Valid check of Network 0xA5A5 Valid Information Others Invalid JeNnuEN S A9SN HAV LO300LGSM NET SIP Source IP Address OxCOA80002 192 168 0 2 Network Information is accessed as NETCONF Data Type lt Table 3 7 NETCONF Data Type Definition gt Type Definition Global Instance typedef struct NETCONF NETCONF NetConf d u int test u_char mac 6 u long sip u long gwip u long sn u long dns u char mem alloc NETCONF lt Table 3 8 Network Information Access Functions gt void set netconf NETCONF pNetConf Save the Network Information void get netconf NETCONF pNetConf Get the Network Information 23 Copyright 2007 WIZnet Co Inc All rights reserved WIZnet 3 1 2 3 Channel Information Following table introduces applications to be used in 4 channels of W5100 lt Table 3 9 Channel Information gt CH TEST Valid check of channel OxA5A5 Valid Information Others Invalid CH_TYPE_X Application type of Default LB TCPS No X Channel NOTUSE Not Used DHCP CLIENT DHCP Client LB TCPS Loopback TCP Server LB TCPC Loopback TCP
52. an Direct Bus Mode use desired Bus Mode defined as DEF IINCHIP BUS _ instead of DEF IINCHIP DIRECT MODE _ If DEFINE OPTION of W5100 is changed the sources must Re Build To Re Build project do make clean then make In case of SPI mode be sure to change the configuration of JP3 in the W5100E01 AVR board For more detail refer to Chapter 2 1 1 EVB B D Layout amp Configuration 3 2088 How to download For downloading the hex file we use AVRStudio and AVRISP Cable 1 Connect AVRISP Cable to JP3 at the PM A1 Supply the power to EVB B D Run AVRStudio exe A W N Select ATmega128 in Device section 5 Select the HEX file in FLASH section 6 Click Program button Please refer to AVR Tool Guide pdf for more information 3 2 4 EVB B D s main If we take closer look at main for certain amount of time we wait for Manage Program from RS232 Terminal after initialization of board with board reset At this point if RS232 terminal displays the Manage Program entering command EVB B D environment such as network information and channel Information can be set and ping request program can be run If Manage Program is done or there is no entering command from RS232 terminal the application for each of 4 channels of W5100 is executed and initialized using previously set network information lt Fig 3 3 gt process procedure of EVB B D main Refer to main main c Copyright 2007 WIZnet Co
53. at is not actually used For this reason there is no chance for collision with other network For DHCP server to transmit UDP broadcast packet note that Flag field MSB of DHCP message must be set 1 Refer to lt Fig 3 26 DHCP Message Format gt lt Table 3 36 gt is a part of code that sets up Flag field lt Table 3 35 DHCP Message Flag Field Setup gt define DHCP FLAGSBROADCAST 0x8000 pRIPMSG gt flags htons DHCP FLAGSBROADCAST Third management of network information obtained from DHCP server can be performed by check DHCP state lt Fig 3 30 gt shows DHCP message flow due to DHCP client state change in the check DHCP state process Copyright 2007 WIZnet Co Inc All rights reserved JeNnuENy S J9Sf HAV LO300LGSM 71 WIZnet DHCP Client DHCP Server DHOP_DISCOVER STATE DHCP DISCOVER Receive Timeout DHCP DISCOVER DHCP OFFER STATE DHCP REQUEST IEIUEN S J9Sf HAV LO300LGSM Receive Timeout DHCP REQUEST STATE_DHCP_DISCOVER DHCP DISCOVER DHCP OFFER STATE DHCP REQUEST DHCP REGUEST STATE DHCP LEASED After the half af leased time DHCP REQUEST Unicast STATE DHCP REREQUEST STATE DHCP LEASED lt Fig 3 30 DHCP Message Flow by DHCP Client State gt check DHCP state checks if there is DHCP message from DHCP server It receives and analyzes DHCP message Accoridng to the types of analyzed DHCP message if it s DHCP message that can be receivable it changes to next state
54. ated records A request for mail agent RRs request for all records define CLASS IN Internet define CLASS CS CSNET class define CLASS CH CHAOS class define CLASS HS Hesiod Dyer 87 define QCLASS ANY Any class Copyright 2007 WIZnet Co Inc All rights reserved JeNnuEy S J9Sf HAV LO300LGSM 84 LZnet dns parse response Declare amp Initialize Local variables u inti DHDR dhdr chat cur ptr dns but dhdrid 000 intfcur ptr M IEIUEN S J9Sf HAV LO300LGSM dns_id Eur ptr 2 dhdrfilagO cur_pirt dhdrflagt cur_pirt qhdrflagd amp ep ST Y RETURN O N Thdrflagi amp wsi T H Display the Error l Indrflagt amp OXOF EU H dhdrgqdcount Su inf ceur ptr dhdrancaunt SOU inf ycur_ptr 2 dhdrnscaunt Su intfeur pir dl dhdrarcount iu intficur Dirr cur ptr H Parse the Question Section dns parse question cur ptr Parse the Answer Section dns answer cur ptr Y M vun ung M RETURN 1 Fig 3 42 dns parse response gt 85 Copyright 2007 WIZnet Co Inc All rights reserved WIZnet dns parse response of lt Fig 3 42 gt analyzes Response Message received by DNS Name Server dns parse response checks if it s same as Request Message ID that was sent to DNS Name Server and it also checks if the message received is a response message by checking QR Field of Header Section If the received message is response from DNS Name Server the
55. ation The network information is valid only for the Lease Time suggested by DHCP server Hence if DHCP Client wants to keep using the network information it retransmits REQUEST message to DHCP server to maintain network information usually after half of the Lease Time In this process DHCP client can get same or new network information from DHCP server In case that it receives new network information the new one must be used Message between DHCP server and client has the format as in lt Fig 3 26 gt with the size of 544 Bytes Refer to document RFC1541 for detailed explanation for each field of DHCP message Format op Field of the first Copyright 2007 WIZnet Co Inc All rights reserved JenuEy S J9Sf HAV LO300LGSM 66 WIZnet byte decided Request Reply and fields after ciaddr is used to deliver network information and options field of 312 byte is used to transmit message type or the information such as Client Identifier 15 16 31 htype 1 hlen 1 hops 1 AG em m 2 gt riis ntis sett 1 te Br Message SHOUD siaddr 4 be sentas using an IP Broadcast address giaddr 4 chaddr 15 preferably 255 255 255 255 asthe IP destination address MBZ Must Be ZERO Reserved for future use oi OD eee Oe P On file 128 options 312 lt Fig 3 26 DHCP Message Format gt lt Table 3 32 DHCP Message Data Type gt typedef struct RIP MSG d u_char op DHCP BOOT
56. d 3 Connected by 192 166 0 30 2313 Peer Connection Information lt Fig 2 18 Web Server Test gt If the web browser is successfully connected to HTTP port of EVB B D the Web Page of lt Fig 2 19 gt can be viewed In case Web Page of lt Fig 2 19 gt is not shown refresh the screen using the Refresh function of the web browser Copyright 2007 WIZnet Co Inc All rights reserved IEIUEW S J9Sf HAV LO300LSM 16 WIZnet Silicon Proven TCP IP Technology Wl net provides the simplest Internet connectivity Using menory like hardware TORAP chips and Component modules Control lt Fig 2 19 Default Web Page of EVB B D gt If Control button on the Web Page in lt Fig 2 19 gt is clicked it can set the network information or show the web page that can turn on or off LEDs D3 D4 and display rows of text on Text LCD display source IP 192 166 000 002 Gateway IP 152 168 000 001 5 subnet Mask 255 255 255 000 ONS Server IP 000 000 000 000 MAC Address 00 08 DC 00 00 35 Network Contig LEDO e 192 168 000 002 KG LEDI e LCD amp LED Config lt Fig 2 20 Web Page of EVB B D Control gt Copyright 2007 WIZnet Co Inc All rights reserved IEIUEW 5 J195N YAV LOSOOLSM 17 WIZnet 2 5 Troubleshooting Guide 2 0 1 Ping When you can not reach EVB B D by Ping command Step 1 Check if you connect correctly test PC and EVB B D with UTP cable Step 2 Ch
57. d RD Signal are used together to control the timing 103 Copyright 2007 WIZnet Co Inc All rights reserved WIZnet LCDCS 0x9000 0x93ff process Addr nRD nWR begin if Addr gt 100100 and Addr lt 100101 and nRD 0 or nWR 0 then LCDCS lt 1 else LCDCS lt 0 end if JEeNUuENN S J9Sf HAV LOI00LGSM end process 0x9000 lt lt 0x9400 LCD E A15 amp A14 amp A13 amp A12 amp IA11 amp A10 amp InRD InWR LCD is High Active Enable Signal 4 4 4 W5100 Area In case of W5100 the address is divided into 2 parts about same Chip For more details refer to W5100 Datasheet 104 Copyright 2007 WIZnet Co Inc All rights reserved WIZnet IINCHIP 0x8000 0x8800 0xC000 OxFFFF process Addr begin if Addr gt 100000 and Addr 100010 or Addr gt 110000 then nCS IINCHIP lt 0 else nCS IINCHIP lt 1 end if end process 0x8000 lt 0x8800 OR gt O0xCO000 InCS IINCHIP A15 amp A14 amp IA13 amp IA12 amp IA11 4 A15 amp A14 For VHDL Source Code refer to EVB PAL VHD in the CD For CUPL Source Code refer to EVB PAL PLD in the CD Please refer to AVR Tool Guide pdf for compiling Copyright 2007 WIZnet Co Inc All rights reserved IEIUEN S J9Sf HAV LO300LGSM 105 Wiznet 4 5 Parts List 4 5 1 W5100E01 AVR Parts List Please refer to W510
58. date PingRequest checksum Verify the Arguments PingLog PingRequest S cessed to Send N PingLog ARPErr Y A N Diapiay Loss PingLog Loss H sReceived 0 N RemainTime gt 0 Ping Reply Y Wait 2 ms ocket Status SOCK CLOSED PingLog ChecksumErr a Display Unknown Peer IsReceived 1 Calculate Check Sum of PingReply PingLog UnkonwMSG va N Check Sum Error Y Display Checksum Error PingReply type 0 N Display Unreachable Error PingLog UnreachableErr IsReceived 1 PingReply type N Y PingLog TimeExceedMSG Y p IsReceived 1 lt PingReply type 11 N d N z received peer addr Send a Ping Reply to a peer S PingReply type 8 Call SendPingReply N PingLog PingReply PingLog UnkonwMSG IsReceived 1 Display Unknown Message O Display Ping Reply OK lt Fig 3 11 ping gt Copyright 2007 WIZnet Co Inc All rights reserved JENUEIN S 49Sf YAV LOSOOLSM WIZnet Display Ping Statistics Display a Title Display the Packet Count Sent ReceivedLost Display the Check Sum
59. eck if interface jumper of JP3 is correctly set JP3 SPI mode pin2 3 should be connected Bus mode pin1 2 should be connected Step 3 Check if you correctly change your test PC s network environment IP address Gateway Subnet If not you should change it as follows IP address 192 168 0 3 Gateway address 192 168 0 1 Subnet Mask 255 255 255 0 Step 4 Check if link LED of MAGJACK left LED from rear view is on If it is off check UTP cable is working properly 2 0 2 Misc When the serial terminal screen remains blank with the power on after a connection is made Step 1 Check the connection condition of the serial cable Step 2 Check the COM Port numbers of the PC and terminal coincide Step 3 Check the terminal s baud rate 57600 Copyright 2007 WIZnet Co Inc All rights reserved nuEpy S J9Sf HAV LO300LGSM 18 WIZnet 3 Programmer s Guide 3 1 Memory Map 9 1 1 Code amp Data Memory Map Memory Map of EVB B D is composed of code memory 128 Kbytes and data memory 64Kbytes Data memory is divided into SRAM W5100 and Text LCD Area Other than these there is 4Kbytes AVR Internal EEPROM Various types of environmental variables are recorded on this EEPROM Fig 3 1 Table 3 1 are representations of System Memory Map of EVB B D Ox1FFFF OxFFFF 0xC000 0x9400 0x9000 0x8400 0x8000 0x1100 0x0100 Er 0x00000 lt Fig 3 1 EVB B D Memory Map gt 0x0000
60. ed Unreachable MSG field and TimeExceedMSG field are incremented by 1 in case of receiving Unreachable Message or Time Exceeded Message from peer or gateway UnknownMSG field is incremented by 1 when the unknown message is received Copyright 2007 WIZnet Co Inc All rights reserved JeNnuEN S A9SN HAV LO300LGSM 43 Wiznet ARPErr field is incremented by 1 whenever ARP reply is not received upon ARP request to get the Hardware address MAC Address of the peer PingRequest field is incremented by 1 whenever ping sends Ping request PingReply field is incremented by 1 whenever Ping reply for Ping request from the peer is received Loss field is incremented by 1 whenever Wait Timeout is occurred because nothing is replied to the peer in certain period of time after sending Ping request Copyright 2007 WIZnet Co Inc All rights reserved IEIUEW S J9Sf HAV LO300LSM 44 WIZnet Local Variable Declare amp Init SOCKET s 1 PING PingRequest PING PingReply N bLoop 0 RemainTime 0 IsReceived 0 long peerip inet aton addr Y PingRequest type 8 PingRequest code 0 RemainTime time 2 PingRequest checksum 0 PingRequest seqnum Le count END PingRequest id Random Integer Number PingRequest checksum 0 PingRequest seqnum Random Integer Number IsReceived 0 Fill in PingRegeust data with a to w alphabet N Calculate Checksum of PingRequest Up
61. efault Applied 122 153 0 3 server Port Num 1 565535 Default Applied 3000 lt Fig 2 11 Loopback TCP Client Application Setting Example gt lt Table 2 7 Application Default Value gt Application Type Default Value TCP Loopback Server Listen Port Number 5000 TCP Loopback Client Server IP Address 192 168 0 3 Jesse 0 Copyright 2007 WIZnet Co Inc All rights reserved JeNnuEN S A9SN HAV LO300LGSM 11 Wiznet 2 4 1 3 Ping Application Test Ping Application Test is a program created for IP RAW channel evaluation of W5100 and sends Ping request to certain peer and receives Ping Reply This program is set up identically with the ping command in the DOS prompt It s executed when 3 is chosen Fig 2 6 Manage Program Execution gt Mini Term File Ei Configure C3 Transfer T3 Help CH cH s Y i Channel Config Ping ipp Test Factory Reset n count l size w timeout destination list Ping the specified host until stopped To see statistics and continue type Control Break To stop type Control c Resolve addresses to hostnames Number of echo requests to send l size Send buffer size w timeout Timeout in milliseconds to wait for each reply Connected 57600 8 Mane 1 Mane Capture OFF lt Fig 2 12 Usage of Ping Application gt lt Fig 2 12 gt displays the execution screen of Ping Application and shows how to use the Ping Application Copyrig
62. enseeesseeens 75 lt TABLE 3 37 DNS MESSAGE DATA TYPE sessi nennen enne nnne nennen tentent nnns 79 lt TABLE 3 38 QUERY TYPE DEFINITION AT DNS OUER 79 lt TABLE 3 39 CONSTANTS AND MACRO USED IN HEADER SECTION gt c ccccsscessecessecessecessseesseeesseens 83 lt TABLE 3 40 CONSTANTS DEFINITION AT QTYPE amp QCLASS FIELD eene 84 lt TABLE 3 41 CONSTANT DEFINITION AT HEADER SECTION S RCODE FIELD sssess 86 TABLE 3 42 REFERENCE FUNCTIONS IN DNS CLIENT zs 91 TABLE 4 1 PM A1 MODULE PIN DESCRIPTION ccscccsssseessecesseceseeesseeessseeeseeeseeeeseeenseeenseeeneeens 94 lt PERE 4 2 ISP PINNEESSBIPTION CERA e 96 lt PEE 4 3 LCD PIN DESSBIBIION EEN 97 TABLE 4 4 EXPANDED BOARD INTERFACE PIN DESCRIPTION cccccccssesesscseescsecseesesecseescsecseeseseeseeas 98 lt TABLE 4 5 EVB B D POWER CONSUMPTION gt ccssccesscesscsssecssecesscsseeeesscessesseeceecessesseeseeecessesseessass 107 W5100E01 AVR User s Manual X WIZnet 1 Overview W5100E01 AVR is W5100 Evaluation B D for AVR developers 1 1 Package When purchasing W5100E01 AVR B D please make sure you have all the following contents Table 1 1 List of Items Contained in the EVB B D gt po Rec quee W5100E01 AVR Main Board PM A1 MCU Module Plugged In a EVB B D AVR Power Adaptor DC5V 2A e UTP Cable Serial Cable ISP Gender Type Option
63. equest Type 0 pingrequest Code 0 pingrequest CheckSum 0 Calculate the check sum of pingrequest Successed to Send N Y RETURN lt Fig 3 13 SendPingReply gt Copyright 2007 WIZnet Co Inc All rights reserved jenuEy S SN HAV L0300LGM 47 WIZn et lt Table 3 22 Reference Functions in ping_request gt void ping_request void Ping Request program app ping_app c void ping_usage void Outputs the instruction of Ping Request app ping_app c program char ping Sends Ping Request to specific inet ping c int count u_int size u_int destination and processes ICMP time u_char addr PINGLOG message received from any destination log void H Ail Outputs the results from ping calling inet ping c mos m em void SE Assigns IP protocol of the related socket iinChip w5100 c e e char socket SOCKET S Creates sockets related to as TCP UDP IP iinChip socket c u char protocol u int port u char flag int sendto SOCKET s Sends Datagram packet to specific iinChip socket c const u char buf u int len destination u char addr u int port int recvfrom SOCKET s Receives Datagram packet from any iinChip socket c u_char buf u_int len destination u_char addr u_int port SOCKET getSocket unsigned Searches for socket has the designated util sockutil c char status SOCKET start status Copyright 2007 WIZnet Co Inc All rights reserved
64. er after it initializes all the variables to start the connection of DHCP server and DHCP message lt Table 3 36 Reference Functions in DHCP Client gt void init dhcp client SOCKET s Initializes DHCP Client inet dhcp c void ip update void void ip conflict void u int getlP DHCPS void Obtains network information from inet dhcp c 4 y void check DHCP state SOCKET s Manages network information inet dhcp c ums obtained from DHCP Server EA void set DHCP network void Applies network information inet dhcp c obtained from DHCP server to W3150A char parse 3 Analyzes and processes DHCP inet dhcp c EOS NN d ERN void check DHCP Timeout void Retransmits the DHCP message inet dhcp c when DHCP connection Timeout occurs char check_leasedlP void Check if the IP obtained from DHCP inet dhcp c se e void reset DHCP time void Initializes DHCP Timer related inet dhcp c void send DHCP DISCOVER Transmits DHCP DISCOVER inet dhcp c SOCKET s message to DHCP server East void send DHCP REQUEST Transmits DHCP REQUEST inet dhcp c SOCKET s message to DHCP server M void Transmits inet dhcp c send DHCP RELEASE DECLINE DHCP DISCOVER DHCP DECLIN mms SOCKET s char msgtype E message to DHCP server u_int init_dhcpc_ch SOCKET s Creates DHCP client socket inet dhcp c Copyright 2007 WIZnet Co Inc All rights reserved JenuEy S A9SN HAV LO300LGSM 75 WIZn et uint8 getSn_
65. escessseesescesseneseseenes 85 lt FIG 3 43 DNS PARSE QUESTION amp DNS ANSWER issssseeseeeeeeenenneee nnne nennen en ernnn nennen 87 FE MENE EE 88 lt FIG 3 45 DNS MESSAGE COMPRESSION SCHEME sss nne 89 lt FIG 4 1 EVB B D BLOCK DIAGRAMS ccccccscescescescsscsscsecseeseescescsacsassscsecsecsecseescsacsacsassessecstestesteaeeass 92 lt FIG 4 2 PM A1 MODULE DIMENSION ee 93 W5100E01 AVR User s Manual vill w L net Tables lt TABLE 1 1 LIST OF ITEMS CONTAINED IN THE EVB B D sse ener enne 1 lt TABLE 1 2 CONTENTS OF SOFTWARE CD 1 TABLE 2 1 TERMINAL PROPERTIES SETTING c cccccccsccsscssessesssscsscesesecsscsecssssessesseeeseesscnscsesseeseeeeeees 5 lt TABLE 2 2 EVB B D DEFAULT NETWORK INFORMATION 7 lt TABLE 2 3 MENU OF NETWORK CONFIG gt Adsense 8 lt TABLE 2 4 EVB B D DEFAULT CHANNEL INFORMATION 9 TABLE 2 5 MENU OF CHANNEL CONFIG gt 0 ctescceccessscsssccscssstessscessesscsesseeesseeseseseeeseesseeesnaddubessesens 10 lt TABLE 2 6 W5100 CHANNEL APPLICATION TYPE nnne nnne nnne 10 lt TABLE 2 7 APPLIQ NISWNSETAULT VALUE 88 ouf EE 11 TABLE 3 1 DEVICE MAP DEFINITION gt cccccscsssesscsccescescessutenssessescensceccsscsscessessestensensenacescesseseeseens 20 TABLE 3 2 AVR INTERNAL EEPROM MAP DEFINITION gt s ssssssessssssesssreresrererisrsreresrererisreresrsrsresrsreresrs 21 TABLE 3299
66. est Full Response Full Request Request Line JeNnuENy S J9Sf HAV LO300LGSM General Header Request Header Entity Header CRLF Entity Body Full Response Status Line General Header Response Header Entity Header CRLF CRLF Entity Body Request Line Method SP Request URI SP HTTP Version CRLF Status Line HTTP Version SP Status Code SP Reason Phrase CRLF Entity Header Allow Content Encoding Content Length Content Type Expires Last Modified extension header Entity Body OCTET Method GET HEAD POST extension method For further information on HTTP message refer to RFC2616 HTTP request message varies according to web browser type Table 3 29 shows the examples of HTTP message communication between Internet Explores on Windows 2000 and EVB B D 56 Copyright 2007 WIZnet Co Inc All rights reserved Wiznet lt Table 3 28 HTTP MESSAGE BETWEEN EVB B D AND WEB BROWSER gt HTTP Request Message Ex1 gt GET wiz_log gif HTTP 1 1CRCF Accept image gif image x xbitmap image jpeg image pjpeg application vnd ms powerpoint application vnd ms excel application ms word CRCF Accept Language koCRCF Accept Encoding gzip deflateCRCF User Agent Mozilla 4 0 compatible MSIE 5 01 Windows NT 5 0 NET CLR 1 3705 CRCF Host 192 168 0 2CRCF Connection Keep AliveCRCF CRCF Ex2 gt GET http 192 168 0 2 LCDNLED CGI Icd hi EVB B D amp led0 on HTTP 1 1CRCF Acce
67. evb config c u int uart keyhit u char uart Checking the Input from UART 0 1 mcu serial c char uart0 getchar void mcu serial c void wait 1ms u int cnt mcu delay c void ping request void app ping app c EK IN Network Configuration Network Configuration is a sub program of Manage Program and built with manage network And it s the program that sets up Network Information of EVB B D In general MAC Address of Network Information is hardly updated after the initial setup Accordingly MAC Address setup does not provide Configuration Menu such as Source IP Gateway IP or Subnet Mask but it provides hidden menu Also MAC Address is not changed at the time of Factory Reset MAC Address is updated using M or m Copyright 2007 WIZnet Co Inc All rights reserved nugpy S J9Sf HAV L03001LGM 55 Ww LZnet START DEEN a manage network ebe Source IP 0 1 2 Gateway IP 3 Subnet Mask 4 F E Get the Network Information DNS Server IP get_netconf amp NetConf Factory Reset Ak Display Network Config Menu tos Get the pressed Key sel uartO get char Display Network Information display netconf Verify the Value VerifiylPAddress Get a Value 3 N uartO gets H Update Source IP Address NetConf sip htonl inet addr Verify the Value N Veri
68. f HAV LO300LGSM 49 WIZn et Table 3 23 Reference Functions in loopback tcps void loopback tcps u char ch Loopback TCP Server program app loopback c uint8 getSn SR SOCKET s Get the socket status iinChip w5100 c uint16 size of data transmittable and received iinChip w5100 c getSn RX RSR SOCKET s data u_char socket SOCKET s Create the socket iinChip socket c u char protocol u int port u char flag u char listen SOCKET s It sets related socket as server mode iinChip socket c u int send SOCKET s Transfer the data to the connected socket iinChip socket c const u_char buf u int len mmm u int recv SOCKET s Receive the data to the connected socket iinChip socket c u char buf u int len a on nn void disconnect SOCKET s Close the connection of the socket iinChip socket c If the server socket is in SOCK CLOSED status loopback tcps calls socket with the elements of SOCK STREAM Listen Port Number and Option Flag to create TCP server socket The socket function changes the socket status to SOCK INIT regardless of the previous socket status If the server socket is created successfully its put in TCP Server mode after calling listen with the server socket as the parameter listen makes the server socket status as SOCK LISTEN status and maintains SOCK LISTEN status until any client s connection At this point when any client tries to connect to the server socket the server socket sta
69. fiylPAddress Get a Value gt erifty OK uartO gets 4 Update G W IP Address NetConf gwip htonl inet addr Verify the Value VerifiylPAddress SS erifty OK Get a Value uartO gets Z 4 Zz Update S N Mask NetConf sn htonl inet addr Verify the Value VerifiylPAddress erifty OK Get a Value N uartO gets 4 Update DNS IP Address NetConf dns htonl inet_addr Verify the Value Get a Value ValidATOI uartO gets i Update MAC Address Factory Reset load factory netconf Update Network Information END set netconf amp NetConf lt Fig 3 6 manage network gt Copyright 2007 WIZnet Co Inc All rights reserved IEIUEW S 49Sf HAV LO300LSM WIZnet Table 3 17 Reference Functions in manage config gt void get netconf NETCONF Get the Network Information that is evb config c void set netconf NETCONF Update the Network Information evb config c void display netconf Outputs the Network Information to evb config c Void load factory netconf void Load Factory Reset Network evb config c Information char uart0 getchar void Read one character from UARTO int uart gets u char uart char str Read tex
70. h get http uri name Query String of Request URI can include one or more variable value pair that has amp as a separator Through function get_http_param_value it can extract the wanted variable value in Query String get http ud namel get http param valuel Declare amp Initialize Local variables Declare amp Initialize Local variables chartempUAl MaAx_LUAl_SI2E char uri name H opy uri to tempURI Get the URL name Token uri name strtokitempUA Find in un_name char tempURI M aA _UAl_SI2E char name NULL Extract the value of pama name name stden param_namel 1 name strok name amp inti 3 Decoding the escape characters unescape hip uiiname Replace with SP RETURN replacetochar name SP fi lt Fig 3 22 get_http_uri_name amp get http parse value gt un namae RETURN CGI processing of Web Server Program at EVB B D is different from general Web Server Program which is Copyright 2007 WIZnet Co Inc All rights reserved JeNnuEN S A9SN HAV LO300LGSM 62 WIZnet based on OS Web Server Program which is based on OS creates separate process to take case of communication between processes independently However Web Server of EVB B D is OS less so instead of making independent process it calls relevant functions to deal directly with CGI processing EVB B D supports NETCONF CGI which updates Network Information and LCDNLED CGI
71. he variable length processes and QTYPE and QCLASS Field are skipped dns answer analyzes and processes Answer Section Answer Section is a section where transformation actually takes effects and it performs appropriate process to TYPE Field of Answer Section TYPE of Answer Section has one of values from lt Table 3 41 Constants Definition at QTYPE amp QCLASS Field gt and the value comes from either TYPE Aor TYPE PTR In case that the Domain Name is changed to IP Address it can get the changed IP Address from TYPE A and if the IP Address is changed to Domain Name Domain Name can be obtained from TYPE PTR Changed Domain Name or IP Address are also processed and extracted by parse_name parse name Declare amp Initialize Local variables N g E cem qname MULL lt Hame rmaxlen Tr gr Enough RETURN 0 M ernory M qname cot qnamert nsegt Fig 3 44 parse name gt Copyright 2007 WIZnet Co Inc All rights reserved JenuEy S J9Sf HAV LO300LGSM 88 WIZnet parse name processes QNAME Field of Question Section or NAME RDDATA Field of RRs Section QNAME NAME RDDATA Field are mostly composed as in lt Fig 3 41 Example of QNAME Field transformation of Question Section gt However it can be compressed to reduce DNS Message Size Compression scheme is expressed in 2 Byte If the first byte the upper 2 bits are 11 it means the Label is compressed It has the
72. heck to expire the leased time from inet dhcp c Fal eee Copyright 2007 WIZnet Co Inc All rights reserved JeNnuEN S J9Sf HAV LO3I00LGM 31 IZnet START main Initialize EVB B D evb_init Y Check to enter the manage mode check manage j sock_flag 0x00 Unregister i th Channel Apps Handle unregister channel handle Get MAC Addr from EEPROM get netconf amp NetConf Y Set theMAC Addr to DHCP Cleint memcpy SRC MAC ADDR NetConf mac 6 ChConf i type NOTUSE Register i th Channel Apps Handle register_channel_handle check_DHCP_state hConf i type LB TCP onf i type EB SERVER Y Register i th Channel Apps Hand register channel handle loopback tcps le Register i th Channel Apps Handle register_channel_handle loopback_tcpc Register i th Channel Apps Hand register_channel_handle loopback_udp e Register i th Channel Apps Handle register channel handle web server Network Configruation net init i lt lt Call i th Channel Apps Handle lt Fig 3 3 EVB B D s main gt Copyrigh
73. ht 27 gt lt input name sn type text size 20 value SUB_NET__ MASK gt lt td gt lt tr gt lt tr gt lt td width 110 height 22 gt lt font color FEFEEF gt lt font gt DNS Server IP lt td gt lt td height 27 gt lt input name dns type text size 20 value DNS SERVER IP gt lt td gt lt tr gt lt tr gt lt td width 110 height 22 gt lt font color FEFEEF gt lt font gt MAC Address lt td gt lt td height 27 gt SRC MAC ADDRESS lt td gt lt tr gt lt Table 3 30 gt is a part of evbctrl html in ROM File Image of EVB B D The length of the system environment variables is defined to fit the length of system environment value to be replaced For example if Source IP Address of EVB is expressed in string the maximum is 16 Hence the length of SRC IP ADDRESS is 16 as well ROM File System of EVB B D can be created with Copyright 2007 WIZnet Co Inc All rights reserved JenuEy S J9Sf HAV LO300LGSM 60 WIZnet ROMFileMaker exe provided by WIZnet Refer to ROM File Maker Manual Vx x pdf for further information HTTP Request message can be divided into Method and Request URI by parse http request and stored in st http request Date Type which is defined in Table 3 31 It gets the requested URI Type with get_http_uri_type lt Table 3 30 st_http_request Data gt JeNnuEy S J9Sf HAV LO300LGSM define MAX URI SIZE 2048 sizeof char 2
74. ht 2007 WIZnet Co Inc All rights reserved IEIUEW J95N HAV LO300LSM 12 Ww LZnet lt Fig 2 13 gt shows the real example of sending the Ping Request to the destination and receiving the Ping Reply Mini Term EE El xl File F Configure C Transfer T Help H g n count Number of echo requests to send l Size Send buffer size ce sk ta LX w timeout Timeout in milliseconds to wait for each reply PING gt ping wuw yahoo co kr DNS SERVER 164 124 101 2 Ping Request to 202 435 214 151 uuw yahoo co EE Pinging 202 435 214 151 with 32 bytes of data Reply from 202 435 214 151 bytes 32 timec zms Reply from 202 43 214 151 bytes 52 time lt 2m5 Reply from 202 43 214 151 bytes 52 time lt 2m5 Reply from 202 43 214 151 bytes 52 time lt 2m5 Ping Statistics Packets Sent 4 Received 4 Lost 0 Ping Reply Packets 4 Connected 5 7600 8 None 1 None Capture OFF lt Fig 2 13 Ping Application Test gt To terminate the Ping Application type type exit at the PING gt prompt 2 4 2 EVB B D Test Applications 2 4 2 1 DHCP Client DHCP Client Application is an application that dynamically assigns network information for EVB B D from DHCP Server To test DHCP Client first of all W5100 1 channel application type must be set up as DHCP Client using Manager gt gt Channel Config gt gt 0th Channel Menu Refer to Chapter
75. ht 2007 WIZnet Co Inc All rights reserved JeNnuEN S A9SN HAV LO300LGSM 70 WIZnet DHCP Timeout is 1 getlP DHCPSY returns failure after releasing the DHCP Timer When it failed to obtain network information from DHCP server EVB B D sets network configuration using default network information or previously obtained network information lt Table 3 35 gt is a definition of State Timeout and Retry Count of DHCP Client lt Table 3 34 DHCP Client State amp Timeout Definition gt define STATE DHCP REQUEST 2 define STATE DHCP LEASED 3 define STATE DHCP REREQUEST 4 After obtaining Network Information REQUEST Retransmission define STATE DHCP RELEASE 5 RELEASE Transmission define MAX DHCP RETRY 3 Number of Same DHCP Message Transmission 3 times define DHCP WAIT TIME Waiting time for receiving DHCP Message 5 sec At getlP DHCP DHCP XID is variable to set up xid Field of DHCP message in Fig 3 26 DHCP Message Format gt it must be unique and maintain the same value until Lease Time of network information is expired DHCP XID is fixed with 0x12345678 on here but it s recommended to use the random value Be advised to set source IP address as 0 0 0 0 when initializing W5100 for communication with DHCP server You can use any IP address to set Source IP address of W5100 but using 0 0 0 0 is better because 0 0 0 0 corresponds to Class A in IPv4 addressing and it s a Null IP address th
76. inChip socket c u char buf u int len u char destination addr u int port void close SOCKET s Closes the related Socket iinChip socket c Copyright 2007 WIZnet Co Inc All rights reserved nuEpy S J9Sf HAV LO300LGSM 91 WIZnet W5100E01 AVR User s Manual W5100E01 AVR DIN 96Pin Expanded Board Interface 3 3V Power On System Reset 4 Hardware Designer s Guide 4 1 Block Diagram Seral Interface Low Active RESET _ TF Address Busf1 Zh Phi Al Pata Bust T Processor Module P ort Interface Power Regulator Address Bust nin LED E ge Fig 4 1 EVB B D Block Diagram 92 Copyright 2007 WIZnet Co Inc All rights reserved WIZnet 4 2 Block Description EVB B D is composed of W5100E01 AVR EVB Base Board and PM A1 AVR MODULE Following 9 blocks are components of EVB B D PM A1 LCD PAL SRAM RS232 Port Expanded Board Interface Power Regulator 3 3V Power On System Reset 4 2 1 PM A1 PM A1 AVR MODULE is composed of Atmega128 Processor 74HC573 for address latch 8MHz external crystal and header for interfacing to Base board JP4 JP5 and ISP JP3 amp JTAG JP1 Interface 5000mm Cc WHO OF e m o E tn Fig 4 2 PM A1 MODULE Dimension For easy development using EVB Board all the port pin except for ALE PG2 are connected to MB EVB X2 through module Interface JP4
77. ip Select as shown in the address map of EVB B D nuEpy S J9Sf HAV LO300LGSM EVB B D provides VHDL Code For developer who uses PAL element CUPL is recommended since it is a freeware PAL Compiler WINCUPL of ATMEL co can be used after simple registration Use it with AWINCUPL EXE that is downloadable from ATMEL Homepage Refer to AVR Tool Guide pdf for usage 4 4 1 IO Define The following is VHDL Source code entity evb pal is port Addr in std_logic_vector 15 downto 10 nRD in std_logic NWR in std_logic NRAMCS out std logic NCS IINCHIP out std_logic LCDCS out std logic The following is CUPL Source code 102 Copyright 2007 WIZnet Co Inc All rights reserved WIZnet pr eee INPUT PINS rn 1 6 2 A10 15 address upper 6bits PIN DD read signal PIN 8 nWR write signal p eee OUTPUT PINS rn PIN 12 nCS RAM External SRAM CS PIN 13 LOD E LCD CS PIN 14 2 nCS IINCHIP iinChip CS JENnUueW S A9SN HAV LO300LGSM 4 4 2 External SRAM Area External SRAM area is ranged from 0x0000 to Ox7fff The following is a VHDL Source Code that makes SRAM CS NRAMCS 0x0000 Ox7fff process Addr begin if Addr lt 100000 then nRAMCS lt 0 else nRAMCS lt 1 end if end process The following is a CUPL Source Code that makes SRAM CS 0x8000 InCS RAM A15 4 4 3 LCD Area LCD is ranged 0x9000 0x9400 WR an
78. known Page M He found the Tila send ERROR HTML PAGE i 7 Make the HesanseHead forthe request TYPE make hitp response headihitp response reqeua TYPE len send the HTTP Response Header sendihitp response M RETURN file en gt U Y Hig ten gt TX Hx MAX DU TT N send file file len Y send file TX Rx MAX BLF SIZE 1 Pen Jen c replace oye ene sd Res TYPE PTVPE HIM M send a HTTP Response Body sendihtitp response content send len file len send len Fig 3 19 proc http gt z Processing Copyright 2007 WIZnet Co Inc All rights reserved IEIUEN S J9Sf HAV LO300LGSM WIZnet proc http calls parse http request to analyse the HTTP request message received from web browser If the METHOD of analyzed HTTP request message is GET HEAD or POST get http uri name is called and URI Name is extracted from HTTP Request message If extracted URI Name is replace URI Name to index html which is web server default page of EVB B D because this means that web browser is requesting default page of web server After getting the HTTP request type of HTTP request message by calling find http uri type if HTTP request type is CGI it performs the related CGI command process After processing CGI commands or in case that HTTP request type is not the CGI search file with URI Name from ROM File Image which is built in EVB B D If the file is found crea
79. lated Label analyzes the Label at the offset of DNS Message where the Label is located If it s no 11 then the Label is analyzed and processed like as lt Fig 3 41 Example of QNAME Field transformation of Question Section gt Copyright 2007 WIZnet Co Inc All rights reserved nuEpy S J9Sf HAV LO300LGSM 90 WIZnet lt Table 3 42 Reference Functions in DNS Client gt int gethostbyaddr Changes IP Address to Domain Name inet dns c oe II u long gethostbyname Changes Domain Name to IP Address inet dns c ee mI u char dns query DNS Message Processing inet dns c SOCKET s u long dnsip u char domain name u long domain ip QUERYDATA querydata u int elapse int dns make query Creates DNS Request Message inet dns c u char op char qname u char re Analyzes Question Section of DNS inet dns c u_char dns answer Answer Section of DNS Response inet dns c u_char cp Message m int parse name char cp char ab M NAME Field of Question inet dns c uint16 getSn RX RSR SOCKET size of data transmittable and iinChip w5100 c Lm ai m in u char socket SOCKET s u char Creates sockets as TCP UDP IP iinChip socket c protocol u int port u_char flag gemeis u_int sendto SOCKET s Transmits data through specific port of iinChip socket c const u_char buf u_int len specific Destination u_char addr u_int port u int recvfrom SOCKET s Receives data through any port of any i
80. le of setting the MAG address of EVB B D in Network Config NETWORK CONFIG Display contig Source IP Gateway IP Subnet Mask DNS Server IP HAC address memory Allocation Factory reset MAC Address O0O 06 dc 00 00 20 lt Fig 2 9 MAC address Setup Example gt 2 4 1 2 Channel Config It sets up an application that can be operated in 4 channels of W5100 By selecting 2 Channel Config each channel can be set up The default W5100 channel information is shown in lt Table 2 4 gt lt Table 2 4 EVB B D Default Channel Information gt W5100 Channel Test Application 1 Loopback TCP Server Port 5000 Loopback TCP Server Port 5000 Loopback TCP Server Port 5000 4 Loopback TCP Server Port 5000 If Channel Config menu is selected in manage program Fig 2 10 is displayed and the functionality of each menu is described in Table 2 55 Copyright 2007 WIZnet Co Inc All rights reserved IEIUEN S J9Sf HAV LO300LGSM WIZnet Display Contig 13t Channel 2nd Channel 3rd Channel 4th Channel Factory Reset lt Fig 2 10 Menu of Channel Config gt lt Table 2 5 Menu of Channel Config gt Meu Desorption O D Display Config Displays current set up Test Application type of each W5100 channel 0 1 Channel Sets up test application type at W5100 No 0 channel Warning As developing EVB B D DHCP Client application setup is possible only at
81. mpiler version upgrade 2 2 1 2 ICE Programs EVB B D supports JTAG amp ISP ICE for development and debugging For ISP Program AVRStudio program is used Please refer to AVR Tool Guide Vx x pdf for installation and usage of AVR Studio and ISP GENDER User s Guide Vx x pdf for usage of ISP GENDER 2213 ROM File Maker Program ROM File Maker Program is a utility program that provides convenience in using simple ROM File System for EVB B D The reason that ROM File Maker Program is used in EVB B D is to access Web Pages for Web Server Test Application as ROM File System Refer to ROM File Maker Manual Vx x pdf for further instruction on installation and ROM File Maker Program 2 PEE EVB B D Test PC Program Install 22 Loopback Test Program AX1 Install Loopback Test Program referred to as AX1 from here on is a program to evaluate the performance of W5100 and does the Loopback the file and packet data in connection with EVB B D channel applications such as Loopback TCP Server Client and Loopback UDP Please refer to AX1 Manual Vx x pdf for installation and usage Copyright 2007 WIZnet Co Inc All rights reserved JeNnuEy S J9Sf HAV LO300LGSM WIZnet 2 3 Quick Start After the confirming the Package of EVB B D test EVB B D in the order shown below D Confirm the testing environment Refer to Chapter 2 1 Connect test PC to EVB B D using UTP cable directly Connect test
82. n Loopback UDP UDP Test Application Web Server Web Server Test Application DHCP Client Dynamic Network Config using DHCP Server Copyright 2007 WIZnet Co Inc All rights reserved JeNnuEN S A9SN HAV LO300LGSM Ww LZnet 2 Getting Started 2 1 System Configuration 2 1 1 EVB B D Layout amp Configuration For testing the functions of the EVB B D and developing applications the EVB B D should be configured as shown below First the EVB B D is connected to the PC using the crossed UTP Cable for data transmission and the Serial Cable for monitoring Second the dip switch and jumper should be set as below EI E L 3 ERS 0N ci l f cs p w TE e L RESET OFF lt Fig 2 1 EVB B D Jumper Setting gt D SPI Enable J3 For interfacing W5100 with MCU through SPI mode the pin of 2 and 3 of JP3 should go short In case that SPI mode is not used the pin of 1 and 2 should be shorted BUS 1 SPI lt Fig 2 2 JP3 Jumper Setting gt Copyright 2007 WIZnet Co Inc All rights reserved jJenuEN S J9Sf HAV LO300LSM WIZnet 2 2 PC Programs Install 2 2 1 Development Program Install Please refer to AVR Tool Guide Vx x pdf for more information 2211 Compile Tool Chain For installation and usage of WinAVR refer to the related manual Firmware of EVB B D is currently using AVR GCC Version 3 4 6 Compiler and can be changed with co
83. n Flag to create TCP client socket In creating socket here any port number is used for get_system_any_port This is because connection may be failed if it tries to connect to the same server with same port number After successfully creating the socket call connect with the elements of the client socket to connect to the AX1 server connect makes the socket status into SOCK_SYNSENT and keeps the status as SOCK_SYNSENT until it receives the authorization for connection from the server If the connection is successful the socket status is changed from SOCK SYNSENT to SOCK ESTABLISHED In SOCK ESTABLISHED status the operation is same as explained in loopback tcps Copyright 2007 WIZnet Co Inc All rights reserved JenuEy S J9Sf HAV LO300LGSM 51 WIZnet loopback ies Y Declare amp Initialize Local Variables u_char data buf TX BUF Y Select Socket Status getSn SR OCK ESTABLISHED Select Recieved Size eng gt len getSn_RX_RSR Receive the Data recv ch data_buf len Close Socket close ch Send the Received Data send ch data_buf len SOCK CLOSED Create a TCP Socket socket ch SOCK_STREAM any port flag Y Wait a connetion with a client NBconnect ch destip destport Table 3 24 Reference Functions in loo
84. net Co Inc All rights reserved JenuEy S A9SN HAV LO300LGSM 33 WIZnet If the EVB B D is updated the EVB B D automatically reboots to apply the updated configuration 1 Network Contig Channel Contig 3 Ping App Test F E Factory Reset START Exit manage config Gu Gum mm oe ee ee ee ce Sec Sech Sech immu Sech Sech Set Sen Sec Sech Go Select Display the Config Menu E Get the pressed Key sel uartd getchar Y Configure Network brmodity manage network Sg Configure Channel bmadity manage channel m Test Ping App ping request dE c the Factory Reset Value load_factory netconfO load factory cheonfQ bmadify 1 h d EVB B D Auto Reset evh soft reset M Fig 3 5 manage config gt Copyright 2007 WIZnet Co Inc All rights reserved IEIUEN S J9Sf HAV LO300LGSM 34 WIZnet lt Table 3 16 Caller Function at Manage Program gt void check manage void Decision of Manage Program is executed or not void manage config void Manage Program evb manage c u char manage network void Configure Network Information evb manage c u char manage channel void Configure Channel Information evb manage c u char get reset flag void EVB B D s Auto Manual Reset recognition evb config h and confirm evb config c Auto SYSTEM AUTO RESET Manual SYSTEM MANUAL RESET void set reset flag u char flag void load factory netconf void void load factory chconf void
85. ng and Ping message is defined and used as the data type of lt Table 3 21 gt Refer to inet ping h Copyright 2007 WIZnet Co Inc All rights reserved JenuEy S J9Sf HAV LO300LGSM 42 WIZnet lt Table 3 20 PINGMSG Data Type Definition gt typedef struct PINGMSG char Type 0 Ping Reply 8 Ping Request char Code Always 0 u_short CheckSum Check sum u_short ID Identification u_short SeqNum Sequence Number char Data PINGBUF_LEN Ping Data IPINGMSG Data field size of PINGMSG is of PINGBUF LEN Byte PINGBUF LEN is defined as 32 However data field max size may be 1472 This is because the sending MTU of W5100 is 1480 bytes and the sum of Code CheckSum ID and SeqNum Field Size is 8 Bytes If we subtract 8 from 1480 we get 1472 Hence the size is 1472 bytes The results from ping are saved in Data Type defined in lt Table 3 22 gt lt Table 3 21 PINGLOG Data Type Definition gt typedef struct PINGLOG u_short CheckSumErr u_short UnreachableMSG u short TimeExceedMSG u short UnknownMSG u short ARPErr u short PingRequest u short PingReply u short Loss PINGLOG The saved Ping log can be output with RS232 terminal through DisplayPingStatistics function lt Fig 3 12 gt shows the process procedures of DisplayPingStatistics CheckSumeErr field is incremented by 1 whenever the checksum of Ping Reply from peer is not correctly receiv
86. ng Reply or 8 Ping Request at Type Field The Code Field of ICMP Message has 0 Type Dependant Data Field 4Bytes of ICMP Message can be re defined as ID Field 2Bytes Sequence Number Field 2Bytes respectively Data Field of ICMP Message is filled with the Ping data to be looped back Finally it calculates the checksum of ICMP header and Ping data of which the checksum fields are 0 After the calculation it replaces 0 checksum fields with the newly calculated values lt Fig 3 10 gt is a diagramming representation of the relationship between the ICMP message format and the Ping message 0 fo 15 e ID 2 Bytes B 15 Type Code 1 Byte Byte Checksum 2Bytes Type Dependent Data d Bytes sequence Number 2 Bytes ICMP Message Ping Message lt Fig 3 10 ICMP Message VS Ping Message gt Checking the Ping reply to the Ping request can be processed by checking if the values of ID sequence number and ping data field are same or not In case the Ping reply does not come back in wait time the ping can be sent again In such case the Ping request is sent with the sequence number incremented by 1 Transmitting Ping request message and checking the Ping reply message were done by ping The elements of ping are of destination IP address Ping reply wait time number of Ping requests Ping data size and received Ping Replies are analyzed and processed to fit the elements lt Fig 3 11 gt is the process of pi
87. no 0 channel 1 2 Channel Sets up test application type at W5100 no 1 channel 2 3 Channel Sets up test application type at W5100 no 2 channel 3 4 Channel Sets up test application type at W5100 no 3 channel F Factory Reset Initialize into original setup status Refer to Table 2 4 gt Exits Channel Config Available test application of each W5100 channel is shown as Table 2 6 Table 2 6 W5100 Channel Application Type DHCP Client Receiving Network Information of EVB B D from DHCP Server dynamically Warning If DHCP Server does not exist in LAN it sets back to default value after certain amount of time TCP Loopback Server TCP Server Test Program uM o CN TCP Loopback Client TCP Client Test Program Commun Warning EVB B D TCP Client AX1 TCP Server Loopback UDP UDP Test Program Copyright 2007 WIZnet Co Inc All rights reserved IEIUEN S J9Sf HAV LO300LGSM 10 WIZnet Other application types except for DHCP Client can be repeatedly set up regardless of channel Fig 2 11 shows an example of 2 channel setting of W5100 as TCP Loopback Client When inputting simply ENTER without IP address or port number the default value is applied Table 2 7 shows default values required for each application select 2 select the followed AFPs type for 1 channel No Use Loop Back TCP Server Loop Back TCP Client Loop Back UDF Web Server D
88. nt u int nscount Authority name server count u int arcount Additional record count DHDR Question Section typedef struct QUESTION char qname Variable length data u_int qtype u int qclass DQST Resource Records typedef struct RESOURCE RECORD d char name Variable length data u int type u int class u long ttl u int _rdlen char rdata Nariable length data DNS Resolver works based on gethostbyaddr and gethostbyname gethostbyaddr transforms Internet IP Address to Internet Domain Name and gethostbyname transforms Internet Domain Name to Internet IP Address gethostbyaddr and gethostbyname test the setup of DNS Name Server IP Address and search free channels of W5100 needed for connection with DNS Name Server If a free channel of W5100 exists gethostbyaddr and gethostbyname call dns query with BYNAME or BYIP as the elements For examples of gethostbyaddr and gethostbyname refer to Chapter 3 2 5 3 Ping Request Program Actual connection with DNS Name Server is performed through dns query and gethostbyaddr and gethostbyname are reporting only the result of dns query Table 3 38 Query Type Definition at dns query gt typedef enum _QUERYDATA BYNAME BYIP QUERYDATA Query type Copyright 2007 WIZnet Co Inc All rights reserved JeNnuENy S J9Sf HAV LO300LGSM WIZnet C gethostbyname C gethostbyadar
89. nter working and DNS Request Message is created by calling dns make query If DNS Request Message is created successfully DNS Request Message is sent to DNS Name Server through UDP Socket After sending DNS Request Message it receives DNS Response Message or waits until the waiting time is expired If DNS response message is received from DNS name server during the waiting time it analyzes received DNS response message using dns_parse_response dns_query returns IP Address or Domain Name depending on Query Type lt Fig 3 39 gt is dns query s process map Copyright 2007 WIZnet Co Inc All rights reserved JeNnuEN S J9Sf HAV LO3I00LGM 80 I Znet Declare amp Initialize Local variables u_char response _received 0 Char qname dns_but u_char TA BUF get domain name dns_but MAX DNESMSG SIZE query data query data qname MAX DNSMSG SIZE strepyigname inet ntoa fdomain ip ME in i arpa Create a UDP Socket for ONS socket S0Ck DGRAM hake a Quer with qname len dns makequery OPQUERY qname RETURN 0 E eb Send the query to the ONS Server senito dns bif dnsipIPPORT DOMAIN M k Wait 10ms i wait 10msi 1 I Placis SEL REE Y Clase the socket Receive a answer fromthe ONS Serve closes recvtromidns but reponse received 1 reponse received Y Analyze the answer dns parse repornse Y TUNE CS e HUDP data BY MAME domain_ip get domain ip M Copy get domain name t
90. o domain name strepyidamain name get domain name RETURN 1 lt Fig 3 39 dns query gt Copyright 2007 WIZnet Co Inc All rights reserved JeNnuEN S A9SN HAV LO300LGSM LZnet dns makequert Declare amp Initialize Local Variables char query dns buf u char domain tok u int domain len u int qtype u int qclass gien data BY NAME gtype TYPE A N gtype TYPE PTR Header section qclass CLASS IN OU int quer dns id query 2 yuen MAKE FLAG OG gquery MAKE FLAGIO sm infiquer 1 Juestion Section query dns_buf DHOR SIZE Find the location of In qname domain tok strchriqname domain len strlentqname domain len domain tak qname domain len 63 DH RETURNO N gquen domain Jen memepyiquery qname doman len qname domain Jon gquern domain len Y queri 10 01 nt queryy qtvpe query 7 OU int quer qclass query 2 RETURN Quere Size Fig 3 40 dns makequery gt Copyright 2007 WIZnet Co Inc All rights reserved IEIUEN S J9Sf HAV LO300LGSM 82 WIZnet dns_makequery creates DNS Request message to be sent to DNS Name Server Since DNS Request Message can query only with Header Question Section RRs Sections is not needed to be created If you examine the header section creation at dns makequery first it sets ID Field values as any value in DNS Message inter working On here ID is set with 0x1
91. offset that is composed of 1 Byte excluding upper 2 bits and 2 Byte This offset is Offset of DNS Message and means the actual value of Label is located by the offset from the Starting point of DNS message When Compress Scheme tries to reuse Domain Name that was already used in DNS Message relevant Domain Name sets the offset that is located in DNS Message as Indirect so that it can reduce the size of DNS Message lt Fig 3 45 gt is an example of Compress Scheme of DNS Message and its application DMS Message Fig 3 45 DNS Message Compression Scheme The example of Compression Scheme of Fig 3 45 shows DNS Message in case of F ISIL ARPA FOO F ISLARPA ARPA and ROOT F ISI ARPA is processed in the format of Fig 3 41 Example of Copyright 2007 WIZnet Co Inc All rights reserved nuEpy S J9Sf HAV LO300LGSM 89 Ww LZnet QNAME Field transformation of Question Section gt with Offset 20 of DNS Message without compression In FOO F ISI ARPA since the rest except for FOO is same as Name which is previously processed FOO is processed with lt Fig 3 41 Example of QNAME Field transformation of Question Section gt Format without compression and the rest of names is processed by Offset 26 ROOT is the highest Domain and it s processed with Label Length Field of 0 parse name before analysis of Name checks if upper 2 bits of Label Length Byte are 11 if it s 11 the re
92. ogram uses loopback_udp and lt Fig 3 16 gt shows processing procedure of loopback_udp deopback udp Declare amp Initialize Local Variables u_char data buf TX BUF u long destip 0 u int destport 0 Select Socket Status getSn SR Select Recieved Size pee Y Receive the Data len getSn RX RSR recvfrom ch data buf len amp destip amp destport e Send the Received Data sendto ch data buf len destip destport Create a TCP Socket socket ch SOCK DGRAM port flag RETURN J Fig 3 16 loopback udp Copyright 2007 WIZnet Co Inc All rights reserved JenuEy S J9Sf HAV LO300LGSM WIZnet Table 3 25 Reference Functions in loopback udp void loopback udp u char ch Loopback udp program Cr m C uint8 getSn SR SOCKET s Gets the socket status inChipw5100 c 00 c uint16 getSn RX RSR SOCKET size of data transmittable and received iinChip w5100 c data u_char socket SOCKET s Creates related socket as TCP UDP IP iinChip socket c u char protocol u int port u_char flag u_int sendto SOCKET s Sends data to specific port of specific iinChip socket c const u_char buf u_int len destination related socket u_char addr u_int port u int recvfrom SOCKET s Sends data to any port of any iinChip socket c u char buf u int len u char
93. onet Pete WE WlZnet News uem er Lwr cad MZ nel andar DEA e TID 14 17 ls m l Dee Hear ti n d een sm ME Cinchip WiZnet Products Technology Support How to buy Nows Partners About us If vou find the best network solution here rs WIZnet Winer provides che um ad anastest Dome co Gr n uoa memorie TOTP chipi amf componere SUPPORT O Q amp A En ou A e OME m Li No SUBJECT NAME DATE HTS AQ 4 D y NN i mm a 20089311 110 A4 How Check Bei Te butia i gen 0 Vityustu sni 105 43 AP for AV rein 0 Lube 200500 US R I 4 arena 0 Dy OOD t 41 Inatt Fern 8 0 Lie 2005403068 14 CONTACT US hed 40 GRE emeng Eed C dune xxn o Marketing amp Sales IMIDTOA irternuet ocotien 0 M r cen 200541308 103 Tect sa RE MIMOA hiet prikke 0 Age xou Technical Support eg 0 Der 200560308 9 Ber riensi D kee soon 6 rekt write 12345 net h subject LA seen W5100E01 AVR User s Manual iii w LZnet COPYRIGHT NOTIGE Copyright 2007 WlIZnet Inc All Rights Reserved Technical Support support 2wiznet co kr Sales amp Distribution sales wiznet co kr General Information info wiznet co kr For more information visit our website at htto Avww wiznet co kr W5100E01 AVR User s Manual w L net Table of Contents EE EEE 1 1 1 Ste Let 1 1 2 FT s rv 2 1 2 1 AF NETTO UU TM 2 1 2 2 FU FN he 2 2 Getting Started mRNA enne ener nnnm enne 3 2 1 System m
94. or eee eee esee enn 100 4 2 8 3 3V Power On System Reset ccc cece eee c ence ence eect ene eeeaeeeneeeneees 100 Schematic e EEN 101 4 3 1 WT OUNEN NNN ul o 101 4 3 2 We MN a a 101 SVR JE EE RR 102 4 4 1 Define ee a ae 9 s ae 102 4 4 2 External SRAM Area H egen TEE nn 103 4 4 3 LCD Area EE a ee se 103 4 4 4 W5100 Areaggf H ERA BE 104 Parts List ee B ER E V 106 4 5 1 iu5100E012 5 ES LISM WA 106 4 5 2 ELA Pari LISSE WM llle Meere 106 PhysiealiSescifigation ee EE 107 4 6 1 Powseuesusumption EE 107 EE W5100E01 AVR User s Manual vi w L net Figures FIG 2 1 EVB BD JUMPER ug e 3 FE 2 JP3 JUMPER Ne 3 lt FIG 2 3 EVB B D TEXT LCD DISPLAY gt cc ccsssccsssecesseesssensssensnsensssensnsensnsenensensnsensnsensnsenensenensenenes 5 lt FIG 2 4 OUTPUT OF TERMINAL PROGRAM ENEE 6 FIG 2 5 EVB B D PING REPLY TEST updated 6 lt FIG 2 6 MANAGE PROGRAM EXECUTION gt cccscescescsscsecscsecseeseeseescsacsacsecsecsecsecseesceassessessecsecseeseeseeass 7 lt FIG 2 7 NETWORK CONF RA secs ccsececnsecsserstscstecsseesrecsscesseesereesscaggstilll s 8 lt FIG 2 8 SOURCE IP ADDRESS SET P EXAMPLES A cccccccccccsscesecesetsesceses 2 PEE hhv 9 lt FIG 2 9 MAG AD RE Tun EXAMPLE gt 8 ennen DR 9 lt FIG 2 10 MENU OF CHANNEL CONFIG ene up 98 ERI 10 lt FIG 2 1
95. p request structure void find http uri type Gets MIME Type of HTTP Request inet httpd c u_char char Message D char get http uri name Gets Request URI Name of HTTP inet httpd c char uri Request Message E char get http param value Gets Relevant Parameter Value in inet httpd c char uri char param name Query String of Request URI ae void unescape http uri char Transforms Escape Character inet httpd c void make http response head Creates header of HTTP Response inet httpd c uint8 getSn_SR SOCKET s Informs the socket status iinChip w5100 c uint16 getSn RX RSR SOCKET size of data transmittable and received iinChip w5100 c S data u char SOCket SOCKET S Creates related socket as TCP UDP IP iinChip socket c u_char protocol u int port u_char flag void listen SOCKET s Puts the related socket in Server Mode iinChip socket c u_int send SOCKET s Sends data using connected socket iinChip socket c u int recv SOCKET s Receives data from the data from the iinChip socket c void replacetochar char str Changes the special characters in text util util c char oldchar char newchar rows into new characters Copyright 2007 WIZnet Co Inc All rights reserved nugpy S J9Sf HAV L03001LGM WIZnet 3 2 6 5 DHCP Client DHCP Client program is a program that assigns the network information from DHCP server in the network Note that DHCP Client program must be started
96. pback tcpc RETURN gt lt Fig 3 15 loopback_tcpc gt void loopback_tcpc u_char ch Loopback TCP Client Program poc C uint8 getSn SR SOCKET s Get the socket status inChipiw5100 c 00 c uint16 getSn RX RSR SOCKET size of data transmittable and received iinChip w5100 c data u char socket SOCKET u char protocol u int u char flag u char connect SOCKET s u char addr u int port u int send SOCKET s constu char buf u int len u int recv SOCKET s u char buf u int len void disconnect SOCKET s S Related socket can be created as port TCP UDP IP Attempts to connect to the specific server with related socket Copyright 2007 WIZnet Co Inc All rights reserved iinChip socket c iinChip socket c Sends the data to related socket that is iinChip socket c ee e em Receives the data to related socket that iinChip socket c men mee Close the related socket iinChip socket c u int get system any port void Get any port number evb config c nugpy S J9Sf HAV L03001LGM 52 WIZnet 3 2 6 3 Loopback UDP Loopback UDP Program is a program that uses unicast datagram communication of UDP protocol It operates same as Loopback TCP Server Client program does UDP communication includes unicast datagram communication and broadcast datagram communication and basically supports 1 to many communication that is used for many destinations with one channel Loopback UDP pr
97. pplication that loops back any file or packet data through TCP channel connected with AX1 Program of Test PC First of all set any channel as Loopback TCP Server application type using Manager gt gt Channel Config menu of EVB B D to test Loopback TCP Server When setting up Loopback TCP Server application type of EVB B D you can set listen port to any value Here it s set as the default value 5000 Refer to Chapter 2 4 1 2 After the setup of EVB B D is complete run AX1 at Test PC then try the connection to the IP Address When the connection between EVB B D and AX1 is successful loop back the data Refer to AX1 Manual Vx x pdf Copyright 2007 WIZnet Co Inc All rights reserved jJenuEN S J9Sf HAV LO300LSM 14 WIZnet Source IP EE 168 042 Gateway IP 192 168 0 1 Subnet Mask K 2ES 255 255 0 DNS Server IP 0 0 0 0 Mac ddr x 0x 8 0xbc 0x 0 0x 00 0x35 HHHRRP AR ETT nn RRR RRR RRR RRR PRR RRR RRR RB O Loop Back TCP Server Started 1 Loop Back TCP Server Started 2 Loop Back TCP Server Started 3 Loop Back TCP Server Started lf Connected by 192 1658 0 30 2313 Peer Connection Information in 0 channel of W5100 lt Fig 2 15 Loopback TCP Server Test gt 2 4 2 3 Loopback TCP Client Loopback TCP Client Application is an application that loops back any file and packet data through TCP channel connected with AX1 Program of Test PC After running the
98. prior to other programs because it manages Network Information setup First review basic facts on DHCP Dynamic Host Configuration Protocol and get further into the usage of DHCP Client program DHCP uses UDP protocol in Transport Layer and communicates with DHCP server using broadcast of UDP The reason why it uses broadcast is because it has no IP address and the IP address of server is unknown When UDP broadcast at W5100 destination IP address needs to be set 255 255 255 255 for broadcast packet transmission lt Fig 3 25 gt is a Message Flow between DHCP Server and Client DHCP DHCP CLIEMT SERVER DO Part b Port lt Fig 3 25 DHCP Message Flow gt First of all DHCP client broadcasts DISCOVERY message to the local Network If DHCP server exists at the network then DHCP server receives Discovery message and provides network Information such as IP G W IP Subnet Mask and DNS sever IP which can be used by DHCP Client and information such as Lease Time to the DHCP Client as OFFER message DHCP Client can detect DHCP server by receiving the OFFER message and then it sends REQUEST message to DHCP server to use the information suggested by DHCP server After receiving REQUEST message from DHCP Client DHCP server finds out if the requested network information is usable If it is it sends ACK message if not NACK message is sent to DHCP Client After receiving ACK message from DHCP server DHCP Client uses the offered network inform
99. pt image gif image x xbitmap image jpeg image pjpeg application vnd ms powerpoint application vnd ms excel application ms word CRCF Accept Language koCRCF Accept Encoding gzip deflateC RCF User Agent Mozilla 4 0 compatible MSIE 5 01 Windows NT 5 0 NET CLR 1 3705 CRCF Host 192 168 0 2CRCF Connection Keep AliveCRCF CRCF HTTP Response Message Ex1 gt HTTP 1 1 200 OK CRCF Content Type text htmICRCF Content Length 1451CRCFCRCF Html Document Ex2 gt HTTP 1 1 200 OKCRCF Content Type gif imageCRCF Content Length 613CRCFCRCF GIF IMAGE Web Server program is composed of web_server to manage HTTP server socket and proc_http to manage HTTP message lt Fig 3 18 gt is processing procedure Copyright 2007 WIZnet Co Inc All rights reserved IEIUEW S J9Sf HAV LO300LSM 57 Ww LZnet lt q web server b Y Declare amp Initialize Local Variables u_char http request RX BUF r Select Socket Status getSn_SR Select Recieved Size F RE Y Receive the Data len getSn RX RSR recv ch http request len N E Close Socket close ch Create a TCP Socket Wait for sending the HTTP socket ch sOCK_STREAM port flag Response completely Wait a connetion with a client Close Socket NBlisten ch close ch a RETURN Da o
100. quest uri ledi xam Mt ert Value Ep M Y Tum the D2 LED an Tum the D2 LED aff led nn 1 led nff 1 Set the file name to be sent for HTTP response stropylname evbctri html Find the uri type of the file find http ei typed END Fig 3 24 LCDNLED CGI Processing FORM of NETCONF CGI is submitted in POST Method FORM submitted using POST Method is not submitted in Query String but submitted in Entity Body of HTTP Request Message Such value of parameter for NETCONF CGI also is used to extract related parameter value using get http param value lt FORM gt of LCDNLED CGI is submitted in GET Method and FORM submitted as GET Method is submitted in Query String of Request URI Parameters submitted by Query String of Request URI can also extract parameter value using get http param value 64 Copyright 2007 WIZnet Co Inc All rights reserved WIZnet lt Table 3 31 Reference Functions in web server gt void web server u char ch Web Server Program app webserver c void proc http SOCKET s Processes HTTP Message using related app webserver c u char buf int length Socket u int replace sys env value Change Pre defined System app webserver c u char base u int len Environment Variables in HTTP Hesponse Message to Real Values void parse http request Analyzes and processes HTTP Request inet httpd c st http request u_char Message and saves it in st htt
101. ram is a program that sends Ping Request to a certain destination It uses ICMP protocol message on IP protocol and made with ping request ping request is created with the form similar to Ping program in DOS command prompt It sends Ping request to a destination after analyzing and processing the options Both domain name and IP address can be used for destination address to the Ping request In case of using domain name domain name is changed into IP address using gethostbyname or DNS With the changed IP address the Ping request is sent When IP address is used with a option domain name can be obtained through gethostbyaddr from DNS Server and the Ping request is sent to the IP address When IP address is used without the a option Ping request is sent to input IP address without the connection with DNS gethostbyname gethostbyaddr is DNS related functions For further information refer to Chapter 3 2 6 6 DNS Client Fig 3 8 and Fig 3 9 are processing procedures of ping request Fig 3 8 describes how tokens of inputs of Command Option and Option Value are created and the related Bit of Argument Flag PingArgsFlags is decided Fig 3 9 calls ping based on relevant option and option after checking the validity of command option and option value with bits of argument flag ping sends Ping request message to a certain destination and processes the ICMP message which is received from any de
102. stination Copyright 2007 WIZnet Co Inc All rights reserved IEIUEN S J9Sf HAV L03001LGM 39 LZnet ping request Declare amp Initialize Local variables PINGLOG PingLog char command 81 char qname MAY GN AME LEN char NextTok char Peer 50 Uu Jong peerip char Ping rgsFlags Dr Usage ping 4 a n count 4 size timeout destination lit Options t Ping the specified host until stopped To see statistics and continue type ControlBreak To stop type Controls int pingcnt pingsize pingimeout 8 Resolve addresses to hostnames noount Number af echo requests to send size Send buffer size Display the Usage of Ping wtimeout Timeout in milliseconds to wait for each reply Call ping usage pingent pingsize pingimeout 0 Ping rgsFlags 0 Display the Prompt Get a command from RE232 Coredle program Get a First token from the command Covert it to uppercase string e Ping Unknown l Get a Next token from the command o M XI Token NUE WV pingent 1 Y i Ping rgsFlags 0x01 Get the value of n option M Ping rgsFlags 0 02 TT M Y Ping rgsFlags 0404 TRE Token TE eve option rs Mgl Ping rgsFlags 0 80 M Y Ed DAS PinsargsFiass T 0 08 vi M li H EE E E i Get the value of h option See Ping rgsFlags 0x80 N sd Bad Y OE Ping rgsFlags 0x80 M Et Be FAund 5 Y n U ma nknosn Option B Ping rgsFlags 0x8
103. t 2007 WIZnet Co Inc All rights reserved IEIUEW S J9Sf HAV LO300LSM 32 WIZnet 3 2 5 Manage Program Manage Program is a program that sets up network and channel information through RS232 terminal and tests application by sending Ping Request to certain Destination Manage program can be started by calling check manage from main function check manage checks if there is any entering command to Manage Program from RS232 terminal if character M or m is input or not And if the command is detected Manage Program will be entered through manage config If the user change the configuration the EVB B D automatically reboots and check manage is skipped START check manage Check to reset EVB B D automatically get reset flag Reset Automatically Li Display the Followed Console Message END Press M to enter the manager mode Clear Reset Flag set reset flag SYSTEM MANUAL RESET Lal Check to Press a Key uart_keyhit Get the pressed Key uartO getchar Wait 10ms wait 1ms 10 j lt 40 j N N Y Display M the Progressing Character T ice gt i END D lt Fig 3 4 check_manage gt Run Manage Program manage_config Key ESC Copyright 2007 WIZ
104. t lines from UA 0 1 mcu serial c char VE int max len char char VerifylPAddress char sro char src Gem long htonl Transforms ordering of Long Type util sockutil c FE ae Wl long WW Transforms IP string into long type util sockutil c Sno NN Ma 3 2 5 2 Channel Configuration Channel Configuration a sub program of Manage Program is made of manage_config and decides which application to be applied for each of 4 channels of W5100 The application types that can be set up are DHCP Client Loopback TCP Server Client Loopback UDP and Web Server Program Each channel can be set up with any one of the applications above However the DHCP Client can only be supported by the first channel and the setting cannot be repeated on other channels TCP Server Program LB TCPS WEB SERVER can be set repeatedly by all channels In such case the same port can be used Here the number of clients is as many as the same port number Other applications can be set repeatedly by channels but the same port number cannot be used Copyright 2007 WIZnet Co Inc All rights reserved JeNnuEN S A9SN HAV LO300LGSM 37 WIZnet lt Table 3 18 Constraint by Application Types gt Repeat Destination IP APPTYPE Port Repeat Setups Setup O supports all the simultaneously LB TCPS connected clients as many as the number of repeated ports ee o x 1 gt o we 0 x gt O supports all the simultaneously WEB SERVER connected
105. te HTTP response message and send it HTTP Response message is composed of HTTP response header transmission and HTTP response body transmission For transmission of HTTP response header it calls make http response head using HTTP request type as the element to create HTTP response header After transmitting the created HTTP response header the HTTP response body is transmitted For example if the HTTP response body is any file in ROM File Image the files are much bigger than the MTU of W5100 Hence it has to be divided into maximum size of W5100 before transmission At this point if system environment variables that are defined in EVB B D in HTTP response body exist it calls replace sys env value and replaces system environment variables to system environment value stored in EVB B D Table 3 29 System Environment Variables Usage at evbctrl html gt lt tr gt lt td width 110 height 22 gt lt font color FEFEEF gt lt font gt Source IP lt td gt lt td width 240 height 27 gt lt input name sip type text size 20 value SRC_IP_ADDRES gt lt td gt lt tr gt lt tr gt lt td width 110 height 22 gt lt font color FEFEEF gt lt font gt Gateway IP lt td gt lt td height 27 gt lt input name gwip type text size 20 value GW_IP_ADDRESS gt lt td gt lt tr gt lt tr gt lt td width 110 height 22 gt lt font color FEFEEF gt lt font gt Subnet Mask lt td gt lt td heig
106. tus is changed from SOCK LISTEN to SOCK ESTABLISHED This is when the connection between Client and Server is complete and data transfer is possible in SOCK ESTABLISHED status Data is transferred using recv and send at the SOCK ESTABLISHED The data transfer here is 1 on 1 transfer between EVB B D The server and AX1 The client In the SOCK ESTABLISHED status if the client requests closing of the connection the server socket status is changed from SOCK ESTABLISHED to SOCK CLOSE WAIT In SOCK CLOSE WAIT status data communication is not available and the server socket must be closed In SOCK CLOSE WAIT status disconnect is called to close socket disconnect changes the socket status to SOCK CLOSED regardless of previous socket status Copyright 2007 WIZnet Co Inc All rights reserved JENUeW S J9Sf HAV LO300LGSM 50 WIZnet 3 2 6 2 Loopback TCP Client At Loopback TCP Client program EVB B D works in client mode and AX1 PC test program works in server mode EVB B D tries to connect to AX1 which is waiting as the server if the connection is successful EVB B D receives data stream through TCP channel and then EVB B D sends back the received data stream to AX1 Loopback TCP client program is created with loopback_tcpc and lt Fig 3 15 gt is processing procedure of loopback_tcpc If the client socket is in SOCK CLOSED status loopback_tcpc calls socket with the elements of SOCK_STREAM any Port Number and Optio
107. uestion Section gt Copyright 2007 WIZnet Co Inc All rights reserved JenuEy S J9Sf HAV LO300LGSM 83 WIZnet QTYPE Field of Question Section is set TYPE PTR when it holds Domain Name as QNAME When it s IP address it s set as TYPE A and QCLASS field is set as CLASS IN since it is included in Internet Table 3 41 is definition of constants that are used in QTYPE amp QCLASS Fields lt Table 3 40 Constants Definition at QTYPE amp QCLASS Field gt define define define define define define define define define define define define define define define define define define define define The ARPA Internet an authoritative name server TYPE A TYPE NS TYPE MD TYPE MF TYPE CNAME TYPE SOA TYPE MB TYPE MG TYPE MR TYPE NULL TYPE WKS TYPE PTR TYPE HINFO TYPE MINFO TYPE MX TYPE TXT QTYPE AXFR QTYPE MAILB QTYPE MAILA QTYPE TYPE ALL a mail destination Obsolete use MX a mail forwarder Obsolete use MX the canonical name for an alias marks the start of a zone of authority a mailbox domain name a mail group member c CO N O oOo A C N a mail rename domain name a null RR a well known service description ILL ll N Oo a domain name pointer host information ay ef RA C mailbox or mail list information OT mail exchange OP text strings request for a transfer of an entire zone request for mailbox rel
Download Pdf Manuals
Related Search
Related Contents
Snapper P216012E Lawn Mower User Manual ライ トユニッ トの取外しかた User manual for the application of hose assemblies for high KitchenAid KSV90L1M User's Manual Entero-resonancia magnética: revisión de la técnica para el estudio 容積式流量計 Copyright © All rights reserved.
Failed to retrieve file