Ensuring Full-Sized Segments

 < Day Day Up > 



Let’s do a quick review to understand the principles at work in this optimization. A datagram on the network is made up of a set of encapsulating packet headers followed by a data payload. The size of the data payload is based upon the particular protocol (we focus here on IPv4), the configuration of the two communicating peers, and the configuration of the intermediate nodes between the two peers.

The IPv4 protocol specifies that a datagram can be of size 64 KB, though this is generally much larger than is normally allowed. The most common MTU (or Maximum Transmission Unit) is 1500 octets. Depending upon the options specified within the IP and/or TCP packet headers, the size of the payload may be around 1448 octets. The largest payload size given the MTU is also known as the MSS (or Maximum Segment Size). This section focuses on ensuring that both the MTU and MSS are the largest supported by the given network and configuration.

The MTU can commonly be configured at the interface. This is known as the Link MTU. The application developer can modify the MSS via a socket option. The most common method to alter the MTU (and MSS) is known as Path MTU Discovery. This method is performed automatically within protocol stacks that support the option. The advantage to Path MTU Discovery is that the method identifies the Path MTU, which should not be confused with the Link MTU. The Path MTU is the largest MTU possible for the path between the two communicating peers on the network. Another important distinction for Path MTUs is that they’re only relevant on indirect routes. An indirect route is a path that is not on the same subnetwork. If two peers on are on the same network (can communicate directly with one another without going through a gateway, router, etc.), then they have a direct route to one another. Otherwise, if the path must go through a router, switch, and so on, then the route is indirect. Path MTUs only exist for indirect routes; therefore, Path MTU Discovery isn’t possible for peers on the same subnetwork.

Path MTU Discovery works by sending varying sized packets from peer to peer with a special bit set in the IP header called DF, or Don’t Fragment. This bit specifies that the datagram should not be fragmented during its trip from peer to peer. If the packet is too large for the Path MTU, then the packet is rejected with the DF bit set (otherwise, the interior node would split the packet up so that it fit within the constraints of the interior node’s Link MTU). If the packet is rejected, the originating peer receives a special ICMP message specifying that the packet was too large. The peer then reduces the size of the datagram and tries again until it finds the largest packet possible that makes it from the originator to the recipient. This is the Path MTU and is optimal for the given connection. The Path MTU defines the largest datagram, and the largest segment size that can travel between the two peers, and is, therefore, the optimal MSS for the connection.

The application developer should first check to ensure that their TCP/IP stack supports Path MTU Discovery, and then ensure that it is enabled. Some stacks provide socket option enables on a per-connection basis, but most enable by default if the option is supported.



 < Day Day Up > 



BSD Sockets Programming from a Multi-Language Perspective
Network Programming for Microsoft Windows , Second Edition (Microsoft Programming Series)
ISBN: 1584502681
EAN: 2147483647
Year: 2003
Pages: 225
Authors: Jim Ohlund

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net