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 [2018/03/28 13:44]
ekkim
products:w5100s:application:udp_function [2018/03/30 16:53]
matthew
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 46: Line 46:
  
 ===== Data Communications ===== ===== Data Communications =====
-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.+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 83: 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 104: 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 110: 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 156: 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 */
Line 195: 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 211: 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 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.+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 263: 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 295: Line 295:
 Refer to the “Unicast & Broadcast.” section. Refer to the “Unicast & Broadcast.” section.
 [[http://​wizwiki.net/​wiki/​doku.php?​id=products:​w5100s:​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.txt · Last modified: 2018/03/30 16:53 by matthew