Computer Networks [10MCA32] 1 UNIT V 1. Explain the format of UDP header and UDP message queue. The User Datagram Protocol (UDP) is a end-to-end transport protocol. The issue in UDP is to identify the target process. The approach used by UDP is to indirectly identify each other processes using an abstract locator, often called a port or mailbox. The basic idea is for a source process to send a message to a port and for the destination process to receive the message from a port. The next issue is how a process learns the port for the process to which it wants to send a message. Typically, a client process initiates a message exchange with a server process. Once a client has contacted a server, the server knows the client s port (it was contained in the message header) and can reply to it. The real problem, therefore, is how the client learns the server s port in the first place. A common approach is for the server to accept messages at a well-known port. That is, each server receives its messages at some fixed port that is widely published. In the Internet, for example, the domain name server (DNS) receives messages at well-known port 53 on each host, the mail service listens for messages at port 25, and the Unix talk program accepts messages at wellknown port 517, and so on. The header for UDP contains an identifier (port) for both the sender (source) and the receiver (destination) of the message. SrcPort, DstPort - It can be a client or server. If client, the port number is called ephemeral. If it is a server, then the server has a well known port number. Length - This field gives the length of the entire UDP. Checksum - Used to check errors in transmission. Typically, a port is implemented by a message queue, as illustrated in the Figure. When a message arrives, the protocol (e.g., UDP) appends the message to the end of the queue. When the queue is full, the message is discarded. There is no flow-control mechanism that tells the sender to slow down. When an application process wants to receive a message, one is removed from the front of the queue. If the queue is empty, the process blocks until a message becomes available. Finally, although UDP does not implement flow control or reliable/ordered delivery, it does a little more work than to simply demultiplex messages to some application process it also ensures the correctness of the message by the use of a checksum.
Computer Networks [10MCA32] 2 UDP computes its checksum over the UDP header, the contents of the message body, and something called the pseudoheader. The pseudoheader consists of three fields from the IP header protocol number, source IP address, and destination IP address plus the UDP length field. The pseudoheader is used to verify that this message has been delivered between the correct two endpoints. For example, if the destination IP address was modified while the packet was in transit, causing the packet to be misdelivered, this fact would be detected by the UDP checksum. 2. Explain the TCP header format with suitable diagram. TCP is a byte-oriented protocol, which means that the sender writes bytes into a TCP connection and the receiver reads bytes out of the TCP connection. TCP on the source host buffers enough bytes into send buffer and then sends the packet to its peer on the destination host. TCP on the destination host then empties the contents of the packet into a receive buffer, and the receiving process reads from this buffer at its leisure. This situation is illustrated in the Figure.
Computer Networks [10MCA32] 3 The packets exchanged between TCP peers are called segments, since each one carries a segment of the byte stream. Each TCP segment contains the header schematically depicted in the Figure. The SourcePort specifies a 16 bit Source port. DestinationPort identify the 16 bit destination port. The SequenceNumber is a 32 bit field which contains the sequence number for the first byte of data carried in that segment. The Acknowledgment Number is a 32 bit field identifying the next data byte the sender expects from the receiver. AdvertisedWindow or Window Size field, a 16-bit integer used by TCP for flow control in the form of a data transmission window size. This number tells the sender how much data the receiver is willing to accept. The header length gives the length of the header in 32-bit words. This is required because the length of the options field is variable. Reserved is a 6-bit field currently unused and reserved for future use. The 6-bit Flags field is used to relay control information between TCP peers. The possible flags include SYN, FIN, RESET, PUSH, URG, and ACK. o The SYN and FIN flags are used when establishing and terminating a TCP connection, respectively. o The ACK flag is set any time the Acknowledgment field is valid. o The URG flag signifies that this segment contains urgent data. o When this flag is set, the UrgentPointer field indicates where the nonurgent data contained in this segment begins. The urgent data is contained at the front of the segment body, up to and including a value of UrgentPointer bytes into the segment. o The PUSH flag signifies that the sender invoked the push operation, which indicates that the receiver should deliver this segment to the receiving application as soon as possible. o The RESET flag signals the receiver that the sender is aborting the connection and all queued data and allocated buffers for the connection can be freed. Finally, the Checksum field is used in exactly the same way as for UDP it is computed over the TCP header, the TCP data, and the pseudoheader, which is made up of the source address, destination address, and length fields from the IP header. Options: In order to provide additional functionality, several optional parameters may be used between a TCP sender and receiver. Depending on the option(s) used, the length of this field will vary in size, but it cannot be larger than 40 bytes due to the size of the header length field (4 bits).
Computer Networks [10MCA32] 4 The most common option is the maximum segment size (MSS) option. A TCP receiver tells the TCP sender the maximum segment size it is willing to accept through the use of this option. Other options are often used for various flow control and congestion control techniques. The Padding or Offset field, measures the offset from the start of the packet to the start of the data. Data is a variable length field carries the application data from TCP sender to receiver. This field coupled with the TCP header fields constitutes a TCP segment. 3. Explain how TCP manages byte stream? TCP supports a byte-stream that is, application programs write bytes into the stream. The TCP has to decide whether it has enough bytes to send a segment. The TCP has three mechanisms to trigger the transmission of a segment. 1. First, TCP maintains a variable, called the maximum segment size (MSS), and it sends a segment as soon as it has collected MSS bytes from the sending process. MSS is usually set to the size of the largest segment TCP can send without causing the local IP to fragment. 2. The second thing that triggers TCP to transmit a segment is that the sending process has explicitly asked it to do so. TCP supports a push operation, and the sending process invokes this operation to flush the buffer of unsent bytes. 3. The third thing that fires transmission of a segment is that when a timer fires. Silly Window Syndrome Silly window syndrome is a problem when either the sender transmits a small segment or the receiver opens the window a small amount. The application might do a push after sending a single byte leading to a small segment. In order to solve this problem, the rule is that after advertising a zero window, the receiver must wait for space equal to an MSS before it advertises an open window. Since this problem cannot be eliminated, we can try to coalesce them. The receiver can do this by delaying ACKs sending one combined ACK rather than multiple smaller ones but this is only a partial solution because the receiver has no way of knowing how long it is safe to delay waiting either for another segment to arrive or for the application to read more data. Nagle s Algorithm If there is data to send but the window is open less than MSS, then we may want to wait some amount of time before sending the available data, but the question is, how long? If we wait too long, then the connection may be disconnected. If we don t wait long enough, then we risk sending a bunch of tiny packets and falling into the silly window syndrome. The answer is to introduce a timer, and to transmit when the timer expires. Nagle introduced an elegant self-clocking solution.
Computer Networks [10MCA32] 5 The idea is that as long as TCP has any data to transfer, the sender will eventually receive an ACK. This ACK can be treated like a timer firing, triggering the transmission of more data. Nagle s algorithm provides a simple, unified rule for deciding when to transmit: When the application produces data to send if both the available data and the window MSS send a full segment else if there is unacked data in flight buffer the new data until an ACK arrives else send all the new data now Always send a full segment if the window allows. It can also immediately send a small amount of data if there are currently no segments in transit, If there is anything in flight, the sender must wait for an ACK before transmitting the next segment. Because some applications cannot afford such a delay for each write, the application turns off Nagel s algorithm by setting the TCP_NODELAY option. Setting this option means that data is transmitted as soon as possible. 4. Advantages of UDP It is a simple protocol using a minimum of overheads. If a process wants to send a small message and does not care much about reliability it can use UDP. UDP is suitable for a process with internal flow & error control mechanism. Ex: Trivial File Transfer Protocol (TFTP). UDP is suitable for multicasting. UDP is also used for root updating protocol such as Routing Information Protocol (RIP).