Unit 3
Unit 3
Ans: The User Datagram Protocol (UDP) is a connectionless, unreliable transport protocol that provides
minimal services beyond the Internet Protocol (IP). It facilitates process-to-process communication rather
than host-to-host, with limited error checking. Despite its simplicity, UDP has several advantages,
especially in scenarios where speed and efficiency are more critical than reliability.
UDP packets, known as user datagrams, have an 8-byte fixed-size header comprising the following fields:
1. Source Port Number (16 bits): Indicates the port number used by the process on the source host.
For clients, this is typically an ephemeral port number, while servers use well-known port
numbers.
2. Destination Port Number (16 bits): Specifies the port number for the process on the destination
host. It follows similar conventions to the source port number.
3. Length (16 bits): Defines the total length of the user datagram, including both the header and
data. This value ranges from 0 to 65,535 bytes, although practical limits are lower due to
encapsulation in IP datagrams.
4. Checksum (16 bits): Used for error detection over the entire user datagram (header and data). It
includes a pseudoheader derived from the IP header to ensure the datagram is correctly delivered
to the UDP protocol and not corrupted.
Characteristics of UDP
Applications of UDP
Despite its simplicity and lack of reliability, UDP is suitable for various applications, particularly where
low latency is essential, and occasional packet loss is acceptable:
2.What is TCP Segment format? What is TCP Fragmentation ? What are TCP differential
services?
Ans: A TCP segment consists of a header and data from the application layer. The header can range from
20 to 60 bytes, depending on the presence of optional fields. The structure of the TCP segment header
includes:
1. Source Port Address (16 bits): Identifies the port number of the sending application.
2. Destination Port Address (16 bits): Identifies the port number of the receiving application.
3. Sequence Number (32 bits): Specifies the number assigned to the first byte of data in the
segment. Each byte in the TCP stream is numbered sequentially to ensure reliable delivery.
4. Acknowledgment Number (32 bits): Indicates the next byte expected by the receiver. If the
receiver has successfully received byte number x, it acknowledges x + 1.
5. Header Length (4 bits): Specifies the length of the TCP header in 4-byte words. The header
length ranges from 20 to 60 bytes, giving values from 5 to 15.
6. Reserved (6 bits): Reserved for future use.
7. Control Flags (6 bits): Includes the following flags:
o URG: Urgent pointer field is valid.
o ACK: Acknowledgment field is valid.
o PSH: Push function.
o RST: Reset the connection.
o SYN: Synchronize sequence numbers.
o FIN: Terminate the connection.
8. Window Size (16 bits): Specifies the size of the receiving window, indicating how many bytes
the receiver is currently willing to accept. The maximum value is 65,535 bytes.
9. Checksum (16 bits): Used for error-checking of the header and data. The inclusion of the
checksum is mandatory in TCP.
10. Urgent Pointer (16 bits): Valid only if the URG flag is set, it indicates the end of urgent data in
the segment.
11. Options and Padding (0-40 bytes): Used for various TCP options like Maximum Segment Size
(MSS), Window Scale factor, etc.
TCP Fragmentation
TCP fragmentation refers to the breaking down of a large segment into smaller segments to fit the
Maximum Transmission Unit (MTU) of the underlying network. This process is essential for efficient
data transfer and to avoid packet loss due to oversized segments that cannot be transmitted through the
network. Fragmentation in TCP involves:
Segmentation: TCP divides the data into smaller segments, ensuring each fits within the MTU.
Reassembly: At the receiving end, TCP reassembles the segments into the original data stream.
Differential services in TCP involve mechanisms to manage and prioritize different types of traffic to
improve performance and reliability. Key aspects include:
1. Quality of Service (QoS): TCP can work with IP's QoS features to ensure that critical
applications (like VoIP or streaming) receive higher priority over less critical ones (like email).
2. Explicit Congestion Notification (ECN): TCP can use ECN to detect and respond to network
congestion without dropping packets. ECN allows routers to mark packets instead of dropping
them, and the sender then adjusts its transmission rate.
3. Selective Acknowledgments (SACK): This feature allows the receiver to inform the sender
about successfully received segments, enabling the sender to retransmit only the missing
segments, rather than all segments following a lost one.
4. Differentiated Services Code Point (DSCP): This field in the IP header is used to classify and
manage traffic by setting different levels of service. TCP segments can be marked for specific
handling in the network based on the DSCP value.
Ans: The 3-way handshake protocol is used in TCP to establish a connection between a client and a
server, ensuring both parties are ready for communication.
This process involves three steps:
The connection is now established, and both parties can begin data transfer. The client and server can
simultaneously send and receive data in full-duplex mode.
In rare cases, a simultaneous open can occur when both parties initiate the connection simultaneously.
Each side sends a SYN segment, and they each respond with a SYN + ACK segment, resulting in a single
connection being established.
The 3-way handshake also addresses security concerns. For instance, the SYN flooding attack involves an
attacker sending numerous SYN segments with fake source IP addresses, causing the server to allocate
resources for non-existent clients. This can be mitigated by limiting connection requests, filtering
unwanted IP addresses, or using cookies to delay resource allocation until the connection is fully
established.
Ans: TCP uses a sliding window protocol to manage flow control and ensure efficient data transmission.
This protocol is a hybrid of the Go-Back-N and Selective Repeat sliding window protocols, as it does not
use negative acknowledgments (NAKs) like Go-Back-N but does allow the receiver to hold out-of-order
segments until the missing ones arrive, similar to Selective Repeat.
There are two key differences between the TCP sliding window and the one used at the data link layer:
The sliding window in TCP spans a portion of the buffer containing bytes received from the process. This
window has two walls: a left wall and a right wall. The bytes within the window can be transmitted
without awaiting acknowledgment.
Opening the Window: This involves moving the right wall to the right, allowing more new bytes
in the buffer to become eligible for sending.
Closing the Window: This involves moving the left wall to the right, indicating that some bytes
have been acknowledged and the sender no longer needs to worry about them.
Shrinking the Window: This involves moving the right wall to the left, revoking the eligibility
of some bytes for sending. Shrinking is discouraged and not allowed in some implementations
because if the sender has already sent these bytes, revoking them can cause issues. The left wall
cannot move to the left, as this would revoke previously sent acknowledgments.
The sliding window mechanism ensures that data transmission is efficient and prevents the destination
from being overwhelmed with data. The window size at one end is determined by the lesser of two
values:
Receiver Window (rwnd): This value is advertised by the opposite end in an acknowledgment
segment and indicates the number of bytes the other end can accept before its buffer overflows.
Congestion Window (cwnd): This value is determined by the network to avoid congestion.
Operation
1. Initial Transmission: The sender begins by sending segments of data within the window size.
2. Acknowledgments: As the receiver gets data, it sends acknowledgments back to the sender. The
sender then moves the left wall of the window to the right, acknowledging received data and
allowing more data to be sent.
3. Dynamic Adjustment: The size of the window can dynamically change based on network
conditions (cwnd) and the receiver's buffer capacity (rwnd). If the network is congested, the
congestion window may shrink, reducing the sender's transmission rate.
The TCP sliding window protocol effectively manages data flow, ensuring that the sender transmits data
at an optimal rate without overwhelming the receiver or causing network congestion. By dynamically
adjusting the window size, TCP maintains a balance between efficient data transmission and network
stability.