User Tools

Site Tools


products:w5100s:application:udp_function

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
products:w5100s:application:udp_function [2017/03/31 16:31]
lawrence
products:w5100s:application:udp_function [2018/03/30 16:53] (current)
matthew
Line 1: Line 1:
-====== ​W5500 UDP Function ======+====== ​W5100S ​UDP Function ======
  
-By setting some register and memory operation, ​W5500 provides internet connectivity.+By setting some register and memory operation, ​W5100S ​provides internet connectivity.
 This chapter describes how it can be operated. This chapter describes how it can be operated.
  
Line 7: Line 7:
  
 ==== Basic Setting ==== ==== Basic Setting ====
-For the W5500 operation, select and utilize appropriate registers shown below.+For the W5100S ​operation, select and utilize appropriate registers shown below.
   - Mode Register (MR)   - Mode Register (MR)
   - Interrupt Mask Register (IMR)   - Interrupt Mask Register (IMR)
Line 27: Line 27:
   - SIPR(Source IP Address Register)   - SIPR(Source IP Address Register)
  
-==== Set socket ​memory information ==== +==== Set SOCKET ​memory information ==== 
-This stage sets the socket ​tx/rx memory information. The base address and mask address of each socket ​are fixed and saved in this stage.+This stage sets the socket ​TX/RX memory information. The base address and mask address of each SOCKET ​are fixed and saved in this stage.
  
 <​markdown>​ <​markdown>​
  
-<​B>​*In case of, assign ​2KB rx, tx memroy ​per SOCKET*</​B>​+<​B>​*In case of, assign ​2Kbytes TX/RX memory ​per SOCKET*</​B>​
 </​markdown>​ </​markdown>​
 <code c> <code c>
-In case of, assign ​2KB rx, tx memory per SOCKET+In case of, assign ​2Kbytes TX/RX memory per SOCKET
 { {
 Sn_RXMEM_SIZE(ch) = (uint8 *) 2; // Assign 2K rx memory per SOCKET Sn_RXMEM_SIZE(ch) = (uint8 *) 2; // Assign 2K rx memory per SOCKET
Line 41: Line 41:
  
 /* Same method, set gS1_TX_BASE,​ gS1_TX_MASK,​ gS2_TX_BASE,​ gS2_TX_MASK,​ /* Same method, set gS1_TX_BASE,​ gS1_TX_MASK,​ gS2_TX_BASE,​ gS2_TX_MASK,​
-gS3_TX_BASE,​ gS3_TX_MASK,​ gS4_TX_BASE,​ gS4_TX_MASK, gS5_TX_BASE,​ gS5_TX_MASK,​ +gS3_TX_BASE,​ gS3_TX_MASK,​ gS4_TX_BASE,​ gS4_TX_MASK*/​
-gS6_TX_BASE,​ gS6_tx_MASK,​ gS7_TX_BASE,​ gS7_TX_MASK ​*/+
 } }
 </​code>​ </​code>​
  
 ===== Data Communications ===== ===== Data Communications =====
-After the initialization process, ​W5500 can transmit and receive the data with others by ‘open’ the SOCKET of TCP, UDP, IPRAW, and MACRAW mode. The W5500 supports the independently and simultaneously usable ​8 SOCKETS. In this section, the communication method for each mode will be introduced.+After the initialization process, ​W5100S ​can transmit and receive the data with others by ‘open’ the SOCKET of TCP, UDP, IPRAW, and MACRAW mode. The W5100S ​supports the independently and simultaneously usable ​4 SOCKETs. In this section, the communication method for each mode will be introduced.
  
 ==== UDP ==== ==== UDP ====
  
-The UDP is a Connection-less protocol. It communicates without “connection SOCKET.” The TCP protocol guarantees reliable data communication,​ but the UDP protocol uses datagram communication which has no guarantees of data communication. Because the UDP does not use “connection SOCKET,” it can communicate with many other devices with the known host IP address and port number. This is a great advantagecommunication with many others by using just one SOCKET, but also it has many problems such as loss of transmitted data, unwanted data received from others, etc. To avoid these problems and guarantee reliability,​ the host retransmits damaged data or ignores the unwanted data which is received from others. The UDP protocol supports unicast, broadcast, and multicast communication. It follows the below communication flow.+The UDP is a Connection-less protocol. It communicates without “connection SOCKET”The TCP protocol guarantees reliable data communication,​ but the UDP protocol uses datagram communication which has no guarantees of data communication. Because the UDP does not use “connection SOCKET”it can communicate with many other devices with the known host IP address and port number. This is a great advantagecommunication with many others by using just one SOCKET. But also it has many problems such as loss of transmitted data, unwanted data received from others, etc. To avoid these problems and guarantee reliability,​ the host retransmits damaged data or ignores the unwanted data which is received from others. The UDP protocol supports unicast, broadcast, and multicast communication. It follows the below communication flow.
  
 {{:​products:​w5500:​application:​udp_flow.jpg|UDP Operation Flow}} {{:​products:​w5500:​application:​udp_flow.jpg|UDP Operation Flow}}
Line 69: Line 68:
  
 == SOCKET Initialization == == SOCKET Initialization ==
-For the UDP data communication,​ SOCKET initialization is required; it opens the SOCKET. The SOCKET open process is as followed. At first, choose one SOCKET among the SOCKETS of W5500, then set the protocol mode (Sn_MR(P3:​P0)) of the chosen SOCKET and set the source port number Sn_PORT0 for communication. Finally, execute the OPEN command. After the OPEN command, the state of Sn_SR is changed to SOCK_UDP. Then the SOCKET initialization is complete.+For the UDP data communication,​ SOCKET initialization is required; it opens the SOCKET. The SOCKET open process is as followed. At first, choose one SOCKET among the SOCKETS of W5100S, then set the protocol mode (Sn_MR(P3:​P0)) of the chosen SOCKET and set the source port number Sn_PORT0 for communication. Finally, execute the OPEN command. After the OPEN command, the state of Sn_SR is changed to SOCK_UDP. Then the SOCKET initialization is complete.
  
 <code c> <code c>
Line 84: Line 83:
 == Check received data == == Check received data ==
 Check the reception of UDP data from destination. User can also check for received data via TCP communication. It is strongly recommended to use the second method because of the same reasoning from TCP. Please refer to the “TCP SERVER” section. Check the reception of UDP data from destination. User can also check for received data via TCP communication. It is strongly recommended to use the second method because of the same reasoning from TCP. Please refer to the “TCP SERVER” section.
-[[http://​wizwiki.net/​wiki/​doku.php?​id=products:​w5500:​application:​tcp_function|TCP SERVER]]+[[http://​wizwiki.net/​wiki/​doku.php?​id=products:​W5100S:​application:​tcp_function|TCP SERVER]]
  
 <code c> <code c>
Line 105: Line 104:
 {{:​products:​w5500:​application:​received_udp_data.jpg|The Received UDP data format}} {{:​products:​w5500:​application:​received_udp_data.jpg|The Received UDP data format}}
  
-The received UDP data consists of 8bytes PACKET-INFO,​ and DATA packet. The PACKETINFO ​contains transmitter’s information (IP address, Port number) and the length of DATA packet. The UDP can receive UDP data from many others. User can classify the transmitter by transmitter’s information of PACKET-INFO. It also receives broadcast SOCKET by using “255.255.255.255” IP address. So the host should ignore unwanted reception by analysis of transmitter’s information. If the DATA size of Socket ​n is larger than Internal RX memory free size, user cannot receive that DATA and also cannot receive fragmented DATA.+The received UDP data consists of 8bytes PACKET-INFO,​ and DATA packet. The PACKET-INFO ​contains transmitter’s information (IP address, Port number) and the length of DATA packet. The UDP can receive UDP data from many others. User can classify the transmitter by transmitter’s information of PACKET-INFO. It also receives broadcast SOCKET by using “255.255.255.255” IP address. So the host should ignore unwanted reception by analysis of transmitter’s information. If the DATA size of SOCKET ​n is larger than Internal RX memory free size, user cannot receive that DATA and also cannot receive fragmented DATA.
  
 <code c> <code c>
Line 111: Line 110:
 /* Get offset address */ /* Get offset address */
 src_ptr = Sn_RX_RD; src_ptr = Sn_RX_RD;
-/* select RX memory, refer to Datasheet 14 page */+/* select RX memory, refer to RMSR(Rx Memory Size Register) ​*/
 cntl_byte = Socket_n_RX_Buffer ​ cntl_byte = Socket_n_RX_Buffer ​
 /* read head information (8 bytes) */ /* read head information (8 bytes) */
Line 118: Line 117:
 for(i=0; i<​header_size;​ i++) for(i=0; i<​header_size;​ i++)
 { {
-  header[i] = W5500_READ(src_ptr, header);+  header[i] = W5100S_READ(src_ptr, header);
 } }
 /* update src_ptr */ /* update src_ptr */
Line 131: Line 130:
 for(i=0; i<​get_size;​ i++) for(i=0; i<​get_size;​ i++)
 { {
-  *(dst_ptr+i) = W5500_READ(addr, cntl_byte, src_ptr+1);+  *(dst_ptr+i) = W5100S_READ(addr, cntl_byte, src_ptr+1);
 } }
 /* increase Sn_RX_RD as length of len+ header_size */ /* increase Sn_RX_RD as length of len+ header_size */
Line 157: Line 156:
 /* Get offset address */ /* Get offset address */
 dst_ptr = Sn_TX_WR; dst_ptr = Sn_TX_WR;
-/* select TX memory, refer to Datasheet 14 page */+/* select TX memory, refer to TMSR(Tx Memory Size Register) ​*/
 cntl_byte = Socket_n_TX_Buffer ​ cntl_byte = Socket_n_TX_Buffer ​
 /* copy len bytes of source_address to dst_ptr */ /* copy len bytes of source_address to dst_ptr */
 for(i=0; i<len; i++) for(i=0; i<len; i++)
 { {
-  ​W5500_WRITE(addr, cntl_byte, dst_ptr+i);+  ​W5100S_WRITE(addr, cntl_byte, dst_ptr+i);
 } }
 /* increase Sn_TX_WR0 as length of len */ /* increase Sn_TX_WR0 as length of len */
Line 196: Line 195:
  
 === Check Finished / SOCKET close === === Check Finished / SOCKET close ===
-If user doesn’t need the communication any more, close the Socket ​n.+If user doesn’t need the communication any more, close the SOCKET ​n.
  
 <code c> <code c>
Line 212: Line 211:
 The ‘Group hardware address’ is selected at the assigned range (From “01:​00:​5e:​00:​00:​00”to “01:​00:​5e:​7f:​ff:​ff”) and the ‘Group IP address’ is selected in D-class IP address (From “224.0.0.0” to “239.255.255.255”,​ please refer to the website; The ‘Group hardware address’ is selected at the assigned range (From “01:​00:​5e:​00:​00:​00”to “01:​00:​5e:​7f:​ff:​ff”) and the ‘Group IP address’ is selected in D-class IP address (From “224.0.0.0” to “239.255.255.255”,​ please refer to the website;
 http://​www.iana.org/​assignments/​multicast-addresses).\\ http://​www.iana.org/​assignments/​multicast-addresses).\\
-When selecting, the upper 23bit of 6bytes ‘Group hardware address’ and the 4bytes ‘Group IP address’ must be the same. For example, if the user selects the ‘Group IP address’ to “244.1.1.11,​” the ‘Group hardware address’ is selected to “01:​00:​5e:​01:​01:​0b.” Please refer to the “RFC1112” (http://​www.ietf.org/​rfc.html).\\ +When selecting, the upper 23bits ​of 6bytes ‘Group hardware address’ and the 4bytes ‘Group IP address’ must be the same. For example, if the user selects the ‘Group IP address’ to “244.1.1.11,​” the ‘Group hardware address’ is selected to “01:​00:​5e:​01:​01:​0b.” Please refer to the “RFC1112” (http://​www.ietf.org/​rfc.html).\\ 
-In the W5500, IGMP processing to register the multicast-group is internally (automatically) processed. When the user opens the Socket ​n with multicast mode, the “Join” message is internally transmitted. If the user closes it, the “Leave” message is internally transmitted. After the SOCKET opens, the “Report” message is periodically and internally transmitted when the user communicates.\\ +In the W5100S, IGMP processing to register the multicast-group is internally (automatically) processed. When the user opens the SOCKET ​n with multicast mode, the “Join” message is internally transmitted. If the user closes it, the “Leave” message is internally transmitted. After the SOCKET opens, the “Report” message is periodically and internally transmitted when the user communicates.\\ 
-The W5500 support IGMP version 1 and version 2 only. If user wants use an updated version, the host processes IGMP directly by using the IPRAW mode SOCKET.+The W5100S ​support IGMP version 1 and version 2 only. If user wants use an updated version, the host processes IGMP directly by using the IPRAW mode SOCKET.
  
 == SOCKET Initialization == == SOCKET Initialization ==
-Choose one SOCKET for multicast communication among 8 SOCKETS ​of W5500. Set the Sn_DHAR0 to ‘Multicast-group hardware address’ and set the Sn_DIPR0 to ‘Multicastgroup IP address.’ Then set the Sn_PORT0 and Sn_DPORT0 to ‘Multicast-group port number.’ Set the Sn_MR(P3:​P0) to UDP and set the Sn_MR(MULTI) to ‘1.’ Finally, execute OPEN command. If the state of Sn_SR is changed to SOCK_UDP after the OPEN command, the SOCKET initialization is completed.+Choose one SOCKET for multicast communication among 4 SOCKETs ​of W5100S. Set the Sn_DHAR0 to ‘Multicast-group hardware address’ and set the Sn_DIPR0 to ‘Multicastgroup IP address.’ Then set the Sn_PORT0 and Sn_DPORT0 to ‘Multicast-group port number.’ Set the Sn_MR(P3:​P0) to UDP and set the Sn_MR(MULTI) to ‘1.’ Finally, execute OPEN command. If the state of Sn_SR is changed to SOCK_UDP after the OPEN command, the SOCKET initialization is completed.
  
 <code c> <code c>
Line 223: Line 222:
 START: START:
 /* set Multicast-Group information */ /* set Multicast-Group information */
-Sn_DHAR0 = 0x01; /* set Multicast-Group H/W address(01:​00:​5e:​01:​01:​0b) */ +/* set Multicast-Group H/W address(01:​00:​5e:​01:​01:​0b) */ 
-Sn_DHAR1 ​= 0x00+Sn_DHAR[0:​5] ​{0x01,0x00,0x5e,0x01,0x01,0x0b};  
-Sn_DHAR2 = 0x5E; + 
-Sn_DHAR3 = 0x01+/* set Multicast-Group IP address(211.1.1.11) */ 
-Sn_DHAR4 = 0x01; +Sn_DIPR[0:​3] ​{211,1,1,11}
-Sn_DHAR5 = 0x0B; + 
-Sn_DIPR0 = 211; /* set Multicast-Group IP address(211.1.1.11) */ +Sn_DPORT[0:​1] ​={0x0B,0xB8}; /* set Multicast-GroupPort number(3000) */ 
-Sn_DIPR1 ​= 1+Sn_PORT[0:​1] ​{0x0B,0xB8}; /* set SourcePort number(3000) */
-Sn_DIPR2 = 1+
-Sn_DIRP3 = 11; +
-Sn_DPORT0 ​0x0BB8; /* set Multicast-GroupPort number(3000) */ +
-Sn_PORT0 ​0x0BB8; /* set SourcePort number(3000) */+
 Sn_MR = 0x02 | 0x80; /* set UDP mode & Multicast on Socket n Mode Register */ Sn_MR = 0x02 | 0x80; /* set UDP mode & Multicast on Socket n Mode Register */
 Sn_CR = OPEN; /* set OPEN command */ Sn_CR = OPEN; /* set OPEN command */
Line 245: Line 240:
 Refer to the “Unicast & Broadcast.” section. Refer to the “Unicast & Broadcast.” section.
  
-[[http://​wizwiki.net/​wiki/​doku.php?​id=products:​w5500:​application:​udp_function#​unicast_and_broadcast|Unicast & Broadcast]]+[[http://​wizwiki.net/​wiki/​doku.php?​id=products:​w5100s:​application:​udp_function#​unicast_and_broadcast|Unicast & Broadcast]]
  
 == Receiving process == == Receiving process ==
 Refer to the “Unicast & Broadcast.” section. Refer to the “Unicast & Broadcast.” section.
-[[http://​wizwiki.net/​wiki/​doku.php?​id=products:​w5500:​application:​udp_function#​unicast_and_broadcast|Unicast & Broadcast]]+[[http://​wizwiki.net/​wiki/​doku.php?​id=products:​w5100s:​application:​udp_function#​unicast_and_broadcast|Unicast & Broadcast]]
  
 == Check send data / Sending Process == == Check send data / Sending Process ==
Line 268: Line 263:
 { {
 /* copy upper_size bytes of source_addr to destination_address */ /* copy upper_size bytes of source_addr to destination_address */
-upper_size = (gSn_TX_MASK + 1) – dst_mask;+upper_size = (gSn_TX_MASK + 1) dst_mask;
 memcpy((0x0000 + source_addr),​ (0x0000 + dst_ptr), upper_size);​ memcpy((0x0000 + source_addr),​ (0x0000 + dst_ptr), upper_size);​
 /* update source_addr*/​ /* update source_addr*/​
 source_addr += upper_size; source_addr += upper_size;
 /* copy left_size bytes of source_addr to gSn_TX_BASE */ /* copy left_size bytes of source_addr to gSn_TX_BASE */
-left_size = len – upper_size;+left_size = len upper_size;
 memcpy( source_addr,​ gSn_TX_BASE,​ left_size); memcpy( source_addr,​ gSn_TX_BASE,​ left_size);
 } }
Line 299: Line 294:
 == Check finished / SOCKET close == == Check finished / SOCKET close ==
 Refer to the “Unicast & Broadcast.” section. Refer to the “Unicast & Broadcast.” section.
-[[http://​wizwiki.net/​wiki/​doku.php?​id=products:​w5500:​application:​udp_function#​unicast_and_broadcast|Unicast & Broadcast]] +[[http://​wizwiki.net/​wiki/​doku.php?​id=products:​w5100s:​application:​udp_function#​unicast_and_broadcast|Unicast & Broadcast]]
  
products/w5100s/application/udp_function.1490945494.txt.gz · Last modified: 2017/03/31 16:31 by lawrence