CN Notes-Unit V
CN Notes-Unit V
CN Notes-Unit V
UNIT V
1. Explain the format of UDP header and UDP message queue.
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 processit also ensures the
correctness of the message by the use of a checksum.
Mrs. Reena Vimal A. G.
Dept. of MCA, TOCE.
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 headerprotocol
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.
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.
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.
1.
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.
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 ACKssending one combined ACK rather than multiple
smaller onesbut 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.
Nagles 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 dont 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.
Mrs. Reena Vimal A. G.
Dept. of MCA, TOCE.
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.
Nagles 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
4. Advantages of UDP