IP Fragmentation
95
SWRU455A – February 2017 – Revised March 2017
Copyright © 2017, Texas Instruments Incorporated
Socket
{
// error
}
Addr.sin_family = SL_AF_INET;
Addr.sin_port = sl_Htons(5001);
Addr.sin_addr.s_addr = sl_Htonl(SL_IPV4_VAL(192,168,1,31));;
Status = sl_Connect(Sd, ( SlSockAddr_t *)&Addr,
sizeof
(SlSockAddr_t));
if
( Status )
{
// error
}
Status = sl_Select( nfds, NULL, &rxSet, NULL, &timeVal );
//Sleep until triggered by the select event
2. The host can now enter deep sleep until triggered by the select event
3. After the SL_SOCKET_TRIGGER_EVENT_SELECT event is received, the host wakes up and calls
sl_Select to identify which socket has network activity.
//Call select again since the trigger event has arrived
SL_SOCKET_FD_ZERO( &rxSet );
SL_SOCKET_FD_SET( Sd, &rxSet );
Status = sl_Select( nfds, NULL, &rxSet, NULL, &timeVal );
if
(SL_SOCKET_FD_ISSET(Sd, &rxSet))
{
//socket is marked, call receive
Status = sl_Recv(Sd, RecvBuf, 1460, 0);
if
( Status )
{
// error
}
}
6.8
IP Fragmentation
IP fragmentation is a method of breaking the IP packet into smaller messages compatible with the
Maximum Transmission Unit (MTU) size, and reassembling them on the receive side. IPv4 routers
fragment packets according to the MTU of the link. IPv6 routers do not fragment, and it is the
responsibility of the device to fragment the packets. When receiving data, the SimpleLink device supports
reassembling of the received IP fragmented packets for both IPv4 and IPv6. When the host application
sends data which is bigger than the MTU size, the SimpleLink device splits this data into packets
compliant with the MTU size without using IP fragmentation. For TCP, the size has no effect because TCP
ensures byte ordering. However, for UDP the size may cause packet reordering, therefore, TI
recommends that host application sends UDP data up to the MTU size (1472 bytes for IPv4 and 1452
bytes for IPv6), or verify data integrity in higher layers.
The SimpleLink device response to a fragmented ping, the maximum ping packet payload is 19,232 bytes
for Ipv4 and 27,976 bytes for IPv6.
6.9
Errors
One of the main differences between BSD sockets and SimpleLink sockets implementation is that error
codes are returned directly, and not through the errno method (as in Linux). Errors are indicated by the
return value of the API, or by asynchronous events. Asynchronous events can be sent to the host at any
given time with a specific error indication and include specific data for each event. To listen to these
events and conclude the needed information, a handler should be implemented in the user application and
registered under the user.h header file. Each error code is unique. The following errors are common and
require user action (full possible error list is under the file error.h in the host driver).
lists errors indicated by asynchronous events.