Module 5_transport Layer Ppt FINAL (3)
Module 5_transport Layer Ppt FINAL (3)
Transport Layer:
The Transport layer Services, The Internet Transport Protocol: TCP
and UDP. TCP:-Introduction to TCP, The TCP Protocol, The TCP
Segment Header, TCP Connection Establishment, TCP Connection
Release, Modelling TCP Connection Management, TCP Transmission
Policy, TCP Congestion Control, TCP Timer Management.
TCP/IP and OSI model
Internet Layer
2
Transmission Control Protocol
TCP is short for Transmission Control Protocol.
This is because-
• It tells the sender whether data packet has reached its destination
safely or not.
• TCP employs retransmission to compensate for packet loss.
2) TCP is a connection oriented protocol.
•TCP ensures that the data packets get deliver to the destination in
the same order they are sent by the sender.
Sequence number:
o 32 bit field
oSince TCP is connection oriented protocol, to ensure
connectivity , each byte to be transmitted is numbered.
Acknowledgement number:
o 32-bit field
odefines the number that the receiver is expecting to receive from
source
oIf the receiver of the segment has successfully received segment
number x from the other source, it returns x + 1 as the
acknowledgment number.
• Numbering System
• TCP software keeps track of the segments being transmitted or
received , but there is no field for a segment number value in
the TCP header.
• Instead, there are two fields called the sequence number and
the acknowledgment number. These two fields refer to a byte
number and not a segment number.
• Byte Number
• The bytes of data being transferred in each connection are
numbered by TCP.
• The numbering starts with an arbitrarily generated number.
• Sequence Number
• After the bytes have been numbered, TCP assigns a sequence
number to each segment that is being sent.
• The sequence number for each segment is the number of the
first byte of data carried in that segment.
• Acknowledgment Number
• The value of the acknowledgment field in a segment defines
the number of the next byte a receiver expects to receive.
• The acknowledgment number is cumulative.
Header length
o 4 bit field
o value in this field is always between 5(5*4=20) and 15(15*4=60)
Reserved
o6 bit field
oFor future use
Control
oThis field defines 6 different control bits or flags
oOne or more of these bits can be set at a time
oThese bits enable flow control, connection establishment and
termination, connection abortion, and the mode of data transfer in
TCP.
URG
oThe URG flag is used to inform a receiving station that certain data
within a segment is urgent and should be prioritized.
oIf the URG flag is set, the receiving station evaluates the urgent
pointer, a 16-bit field in the TCP header. This pointer indicates how
much of the data in the segment, counting from the first byte, is
urgent
oThe sending TCP creates a segment and inserts the urgent data at
the beginning of the segment. The rest of the segment can contain
normal data from the buffer. The urgent pointer field in the header
defines the end of the urgent data (the last byte of urgent data).
Details of Control field : Flags
oACK
oTo indicate that value carried in acknowledgement field is valid
RST,SYN,FIN
oUsed for connection set up and tear down.
PSH
oUsed for flow control.
Window size
o This field defines the window size of the sending TCP in bytes
Checksum
o 16 bit field- to detect error
Urgent pointer
o16 bit field
o valid only if the urgent flag is set.
o It is used when the segment contains urgent data.
odefines the end of the urgent data
Options
o 40 bytes of optional info in TCP header.
User datagram format
USER User
DATAGRAM PROTOCOL
datagram Protocol
Source port ,Destination port:16 bit
For a client:ephemeral port (> than 1023)
For a source : well known port (0-1023)
20
Example
Given a DUMP of a UDP header in hexadecimal
format 04 21 00 0B 00 2A E2 17. Find the following:-
• The length of the data is the length of the whole packet — the
length of the header i.e. 42 – 8 = 34 bytes
Example
• The following is a dump of a TCP header in hexadecimal
format.
Ready to accept
the connection
The FIN segment consumes one sequence number if it does not carry data.
The FIN + ACK segment consumes one sequence number if it does not carry
data.
An ACK segment, if carrying no data, consumes no sequence number
Half-Close
• In TCP, one end can stop sending data while still receiving
data.
• Either the server or the client can issue a half-close request.
• The client half-closes the connection by sending a FIN
segment.
• The FIN + ACK segment consumes one sequence number if it
does not carry data.
TCP state machine
Windows in TCP
• TCP uses two windows (send window and receive window)
for each direction of data transfer, which means four windows
for a bidirectional communication.
• The receive window closes (moves its left wall to the right) when
it sends acknowledgement.
• It opens (moves its right wall to the right) when more
bytes are pulled by the process.
• We assume that it does not shrink (the right wall does
not move to the left).
Receiver Window
An example of flow control
Shrinking of Windows
• The receive window cannot shrink.
• But the send window can shrink if the receiver defines a
value for rwnd that results in shrinking the window.
• The receiver needs to keep the following relationship
between the last and new acknowledgment and the last and
new rwnd values to prevent the shrinking of the send window
Shrinking of Windows example
Sender has sent bytes from 206 to 214
210
40
Window Shutdown
• Shrinking the send window by moving its right wall to the left
is strongly discouraged.
• However, there is one exception: the receiver can temporarily
shut down the window by sending a rwnd of 0.
• In this case, the sender does not actually shrink the size of the
window, but stops sending data until a new advertisement has
arrived.
• Even when the window is shut down by an order from the
receiver, the sender can always send a segment with 1 byte of
data.
• This is called probing and is used to prevent a deadlock.
Error control
The sender starts with a slow rate of transmission, but increases the
rate rapidly to reach a threshold.
Start → cwnd = i
After 1 RTT → cwnd = i + 1
After 2 RTT → cwnd = i + 2
After 3 RTT → cwnd = i + 3
Congestion detection
•If congestion occurs, the congestion window size must be decreased.
•The only way a sender can guess that congestion has occurred is the
need to retransmit a segment
•However, retransmission can occur in one of two cases: when the
RTO timer times out or when three ACKs are received.
a. If a time-out occurs, there is a stronger possibility of
congestion.
b. If three ACKs are received, there is a weaker possibility of
congestion.
TCP Timers
• Retransmission Timer
• To retransmit lost segments, TCP employs one retransmission timer
that handles the retransmission time-out (RTO), the waiting time for
an acknowledgment of a segment.
• Round-Trip Time (RTT)
• To calculate the retransmission time-out (RTO), we first need to
calculate the roundtrip time (RTT).
– Measured RTT (RTTM): how long it takes to send a segment and receive an
acknowledgment for it. This is the measured RTT.
– Smoothed RTT(RTTs) RTTM, is likely to change for each round trip.The
fluctuation is so high in today’s Internet that a single measurement alone
cannot be used for retransmission time-out calculation purposes.
– RTT Deviation(RTTD) Most implementations do not just use RTTS; they also
calculate the RTT deviation, called RTTD, based on the RTTS and RTTM.
Smoothed RTT Calculation