UDP and TCP

The contents of an IP payload can vary, but most IP packets contain User Datagram Protocol (UDP) or Transmission Control Protocol (TCP). At the IP level, you cannot determine much about the packet other than its size and sender. If the incoming IP payload is UDP, you can find information about who is talking to whom in the UDP header. For example, assume that you have a file server that can serve files to multiple machines. One user on machine_1 requests fileX , another user on machine_1 requests fileZ , while a user on machine_2 requests fileY , all at roughly the same time. First of all, how does the low-level protocol know that the incoming file request is for the file server application running on the machine? It is very likely that multiple servers are running on any one machine (for example TFTP, FTP, HTTP, or TELNET). When the file server application receives the request, how does it know to which client to respond? When the file server receives two requests from two different users on the same machine, how does it respond to the correct user? There's more involved than just IP addresses now. Things start to get more complicated because we are on machines with a single IP address but multiple users or applications trying to communicate with each other over the network.

The packet header for UDP is as follows . It is made up of a header and a pseudoheader. The pseudoheader is shown in italics and is built from information taken from the IP layer.

Source Port

2 bytes

Destination Port

2 bytes

Length of Packet

2 bytes

Checksum

2 bytes

Source Address

4 bytes

Destination Address

4 bytes

Zero

1 byte

Protocol

1 byte

Length of Packet

2 bytes

The pseudoheader is not part of the IP packet specification (hence the term pseudo header). The pseudoheader is constructed from the IP header below it and concatenated onto the UDP packet. The combination of source port, destination port, source IP address, and destination IP address allows the sender and receiver of these packets to keep track of not only the device (or machine) but also the application within the device (or machine) which is responsible for the packet.

TCP makes UDP look like a cakewalk . TCP is a very complicated and robust protocol that certainly requires more than just a few paragraphs. The most important distinction between UDP and TCP is that UDP does not guarantee that the packet will be received. UDP simply sends a packet to a destination; if the packet is not received, the application code must recover. TCP, on the other hand, does guarantee (within reason) that the packet will be received. With that guarantee comes a great deal of added code complexity and real-time overhead. TCP provides addressing similar to that offered by UDP but employs a very elaborate state-based handshake between sender and receiver to assure that a packet reaches its destination intact. MicroMonitor avoids this complexity by responding to all TCP connection requests with a connection reset.



Embedded Systems Firmware Demystified
Embedded Systems Firmware Demystified (With CD-ROM)
ISBN: 1578200997
EAN: 2147483647
Year: 2002
Pages: 118
Authors: Ed Sutter

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