chap-01 tcp
Post on 03-Jun-2018
233 Views
Preview:
TRANSCRIPT
-
8/12/2019 Chap-01 TCP
1/105
TCP/IP Protocol Suite 1
Chapter
Upon completion you wil l be able to:
TransmissionControl Protocol
Be able to name and understand the services offered by TCP
Understand TCPs flow and error control and congestion control
Be famil iar wi th the fields in a TCP segmentUnderstand the phases in a connection-oriented connection
Understand the TCP transition state diagram
Be able to name and understand the timers used in TCP
Be famil iar wi th the TCP options
Objectives
-
8/12/2019 Chap-01 TCP
2/105
TCP/IP Protocol Suite 2
Figure 1.1 TCP/I P protocol sui te
-
8/12/2019 Chap-01 TCP
3/105
TCP/IP Protocol Suite 3
Tcp Session 1 cont..
-
8/12/2019 Chap-01 TCP
4/105
TCP/IP Protocol Suite 4
1.1 TCP SERVICES
We explain the services offered by TCP to the processes at the appli cationlayer.
The topics discussed in this section include:
Process-to-Process Communication
Stream Delivery Service
Ful l-Duplex Communication
Connection-Oriented Service
Reliable Service
-
8/12/2019 Chap-01 TCP
5/105
TCP/IP Protocol Suite 5
Table 1.1 Well-known ports used by TCP
-
8/12/2019 Chap-01 TCP
6/105
-
8/12/2019 Chap-01 TCP
7/105
TCP/IP Protocol Suite 7
Figure 1.3 Sending and receiving buff ers
-
8/12/2019 Chap-01 TCP
8/105
TCP/IP Protocol Suite 8
Figure 1.4 TCP segments
-
8/12/2019 Chap-01 TCP
9/105
TCP/IP Protocol Suite 9
1.2 TCP FEATURES
To provide the services mentioned in the previous section, TCP hasseveral f eatures that are brief ly summarized in this section.
The topics discussed in this section include:
Numbering System
F low Control
Er ror Control
Congestion Control
-
8/12/2019 Chap-01 TCP
10/105
TCP/IP Protocol Suite 10
The bytes of data being transferred in
each connection are numbered by TCP.The numbering starts with a randomly
generated number.
Note:
-
8/12/2019 Chap-01 TCP
11/105
TCP/IP Protocol Suite 11
Suppose a TCP connection is transferr ing a fi le of 5000 bytes.The first byte is numbered 10001. What are the sequence
numbers for each segment i f data is sent in f ive segments, each
carrying 1000 bytes?
Example
SolutionThe following shows the sequence number for each segment:
Segment 1 Sequence Number: 10,001 (range: 10,001 to 11,000)
Segment 2 Sequence Number: 11,001 (range: 11,001 to 12,000)
Segment 3 Sequence Number: 12,001 (range: 12,001 to 13,000)
Segment 4 Sequence Number: 13,001 (range: 13,001 to 14,000)
Segment 5 Sequence Number: 14,001 (range: 14,001 to 15,000)
-
8/12/2019 Chap-01 TCP
12/105
TCP/IP Protocol Suite 12
The value in the sequence number
f ield of a segment defines the numberof the first data byte contained
in that segment.
Note:
-
8/12/2019 Chap-01 TCP
13/105
TCP/IP Protocol Suite 13
The value of the acknowledgment f ield
in a segment defines the number of thenext byte a party expects to receive.
The acknowledgment number is
cumulative.
Note:
-
8/12/2019 Chap-01 TCP
14/105
TCP/IP Protocol Suite 14
1.3 SEGMENT
A packet in TCP is called a segment
The topics discussed in this section include:
Format
Encapsulation
-
8/12/2019 Chap-01 TCP
15/105
TCP/IP Protocol Suite 15
Figure 1.5 TCP segment format
-
8/12/2019 Chap-01 TCP
16/105
TCP/IP Protocol Suite 16
Figure 1.6 Control fi eld
-
8/12/2019 Chap-01 TCP
17/105
TCP/IP Protocol Suite 17
I
Table 1.2 Description of f lags in the control f ield
-
8/12/2019 Chap-01 TCP
18/105
TCP/IP Protocol Suite 18
Figure 1.7 Pseudoheader added to the TCP datagram
-
8/12/2019 Chap-01 TCP
19/105
TCP/IP Protocol Suite 19
The inclusion of the checksum in TCP
is mandatory.
Note:
-
8/12/2019 Chap-01 TCP
20/105
TCP/IP Protocol Suite 20
Figure 1.8 Encapsulation and decapsulation
-
8/12/2019 Chap-01 TCP
21/105
TCP/IP Protocol Suite 21
1.4 A TCP CONNECTION
TCP is connection-oriented. A connection-oriented transport protocolestabli shes a vir tual path between the source and destination. All of the
segments belonging to a message are then sent over this vir tual path. A
connection-oriented transmission requires three phases: connection
establishment, data transfer, and connection termination.
The topics discussed in this section include:
Connection Establishment
Data Transfer
Connection Termination
Connection Reset
-
8/12/2019 Chap-01 TCP
22/105
-
8/12/2019 Chap-01 TCP
23/105
TCP/IP Protocol Suite 23
A SYN segment cannot carry data, buti t consumes one sequence number.
Note:
-
8/12/2019 Chap-01 TCP
24/105
TCP/IP Protocol Suite 24
A SYN + ACK segment cannot carry
data, but does consume one
sequence number.
Note:
-
8/12/2019 Chap-01 TCP
25/105
TCP/IP Protocol Suite 25
An ACK segment, if carrying no data,
consumes no sequence number.
Note:
-
8/12/2019 Chap-01 TCP
26/105
TCP/IP Protocol Suite 26
Figure 1.10 Data transfer
-
8/12/2019 Chap-01 TCP
27/105
TCP/IP Protocol Suite 27
The F IN segment consumes one
sequence number if it does not carry
data.
Note:
Fi 1 11 C ti t i ti i th h d h ki
-
8/12/2019 Chap-01 TCP
28/105
TCP/IP Protocol Suite 28
Figure 1.11 Connection termination using three-way handshaking
-
8/12/2019 Chap-01 TCP
29/105
TCP/IP Protocol Suite 29
The F IN + ACK segment consumes
one sequence number if it does not
carry data.
Note:
Fi 1 12 H lf l
-
8/12/2019 Chap-01 TCP
30/105
TCP/IP Protocol Suite 30
Figure 1.12 Half-close
-
8/12/2019 Chap-01 TCP
31/105
TCP/IP Protocol Suite 31
1.5 STATE TRANSITION DIAGRAM
To keep track of al l the dif ferent events happening dur ing connectionestablishment, connection termination, and data transfer, the TCP
software is implemented as a f ini te state machine. .
The topics discussed in this section include:
Scenarios
-
8/12/2019 Chap-01 TCP
32/105
TCP/IP Protocol Suite 32
Table 1.3 States for TCP
Figure 1 13 State transition diagram
-
8/12/2019 Chap-01 TCP
33/105
TCP/IP Protocol Suite 33
Figure 1.13 State transition diagram
Figure 1 14 Common scenar io
-
8/12/2019 Chap-01 TCP
34/105
TCP/IP Protocol Suite 34
Figure 1.14 Common scenar io
-
8/12/2019 Chap-01 TCP
35/105
TCP/IP Protocol Suite 35
The common value forMSL(maximum segment l i fe) is
between 30 seconds and 1 minute.
Note:
Figure 1 15 Three way handshake
-
8/12/2019 Chap-01 TCP
36/105
TCP/IP Protocol Suite 36
Figure 1.15 Three-way handshake
Figure 1 16 Simultaneous open
-
8/12/2019 Chap-01 TCP
37/105
TCP/IP Protocol Suite 37
Figure 1.16 Simultaneous open
Figure 1 17 Simultaneous close
-
8/12/2019 Chap-01 TCP
38/105
TCP/IP Protocol Suite 38
Figure 1.17 Simultaneous close
Figure 1 18 Denying a connection
-
8/12/2019 Chap-01 TCP
39/105
TCP/IP Protocol Suite 39
Figure 1.18 Denying a connection
Figure 1 19 Aborting a connection
-
8/12/2019 Chap-01 TCP
40/105
TCP/IP Protocol Suite 40
Figure 1.19 Aborting a connection
-
8/12/2019 Chap-01 TCP
41/105
TCP/IP Protocol Suite 41
1.6 FLOW CONTROL
Flow control r egulates the amount of data a source can send beforereceiving an acknowledgment from the destination. TCP defines a
window that is imposed on the buffer of data delivered from the
application program.
The topics discussed in this section include:
Sliding Window Protocol
Sil ly Window Syndrome
-
8/12/2019 Chap-01 TCP
42/105
Figure 1.20 Sliding window
-
8/12/2019 Chap-01 TCP
43/105
TCP/IP Protocol Suite 43
Figure 1.20 Sliding window
-
8/12/2019 Chap-01 TCP
44/105
1 2 3 4 5 6 7 8 9 10 11 12 13
1 2 3 4 5 6 7 8 9 10 11 12 13
1 2 3 4 5 6 7 8 9 10 11 12 13
1 2 3 4 5 6 7 8 9 10 11 12 13
1
2
3
ACK 4
Window size = 6Octets/Bytes received
Host A - Sender Host B - Receiver
Example:-
-
8/12/2019 Chap-01 TCP
45/105
1 2 3 4 5 6 7 8 9 10 11 12 13
1 2 3 4 5 6 7 8 9 10 11 12 13
1 2 3 4 5 6 7 8 9 10 11 12 13
1 2 3 4 5 6 7 8 9 10 11 12 13
1 2 3 4 5 6 7 8 9 10 11 12 13
1
2
3
ACK 4
45
1 2 3 4 5 6 7 8 9 10 11 12 13
1 2 3 4 5 6 7 8 9 10 11 12 13
ACK 6
Host B - ReceiverHost A - Sender
Window size = 6
Window Size increase by 3because received ACK for 3
octets/bytes
Host B - ReceiverHost A - Sender
-
8/12/2019 Chap-01 TCP
46/105
1 2 3 4 5 6 7 8 9 10 11 12 13
1 2 3 4 5 6 7 8 9 10 11 12 13
1 2 3 4 5 6 7 8 9 10 11 12 13
1 2 3 4 5 6 7 8 9 10 11 12 13
1 2 3 4 5 6 7 8 9 10 11 12 13
1
2
3
ACK 4
4
5
1 2 3 4 5 6 7 8 9 10 11 12 13
1 2 3 4 5 6 7 8 9 10 11 12 13
ACK 6
Window size = 6
1 2 3 4 5 6 7 8 9 10 11 12 13
7
6
9
8
1 2 3 4 5 6 7 8 9 10 11 12 13
1 2 3 4 5 6 7 8 9 10 11 12 13
1 2 3 4 5 6 7 8 9 10 11 12 13
1 2 3 4 5 6 7 8 9 10 11 12 13
-
8/12/2019 Chap-01 TCP
47/105
TCP/IP Protocol Suite 47
A sliding window is used to make
transmission more eff icient as well as
to control the flow of data so that thedestination does not become
overwhelmed with data.
TCPs sliding windows are byteoriented.
Note:
-
8/12/2019 Chap-01 TCP
48/105
Figure 1.21 Example 5
-
8/12/2019 Chap-01 TCP
49/105
TCP/IP Protocol Suite 49
g
Figure 1.22 Example 6
-
8/12/2019 Chap-01 TCP
50/105
TCP/IP Protocol Suite 50
Figure 1.23 Example 7
-
8/12/2019 Chap-01 TCP
51/105
TCP/IP Protocol Suite 51
Figure 1.24 Example 8
-
8/12/2019 Chap-01 TCP
52/105
TCP/IP Protocol Suite 52
SI LLYWINDOW SYNDROME by sender
-
8/12/2019 Chap-01 TCP
53/105
If the data is send byte by byte
For sending 1 byte of data 20 bytes of ipheader and 20 bytes of tcp header is usedtotal 41bytes for sending one byte of data
This reduces the efficiency of theoperation
Which indicates that we are using capacityof the network very inefficiently.
TCP/IP Protocol Suite 53
SI LLY WINDOW SYNDROME by sender
SI LLY WINDOW SYNDROME
-
8/12/2019 Chap-01 TCP
54/105
To overcome nagles algorithm wasintroduced
Send piece of data even of 1 byte
Now sender accumulates enough data to fill
maximum-size segment
Transmit full segment at end
TCP/IP Protocol Suite 54
SI LLY WINDOW SYNDROME
SI LLYWINDOW SYNDROME by receiver
-
8/12/2019 Chap-01 TCP
55/105
If the data is received byte by byte whenbuffer is full
Once data is filled in buffer and the bufferis full
Receiver sends zero window size
As soon as one byte is empty the it sendcurrent window 1
This leads to slow data consuming
TCP/IP Protocol Suite 55
SI LLY WINDOW SYNDROME by receiver
SI LLY WINDOW SYNDROME
-
8/12/2019 Chap-01 TCP
56/105
To overcome clarks solution wasintroduced
When buffer is full
Send ack as soon as data arrives but anounce
window size zero
Once the buffer has a space to accommodatea maximum size segment
Send the max window size
TCP/IP Protocol Suite 56
SI LLY WINDOW SYNDROME
SI LLY WINDOW SYNDROME
-
8/12/2019 Chap-01 TCP
57/105
To overcome delayed acknowledgementwas introduced
Delay the ack even if receiver receives data
But acknowledgement should not delay more
than 500 ms
TCP/IP Protocol Suite 57
SI LLY WINDOW SYNDROME
-
8/12/2019 Chap-01 TCP
58/105
TCP/IP Protocol Suite 58
To avoid shrinking the sender window,
the receiver must wait unti l more
space is available in its buffer.
Note:
-
8/12/2019 Chap-01 TCP
59/105
TCP/IP Protocol Suite 59
Some points about TCPs sliding windows:
The size of the window is the lesser of rwndand cwnd.
The source does not have to send a full windows
worth of data.The window can be opened or closed by the receiver,
but should not be shrunk.
The destination can send an acknowledgment at any
time as long as it does not result in a shrinking window.
The receiver can temporari ly shut down the window;
the sender, however, can always send a segment of one
byte after the window is shut down.
Note:
-
8/12/2019 Chap-01 TCP
60/105
TCP/IP Protocol Suite 60
1.7 ERROR CONTROL
TCP provides rel iabil i ty using error control, which detects corrupted,
lost, out-of-order, and duplicated segments. Error control in TCP is
achieved through the use of the checksum, acknowledgment, and time-
out.
The topics discussed in this section include:
Checksum
Acknowledgment
Acknowledgment Type
Retransmission
Out-of -Order SegmentsSome Scenar ios
-
8/12/2019 Chap-01 TCP
61/105
TCP/IP Protocol Suite 61
ACK segments do not consume
sequence numbers and are not
acknowledged.
Note:
-
8/12/2019 Chap-01 TCP
62/105
-
8/12/2019 Chap-01 TCP
63/105
TCP/IP Protocol Suite 63
No retransmission timer is set for an
ACK segment.
Note:
-
8/12/2019 Chap-01 TCP
64/105
TCP/IP Protocol Suite 64
Data may arr ive out of order and be
temporari ly stored by the receiving TCP,
but TCP guarantees that no out-of-order
segment is delivered to the process.
Note:
Figure 1.25 Normal operation
-
8/12/2019 Chap-01 TCP
65/105
TCP/IP Protocol Suite 65
Figure 1.26 Lost segment
-
8/12/2019 Chap-01 TCP
66/105
TCP/IP Protocol Suite 66
-
8/12/2019 Chap-01 TCP
67/105
TCP/IP Protocol Suite 67
The receiver TCP delivers onlyordered data to the process.
Note:
Figure 1.27 Fast retransmission
-
8/12/2019 Chap-01 TCP
68/105
TCP/IP Protocol Suite 68
Figure 1.28 Lost acknowledgment
-
8/12/2019 Chap-01 TCP
69/105
TCP/IP Protocol Suite 69
Figure 1.29 Lost acknowledgment corrected by resending a segment
-
8/12/2019 Chap-01 TCP
70/105
TCP/IP Protocol Suite 70
-
8/12/2019 Chap-01 TCP
71/105
TCP/IP Protocol Suite 71
Lost acknowledgments may create
deadlock if they are not proper ly
handled.
Note:
-
8/12/2019 Chap-01 TCP
72/105
Figure 1.30 Router queues
-
8/12/2019 Chap-01 TCP
73/105
TCP/IP Protocol Suite 73
Figure 1.31 Packet delay and network load
-
8/12/2019 Chap-01 TCP
74/105
TCP/IP Protocol Suite 74
Figure 1.32 Throughput versus network load
-
8/12/2019 Chap-01 TCP
75/105
TCP/IP Protocol Suite 75
Figure 1.33 Slow start, exponential i ncrease
-
8/12/2019 Chap-01 TCP
76/105
TCP/IP Protocol Suite 76
-
8/12/2019 Chap-01 TCP
77/105
Figure 1.34 Congestion avoidance, additive increase
-
8/12/2019 Chap-01 TCP
78/105
TCP/IP Protocol Suite 78
-
8/12/2019 Chap-01 TCP
79/105
TCP/IP Protocol Suite 79
I n the congestion avoidance algor ithm
the size of the congestion window
increases additively unti l
congestion is detected.
Note:
-
8/12/2019 Chap-01 TCP
80/105
TCP/IP Protocol Suite 80
Most implementations react differently to
congestion detection:
I f detection is by time-out, a new slow start phase
starts.
I f detection is by three ACKs, a new congestionavoidance phase star ts.
Note:
Figure 1.36 Congestion example
-
8/12/2019 Chap-01 TCP
81/105
TCP/IP Protocol Suite 81
-
8/12/2019 Chap-01 TCP
82/105
TCP/IP Protocol Suite 82
Tcp Session 2 cont..
1 9 TCP TIMERS
-
8/12/2019 Chap-01 TCP
83/105
TCP/IP Protocol Suite 83
1.9 TCP TIMERS
To perform i ts operation smoothly, most TCP implementations use at
least four timers.
The topics discussed in this section include:
Retransmission Timer
Persistence TimerKeepali ve Timer
TIME-WAI T Timer
Figure 1.37 TCP timers
-
8/12/2019 Chap-01 TCP
84/105
TCP/IP Protocol Suite 84
Retransmission timer
-
8/12/2019 Chap-01 TCP
85/105
Retransmission timer
If the ack is received before timer goes offtimer is destroyed
If the ack is not received and timer goes
off the segment is resent
Calculation of retransmission time Retransmission time = 2 X RTT
RTT = 90% X previous RTT + 10% X current RTT Eg RTT = 0.9 X 100 + 0.1 X 80 = 98microsec
TCP/IP Protocol Suite 85
Persistence timer
-
8/12/2019 Chap-01 TCP
86/105
Persistence timer
It deals with zero window size When an sender tcp receives zero window
size its starts persistence timer
When persistence timer goes off Sender sends special segment called
probewhich contains 1 byte of data
This probe alerts the sender and senderresends the ack
TCP/IP Protocol Suite 86
Keep alive timer
-
8/12/2019 Chap-01 TCP
87/105
Keep alive timer
Keep alive timer is used to prevent long idleconnection
Widen communication client suddenly stayssilent(clients system shutdown)
Time out is usually of 2 hours If client doesnt respond witen 2 hours
Server sends probe segment to client
If there is no response after 10 probes Server terminates the connection
TCP/IP Protocol Suite 87
-
8/12/2019 Chap-01 TCP
88/105
-
8/12/2019 Chap-01 TCP
89/105
TCP/IP Protocol Suite 89
I n TCP, there can be only be one RTT
measurement in progress at any time.
Note:
-
8/12/2019 Chap-01 TCP
90/105
TCP/IP Protocol Suite 90
TCP does not consider the RTT of a
retransmitted segment in its
calculation of a new RTO.
Note:
1 10 OPTIONS
-
8/12/2019 Chap-01 TCP
91/105
TCP/IP Protocol Suite 91
1.10 OPTIONS
The TCP header can have up to 40 bytes of optional information.
Options convey additional information to the destination or align other
options.
Figure 1.40 Options
-
8/12/2019 Chap-01 TCP
92/105
TCP/IP Protocol Suite 92
Figure 1.41 End-of-option option
-
8/12/2019 Chap-01 TCP
93/105
TCP/IP Protocol Suite 93
-
8/12/2019 Chap-01 TCP
94/105
TCP/IP Protocol Suite 94
EOP can be used only once.
Note:
Figure 1.42 No-operation option
-
8/12/2019 Chap-01 TCP
95/105
TCP/IP Protocol Suite 95
-
8/12/2019 Chap-01 TCP
96/105
TCP/IP Protocol Suite 96
NOP can be used more than once.
Note:
Figure 1.43 Maximum-segment-size option
-
8/12/2019 Chap-01 TCP
97/105
TCP/IP Protocol Suite 97
-
8/12/2019 Chap-01 TCP
98/105
TCP/IP Protocol Suite 98
The value of MSS is determined
dur ing connection establ ishment and
does not change dur ing the
connection.
Note:
-
8/12/2019 Chap-01 TCP
99/105
-
8/12/2019 Chap-01 TCP
100/105
TCP/IP Protocol Suite 100
The value of the window scale factor
can be determined only dur ing
connection establishment; it does not
change dur ing the connection.
Note:
Figure 1.45 Timestamp option
-
8/12/2019 Chap-01 TCP
101/105
TCP/IP Protocol Suite 101
-
8/12/2019 Chap-01 TCP
102/105
TCP/IP Protocol Suite 102
One application of the timestamp
option is the calculation of round tr ip
time (RTT).
Note:
1.11 TCP PACKAGE
-
8/12/2019 Chap-01 TCP
103/105
TCP/IP Protocol Suite 103
We present a simpl if ied, bare-bones TCP package to simulate the heart of
TCP. The package involves tables call ed transmission control blocks, a
set of timers, and three software modules.
The topics discussed in this section include:
Transmission Control Blocks (TCBs)
TimersMain M odule
I nput Processing Module
Output Processing Module
-
8/12/2019 Chap-01 TCP
104/105
Figure 1.52 TCBs
-
8/12/2019 Chap-01 TCP
105/105
top related