Professional Documents
Culture Documents
Computer Networks
IT3001
Prof. Ayaskanta Mishra
Overview
• What is TCP?
• Services provided by TCP
– TCP Bytes, Sequence and ACK Numbering
• TCP Segment Format
– Header , Control Fields
– Pseudo header for Checksum
• TCP Connection Management
1. 3-way handshaking for connection establishment
SYN flooding Attack
2. Data transfer
3. 3-way /4-way connection teardown (termination)
What is TCP?
• Connection Oriented
• Reliable
• Acknowledgement
• Handshaking ( 3 Phase)
• Common Transport layer protocol in Internet
Services provided by TCP
1. Process to Process Communication
2. Stream delivery service
3. Sending and Receiving Buffer
4. Segments
5. Full duplex communication
6. Multiplexing and De-multiplexing
7. Connection Oriented Service
8. Reliable Service
Services provided by TCP (Cont.)
1.Process to Process Communication
Services provided by TCP (Cont.)
2. Stream delivery service
Services provided by TCP (Cont.)
3. Sending and Receiving Buffer
Services provided by TCP (Cont.)
4. Segments
Services provided by TCP (Cont.)
5. Full duplex communication
Services provided by TCP (Cont.)
6. Multiplexing and De-multiplexing
Services provided by TCP (Cont.)
7. Connection Oriented Service
Services provided by TCP (Cont.)
8. Reliable Service
TCP Numbering System
(Byte Number, Sequence Number, ACK Number)
1. Byte Number
FIN segment does not carry any data and consume no sequence Number
Half-close ( 4-Way Handshaking)
TCP – State Machine
Overview:
• Illustration of the TCP State Transition Diagram
• Significance of TIME, WAIT state and 2MSL
timeout
• MSL – Maximum Segment Life time
– The time for which a Segment will be alive in a
network after that it shall be destroyed.
– Common value is 30 seconds, it can be 1 minute
even 2 minutes
• Demonstration of various state change in a TCP
client/server program through “netstat” command
Time-line diagram for a Common Scenario
TCP State Transition Diagram
Half-Close Scenario
Transition diagram with half-close connection termination
TCP – Flow & Error Control
Overview:
• Significance of send and receive window in
TCP
• What is Flow Control?
– How it works in TCP with Examples.
• What is Error Control?
– How it works in TCP with Examples.
TCP Windows
• There are a pair of window each side 1. Send
Window, 2. Receive window for each
direction of data flow
• In a bi-directional communication scenario
there would be 4 windows a pair both side of
client-server
• A bidirectional scenario is nothing but two
unidirectional communication with
piggybacking implemented
Windows in TCP
1. Send Window
Send Window important points
• Send window opens, closes or shrinks
• Selective Repeat Protocol is implemented with
following key differences:
1. In SR number of packets are in Sliding Window,
however in TCP its bytes of data. Though TCP sends
Segments by Segments, variable is expressed in
bytes
2. In real world implementation TCP can store data
received from the process and send them later,
Assume that TCP sends immediately as soon as
Segment is received from process.
3. Timer: SR has multiple timers for each segments
but in TCP one timer cumulatively for all sent
segments. (restart the same timer when needed)
Windows in TCP
2. Receive Window
Receive Window important points
• TCP used SR protocol for Receive Window with
following key differences:
1. TCP allow process to PULL data in its own pace. Part of
allocated buffer might be occupied by bytes which are
successfully received and ACKNOWLEDGED already.
Receive Window <= Buffer
rwnd = buffer size – number of waiting bytes to be pulled by process
2. In SR the ACK is selective , however in TCP ACK is
cumulative hence do not support out of order bytes. In
this way TCP Rn appear like GBN.
New version of TCP support both selective as well as
cumulative ACKNOWLEDGEMENT strategy
Flow Control
Data flow and flow control feedback in TCP
Flow control Mechanism in TCP
Algorithm:
Step-1: TCP sender sends first data even if its 1 byte
Step-2: Wait and Accumulate all data from application
till its enough to encapsulate the data inside a segment
(Maximum Segment Size-MSS) Sends Segment
Step-3: Step-2 is repeated for rest of the transmission,
Segment 3 is sent immediately is ACK for Segment 2 is
received. Send next segment based on which ever is
first, either filling up MSS Segment or ACK received
2. Syndrome created by the Receiver
Problem: If application of Receiver Application
consume data slowly
Solution: Clark’s Solution
Untill the receiver buffer is full the receiver TCP
stores then send rwnd=0 to stop sending more
segment as it can not handle. (Receiver App is
consuming data slowly.
Clark’s Solution
Solution 1: Send ACK but don’t advertise the rwnd
Solution 2: Delay in sending ACK
Error Control in TCP
1. Checksum Error Detection
2. Acknowledgement
i. Cumulative Acknowledgement (ACK)
ii. Selective Acknowledgement (SACK)
3. Retransmission
i. Retransmission after RTO ( Retransmission Time-
Out) – RTO is dynamic and set based on RTT
Ascension: Sf < Sn
ii. Retransmission after Three duplicate ACK
Segments – Fast Retransmission
Error Control
Error Control - Scenarios
1. Normal Operation
2. Lost Segment
3. Fast Retransmission
4. Delayed Segment
5. Duplicate Segment
6. Automatic Corrected Lost ACK
7. Lost Acknowledgement corrected by resending
a Segment
8. Dead lock created by lost Acknowledgement
1. Normal Operation
2. Lost Segment
3. Fast Retransmission
4. Delayed Segment
• TCP uses IP to be encapsulated
• IP is a connection less protocol in Network
layer
• For some reason is the packet takes longer
path and get received at the receiver after
Time-out. This Scenario is quite possible.
• If the data takes more time than time out the
as per ARQ it will be retransmitted. In some
occasion if the original data packet get
received after the retransmitted packet then it
will be discarded at the receiver (Duplicate
data)
5. Duplicate Segment
• As discussed prior, A duplicate Segment can
be created under the Scenario of Time-out.
• If ACK is not received due to delay before
Time-out , duplicate Segment is created and
retransmitted.
• When the receiver receives a duplicate
Segment with the same SEQUENCE NUMBER,
then it simply discard the Segment.
6. Automatic Corrected Lost ACK
7. Lost Acknowledgement corrected by resending a
Segment
8. Dead lock created by lost Acknowledgement
Lost ACKNOWLEDGEMENT can create deadlock if
they are not properly handled.
• When receiver sends a ACK with rwnd=0
• Sender shutdown the window temporaryly
•After a while the receiver wants to remove that
restriction , if it has no data to be send it simply
send a ACK Segment with Non-Zero value of rwnd.
•If that ACK is lost it can lead to a dead-lock, each
end waiting indefinitely and a Retransmission timer
is not set. To avoid this a persistence timer is
designed. And Probing technique is used.
TCP – Congestion Control
Overview:
• What is Congestion and why it occurs?
• How to handle this Congestion?
• Congestion Control – Window Method
1. Slow Start: Exponential Increase (SS: EI)
2. Congestion Avoidance: Additive Increase (CA: AI)
3. Congestion Detection: Multiplicative Decrease (CD:MD)
• Congestion Control in TCP
• What is Congestion and why it occurs?
When there is more traffic in the network
Congestion Occurs.
ssthreshold = 32 (Example)
SS:EI continue up to “ssthreshold” value is
reached it will go to CA:AI