Week 10
Week 10
Week 10
Year : 2021
Session 10
Transport Layer
Learning Outcomes
Packets
Error Control
– Lost
– Delivered out of order to application
• Connectionless
UDP segment format, called user datagrams, have a fixed-size header of 8 bytes. The
following figure shows the format of a user datagram.
Destination port number. This is the port number used by the process running on
the destination host. It is also 16 bits long. If the destination host is the server (a
client sending a request), the port number, in most cases, is a well-known port
number. If the destination host is the client (a server sending a response), the port
number, in most cases, is an ephemeral port number. In this case, the server copies
the ephemeral port number it has received in the request packet.
UDP Segment Format
Length. This is a 16-bit field that defines the total length of the user datagram, header plus
data. The 16 bits can define a total length of 0 to 65,535 bytes. However, the total length
needs to be much less because a UDP user datagram is stored in an IP datagram with the total
length of 65,535 bytes. The length field in a UDP user datagram is actually not necessary. A
user datagram is encapsulated in an IP datagram. There is a field in the IP datagram that
defines the total length. There is another field in the IP datagram that defines the length of the
header. So, if we subtract the value of the second field from the first, we can deduce the length
of the UDP datagram that is encapsulated in an IP datagram.
However, the designers of the UDP protocol felt that it was more efficient for the
destination UDP to calculate the length of the data from the information provided in the UDP
user datagram rather than ask the IP software to supply this information. We should remember
that when the IP software delivers the UDP user datagram to the UDP layer, it has already
dropped the IP header.
Checksum. This field is used to detect errors over the entire user datagram (header plus data).
The checksum is discussed in the next section.
Checksum
The checksum includes three sections: a pseudoheader, the UDP header, and the
data coming from the application layer. The pseudoheader is the part of the header
of the IP packet in which the user datagram is to be encapsulated with some fields
filled with 0s.
Checksum
The following figure shows the checksum calculation for a very small user
datagram with only 7 bytes of data. Because the number of bytes of data is odd,
padding is added for checksum calculation.
https://www.youtube.com/watch?v=AtVWnyDDaDI
Example 14.1
The following is a dump of a UDP header in hexadecimal format.
TCP characteristics:
• Point-to-point connections
₋ one sender, one receiver
• Full duplex data:
₋ bi-directional data flow in same connection
• Reliable, in-order byte steam transmission
₋ with no “message boundaries” between bytes
• Pipelined transmission
₋ multiple segments are sent at the same time
₋ Maximum segments sent simultaneously = TCP congestion/flow control
window size
₋ send & receive buffers at sender and receiver
• Connection-oriented:
₋ handshaking occurs between the sender, receiver before data exchange
• Uses flow control:
₋ The sender will not overwhelm receiver’s buffer
TCP Segment Format
TCP Segment Format
Source port address. This is a 16-bit field that defines the port number of the application
program in the host that is sending the segment. This serves the same purpose as the source
port address in the UDP header
Destination port address. This is a 16-bit field that defines the port number of the
application program in the host that is receiving the segment. This serves the same purpose as
the destination port address in the UDP.
Sequence number. This 32-bit field defines the number assigned to the first byte of data
contained in this segment. As we said before, TCP is a stream transport protocol. To ensure
connectivity, each byte to be transmitted is numbered. The sequence number tells the
destination which byte in this sequence is the first byte in the segment. During connection
establishment (discussed later) each party uses a random number generator to create an initial
sequence number (ISN), which is usually different in each direction.
Acknowledgment number. This 32-bit field defines the byte number that the receiver of the
segment is expecting to receive from the other party. If the receiver of the segment has
successfully received byte number x from the other party, it returns x + 1 as the
acknowledgment number. Acknowledgment and data can be piggybacked together.
TCP Segment Format
Header length. This 4-bit field indicates the number of 4-byte words in the TCP
header. The length of the header can be between 20 and 60 bytes. Therefore, the
value of this field is always between 5 (5× 4 = 20) and 15 (15× 4 = 60).
Control. This field defines 6 different control bits or flags. One or more of these
bits can be set at a time. These bits enable flow control, connection establishment
and termination, connection abortion, and the mode of data transfer in TCP.
Window size. This field defines the window size of the sending TCP in bytes.
Note that the length of this field is 16 bits, which means that the maximum size of
the window is 65,535 bytes. This value is normally referred to as the receiving
window (rwnd) and is determined by the receiver. The sender must obey the
dictation of the receiver in this case.
TCP Segment Format
Checksum. This 16-bit field contains the checksum. The calculation of the
checksum for TCP follows the same procedure as the one described for UDP.
However, the use of the checksum in the UDP datagram is optional, whereas
the use of the checksum for TCP is mandatory. The same pseudoheader, serving
the same purpose, is added to the segment. For the TCP pseudoheader, the
value for the protocol field is 6.
Urgent pointer. This 16-bit field, which is valid only if the urgent flag is set, is
used when the segment contains urgent data. It defines a value that must be
added to the sequence number to obtain the number of the last urgent byte in
the data section of the segment.