TCPIntroduction
Download
Report
Transcript TCPIntroduction
TCP : Transmission Control Protocol
( Stevens TCP/ IP Illustrated Volume 1)
Chapter 17 and 18:
• TCP is connection oriented
• Unit of information passed by TCP to IP is a segment
• A segment is retransmitted if an acknowledgement is not received within
ticks of a timer
• TCP upon receipt of data sends an ACK. Normally does not send this
ACK immediately
• TCP reorders out of order data
• TCP uses flow control
1
TCP Connection Establishment And Termination
[ Fig 18.3]
Use “tcpdump” to obtain data for this
• Clint sends a SYN with initial sequence number
Notation 1415531521:1415531521 (0)
Number of Bytes sent
Starting
Sequence
Number
Starting Sequence
Number Plus
Number of Bytes Sent
• Server responds with SYN
• Client ACK the SYN from server
• This is 3 way handshake.
It takes four segments to terminate and is called “ Half Close”
2
3
TCP Header :
Bit 0
4
10
31 ( 32 Bits)
15
SOURCE PORT
DESTINATION PORT
SEQUENCE NUMBER
ACKNOWLEDGEMENT NUMBER
HEADER
LENGTH
UNUSED
U A
R C
G K
P R S
S S Y
H T N
CHECKSUM
OPTIONS +
F
I
N
WINDOW
URGENT POINTER
PADDING
4
• Maximum segment size (MSS) is largest amount of data each TCP sender is
willing to receive
• Advertised by each end and can be different in different directions. It is not “negotiated.”
• If no MSS sent default 536 is used
• For ethernet 1460 bytes is the MSS.
[ Fig 18.12 and 18.13] State Diagram Of TCP
• When TCP active close occurs and sends final Ack, connection stays in Time-Wait state
for twice maximum segment lifetime (MSS) value.
1. In case must resend final ACK
2. In case attempt to reuse IP address and port again while old segments may still
be in network.
• Reset segment RST is sent when error occurs.
5
6
7
TCP Interactive Flow
(TCP/IP Vol. 1, Stevens Chapter 19)
- Look at flow of data for rlogin connection which is a TCP application.
- Each keystroke generates a data packet.
[ Fig 19.1]
- Modified TCP dump output for session with five characters date\n (connection
establishment not shown in Fig 19.2).
[ Fig 19.2 ]
[ Fig 19.3 ]
Time Line For Fig 19.2, much easier to follow
- ACK can be sent along with next data going in same direction called ACK piggyback.
- ACK usually wait up to 200 ms delay to see if must travel alone or get to piggyback.
- Notation in Fig 19.2/19.3 0:1(1) means sent (1) data byte with sequence number 0.
The next starting sequence number will be 1.
8
9
10
11
12
To prevent lots of very small data segments in a network:
Nagle Algorithm (For the sending TCP algorithm)
1.
The sending TCP sends the (small) data even if it is only one byte.
2.
After sending the first data segment, sending TCP accumulates data until receiver
sends an ACK or until data accumulated is an MSS. At this point sender can send
data.
3.
Repeat step two for remainder of transmission.
This algorithm causes a fast application program on a slow network to
accumulate and send larger (mss) segments. A slow application program on a fast
network will send less than mss.
There are situations like x window mouse where small mouse movements need to
immediately be sent, in that case would not want to use Nagle since want to
sendsmall size data immediately.
Fig [19.5-19.8]
13
14
15
16
17
18
TCP Bulk Data Flow
Chapter 20
Normal Data Flow Example Transfer of 8192 bytes of data from srv4 to bsdi
[Fig 20.1] Warning: This example appears to not use slow start (discussed later).
- Sender transmits 3 data segments (4-6)
- Next segment (7) acknowledges the first two data segments only. This is because of the following:
- When TCP processes segment 4 the connection is marked to generate a delayed ACK
- When segment 5 arrives TCP has two outstanding segments and immediately acknowledges.
* TCP Immediately ACK's two outstanding segments.
- Next segment (8) ACK's the third data segment due to ACK acknowledgement timer reaching a
“ 200 ms Interval”.
- Window of only 3072 advertised since 1024 bytes of data still in TCP receive buffer
- In TCP ACK's are cumulative. They acknowledge receipt of up through ACK sequence number
minus one.
Note in Fig. 20.1 that the FIN segment has no data and is 8193:8193(0). The ACK for this is an
ACK8194 which is one more than the last data. This is always true. A FIN uses up one ACK number.
19
20
21
Another Normal Data Flow Example:
[Fig 20.2] Same as before but data sent a bit different.
Warning: This example appears to not use slow start (discussed later).
Fast Sender, Slow Receiver Example:
[Fig 20.3] Warning: This example appears to not use slow start (discussed later).
- Sender transmits four back-to-back data segments (4-7) to fill receivers window.
- Receiver sends ACK but with advertised window 0. Application has not yet read
data
- Another ACK called a window update is sent later announcing some room at the
Inn.
Warning: Fig 20.3 does not follow the ack no more than every other segment rule.
22
23
24
25
26