SlideShare a Scribd company logo
1 of 115
Chapter 12 
Transmission 
Control Protocol 
Objectives 
Upon completion you will be able to: 
• Be able to name and understand the services offered by TCP 
• Understand TCP’s flow and error control and congestion control 
• Be familiar with the fields in a TCP segment 
• Understand 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 familiar with the TCP options 
TCP/IP Protocol Suite 1
Figure 12.1 TCP/IP protocol suite 
TCP/IP Protocol Suite 2
12.1 TCP SERVICES 
We explain the services offered by TCP to the processes at the application 
layer. 
The topics discussed in this section include: 
Process-to-Process Communication 
Stream Delivery Service 
Full-Duplex Communication 
Connection-Oriented Service 
Reliable Service 
TCP/IP Protocol Suite 3
Table 12.1 Well-known ports used by TCP 
TCP/IP Protocol Suite 4
Example 1 
As we said in Chapter 11, in UNIX, the well-known ports are 
stored in a file called /etc/services. Each line in this file gives 
the name of the server and the well-known port number. We 
can use the grep utility to extract the line corresponding to the 
desired application. The following shows the ports for FTP. 
$ grep ftp /etc/services 
ftp-data 20/tcp 
ftp-control 21/tcp 
TCP/IP Protocol Suite 5
Figure 12.2 Stream delivery 
TCP/IP Protocol Suite 6
Figure 12.3 Sending and receiving buffers 
TCP/IP Protocol Suite 7
Figure 12.4 TCP segments 
TCP/IP Protocol Suite 8
12.2 TCP FEATURES 
To provide the services mentioned in the previous section, TCP has 
several features that are briefly summarized in this section. 
The topics discussed in this section include: 
Numbering System 
Flow Control 
Error Control 
Congestion Control 
TCP/IP Protocol Suite 9
Note: 
The bytes of data being transferred in 
each connection are numbered by TCP. 
The numbering starts with a randomly 
generated number. 
TCP/IP Protocol Suite 10
Example 2 
Suppose a TCP connection is transferring a file of 5000 bytes. 
The first byte is numbered 10001. What are the sequence 
numbers for each segment if data is sent in five segments, each 
carrying 1000 bytes? 
Solution 
The 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) 
TCP/IP Protocol Suite 11
Note: 
The value in the sequence number 
field of a segment defines the number 
of the first data byte contained 
in that segment. 
TCP/IP Protocol Suite 12
Note: 
The value of the acknowledgment field 
in a segment defines the number of the 
next byte a party expects to receive. 
The acknowledgment number is 
cumulative. 
TCP/IP Protocol Suite 13
12.3 SEGMENT 
A packet in TCP is called a segment 
The topics discussed in this section include: 
Format 
Encapsulation 
TCP/IP Protocol Suite 14
Figure 12.5 TCP segment format 
TCP/IP Protocol Suite 15
Figure 12.6 Control field 
TCP/IP Protocol Suite 16
Table 12.2 Description of flags in the control field 
I 
TCP/IP Protocol Suite 17
Figure 12.7 Pseudoheader added to the TCP datagram 
TCP/IP Protocol Suite 18
Note: 
The inclusion of the checksum in TCP 
is mandatory. 
TCP/IP Protocol Suite 19
Figure 12.8 Encapsulation and decapsulation 
TCP/IP Protocol Suite 20
12.4 A TCP CONNECTION 
TCP is connection-oriented. A connection-oriented transport protocol 
establishes a virtual path between the source and destination. All of the 
segments belonging to a message are then sent over this virtual 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 
TCP/IP Protocol Suite 21
Figure 12.9 Connection establishment using three-way handshaking 
TCP/IP Protocol Suite 22
Note: 
A SYN segment cannot carry data, but 
it consumes one sequence number. 
TCP/IP Protocol Suite 23
Note: 
A SYN + ACK segment cannot carry 
data, but does consume one 
sequence number. 
TCP/IP Protocol Suite 24
Note: 
An ACK segment, if carrying no data, 
consumes no sequence number. 
TCP/IP Protocol Suite 25
Figure 12.10 Data transfer 
TCP/IP Protocol Suite 26
Note: 
The FIN segment consumes one 
sequence number if it does not carry 
data. 
TCP/IP Protocol Suite 27
Figure 12.11 Connection termination using three-way handshaking 
TCP/IP Protocol Suite 28
Note: 
The FIN + ACK segment consumes 
one sequence number if it does not 
carry data. 
TCP/IP Protocol Suite 29
Figure 12.12 Half-close 
TCP/IP Protocol Suite 30
12.5 STATE TRANSITION DIAGRAM 
To keep track of all the different events happening during connection 
establishment, connection termination, and data transfer, the TCP 
software is implemented as a finite state machine. . 
The topics discussed in this section include: 
Scenarios 
TCP/IP Protocol Suite 31
Table 12.3 States for TCP 
TCP/IP Protocol Suite 32
Figure 12.13 State transition diagram 
TCP/IP Protocol Suite 33
Figure 12.14 Common scenario 
TCP/IP Protocol Suite 34
Note: 
The common value for MSL is 
between 30 seconds and 1 minute. 
TCP/IP Protocol Suite 35
Figure 12.15 Three-way handshake 
TCP/IP Protocol Suite 36
Figure 12.16 Simultaneous open 
TCP/IP Protocol Suite 37
Figure 12.17 Simultaneous close 
TCP/IP Protocol Suite 38
Figure 12.18 Denying a connection 
TCP/IP Protocol Suite 39
Figure 12.19 Aborting a connection 
TCP/IP Protocol Suite 40
12.6 FLOW CONTROL 
Flow control regulates the amount of data a source can send before 
receiving 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 
Silly Window Syndrome 
TCP/IP Protocol Suite 41
Figure 12.20 Sliding window 
TCP/IP Protocol Suite 42
Note: 
A sliding window is used to make 
transmission more efficient as well as 
to control the flow of data so that the 
destination does not become 
overwhelmed with data. 
TCP’s sliding windows are byte 
oriented. 
TCP/IP Protocol Suite 43
Example 3 
What is the value of the receiver window (rwnd) for host A if 
the receiver, host B, has a buffer size of 5,000 bytes and 1,000 
bytes of received and unprocessed data? 
Solution 
The value of rwnd = 5,000 − 1,000 = 4,000. Host B can receive 
only 4,000 bytes of data before overflowing its buffer. Host B 
advertises this value in its next segment to A. 
TCP/IP Protocol Suite 44
Example 4 
What is the size of the window for host A if the value of rwnd is 
3,000 bytes and the value of cwnd is 3,500 bytes? 
Solution 
The size of the window is the smaller of rwnd and cwnd, which 
is 3,000 bytes. 
TCP/IP Protocol Suite 45
Example 5 
Figure 12.21 shows an unrealistic example of a sliding 
window. The sender has sent bytes up to 202. We assume that 
cwnd is 20 (in reality this value is thousands of bytes). The 
receiver has sent an acknowledgment number of 200 with an 
rwnd of 9 bytes (in reality this value is thousands of bytes). The 
size of the sender window is the minimum of rwnd and cwnd or 
9 bytes. Bytes 200 to 202 are sent, but not acknowledged. Bytes 
203 to 208 can be sent without worrying about 
acknowledgment. Bytes 209 and above cannot be sent. 
TCP/IP Protocol Suite 46
Figure 12.21 Example 5 
TCP/IP Protocol Suite 47
Example 6 
In Figure 12.21 the server receives a packet with an 
acknowledgment value of 202 and an rwnd of 9. The host has 
already sent bytes 203, 204, and 205. The value of cwnd is still 
20. Show the new window. 
Solution 
Figure 12.22 shows the new window. Note that this is a case in 
which the window closes from the left and opens from the right 
by an equal number of bytes; the size of the window has not 
been changed. The acknowledgment value, 202, declares that 
bytes 200 and 201 have been received and the sender needs not 
worry about them; the window can slide over them. 
TCP/IP Protocol Suite 48
Figure 12.22 Example 6 
TCP/IP Protocol Suite 49
Example 7 
In Figure 12.22 the sender receives a packet with an 
acknowledgment value of 206 and an rwnd of 12. The host has 
not sent any new bytes. The value of cwnd is still 20. Show the 
new window. 
Solution 
The value of rwnd is less than cwnd, so the size of the window 
is 12. Figure 12.23 shows the new window. Note that the 
window has been opened from the right by 7 and closed from 
the left by 4; the size of the window has increased. 
TCP/IP Protocol Suite 50
Figure 12.23 Example 7 
TCP/IP Protocol Suite 51
Example 8 
In Figure 12.23 the host receives a packet with an 
acknowledgment value of 210 and an rwnd of 5. The host has 
sent bytes 206, 207, 208, and 209. The value of cwnd is still 20. 
Show the new window. 
Solution 
The value of rwnd is less than cwnd, so the size of the window 
is 5. Figure 12.24 shows the situation. Note that this is a case 
not allowed by most implementations. Although the sender has 
not sent bytes 215 to 217, the receiver does not know this. 
TCP/IP Protocol Suite 52
Figure 12.24 Example 8 
TCP/IP Protocol Suite 53
Example 9 
How can the receiver avoid shrinking the window in the 
previous example? 
Solution 
The receiver needs to keep track of the last acknowledgment 
number and the last rwnd. If we add the acknowledgment 
number to rwnd we get the byte number following the right 
wall. If we want to prevent the right wall from moving to the 
left (shrinking), we must always have the following 
relationship. 
new ack + new rwnd ≥ last ack + last rwnd 
or 
new rwnd ≥ (last ack + last rwnd) − new ack 
TCP/IP Protocol Suite 54
Note: 
To avoid shrinking the sender window, 
the receiver must wait until more 
space is available in its buffer. 
TCP/IP Protocol Suite 55
Note: 
Some points about TCP’s sliding windows: 
❏ The size of the window is the lesser of rwnd and cwnd. 
❏ The source does not have to send a full window’s 
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 temporarily shut down the window; 
the sender, however, can always send a segment of one 
byte after the window is shut down. 
TCP/IP Protocol Suite 56
12.7 ERROR CONTROL 
TCP provides reliability 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 Segments 
Some Scenarios 
TCP/IP Protocol Suite 57
Note: 
ACK segments do not consume 
sequence numbers and are not 
acknowledged. 
TCP/IP Protocol Suite 58
Note: 
In modern implementations, a 
retransmission occurs if the 
retransmission timer expires or three 
duplicate ACK segments have arrived. 
TCP/IP Protocol Suite 59
Note: 
No retransmission timer is set for an 
ACK segment. 
TCP/IP Protocol Suite 60
Note: 
Data may arrive out of order and be 
temporarily stored by the receiving TCP, 
but TCP guarantees that no out-of-order 
segment is delivered to the process. 
TCP/IP Protocol Suite 61
Figure 12.25 Normal operation 
TCP/IP Protocol Suite 62
Figure 12.26 Lost segment 
TCP/IP Protocol Suite 63
Note: 
The receiver TCP delivers only 
ordered data to the process. 
TCP/IP Protocol Suite 64
Figure 12.27 Fast retransmission 
TCP/IP Protocol Suite 65
Figure 12.28 Lost acknowledgment 
TCP/IP Protocol Suite 66
Figure 12.29 Lost acknowledgment corrected by resending a segment 
TCP/IP Protocol Suite 67
Note: 
Lost acknowledgments may create 
deadlock if they are not properly 
handled. 
TCP/IP Protocol Suite 68
12.8 CONGESTION CONTROL 
Congestion control refers to the mechanisms and techniques to keep the 
load below the capacity. 
The topics discussed in this section include: 
Network Performance 
Congestion Control Mechanisms 
Congestion Control in TCP 
TCP/IP Protocol Suite 69
Figure 12.30 Router queues 
TCP/IP Protocol Suite 70
Figure 12.31 Packet delay and network load 
TCP/IP Protocol Suite 71
Figure 12.32 Throughput versus network load 
TCP/IP Protocol Suite 72
Figure 12.33 Slow start, exponential increase 
TCP/IP Protocol Suite 73
Note: 
In the slow start algorithm, the size of 
the congestion window increases 
exponentially until it reaches a 
threshold. 
TCP/IP Protocol Suite 74
Figure 12.34 Congestion avoidance, additive increase 
TCP/IP Protocol Suite 75
Note: 
In the congestion avoidance algorithm 
the size of the congestion window 
increases additively until 
congestion is detected. 
TCP/IP Protocol Suite 76
Note: 
Most implementations react differently to 
congestion detection: 
❏ If detection is by time-out, a new slow start phase 
starts. 
❏ If detection is by three ACKs, a new congestion 
avoidance phase starts. 
TCP/IP Protocol Suite 77
Figure 12.35 TCP congestion policy summary 
TCP/IP Protocol Suite 78
Figure 12.36 Congestion example 
TCP/IP Protocol Suite 79
12.9 TCP TIMERS 
To perform its operation smoothly, most TCP implementations use at 
least four timers. 
The topics discussed in this section include: 
Retransmission Timer 
Persistence Timer 
Keepalive Timer 
TIME-WAIT Timer 
TCP/IP Protocol Suite 80
Figure 12.37 TCP timers 
TCP/IP Protocol Suite 81
Note: 
In TCP, there can be only be one RTT 
measurement in progress at any time. 
TCP/IP Protocol Suite 82
Example 10 
Let us give a hypothetical example. Figure 12.38 shows part of 
a connection. The figure shows the connection establishment 
and part of the data transfer phases. 
1. When the SYN segment is sent, there is no value for RTTM , RTTS , or 
RTTD . The value of RTO is set to 6.00 seconds. The following shows the 
value of these variables at this moment: 
RTTM = 1.5 RTTS = 1.5 
RTTD = 1.5 / 2 = 0.75 RTO = 1.5 + 4 . 0.75 = 4.5 
2. When the SYN+ACK segment arrives, RTTM is measured and is equal to 
1.5 seconds. The next slide shows the values of these variables: 
TCP/IP Protocol Suite 83
Example 10 (continued) 
RTTM = 1.5 RTTS = 1.5 
RTTD = 1.5 / 2 = 0.75 RTO = 1.5 + 4 . 0.75 = 4.5 
3.When the first data segment is sent, a new RTT measurement 
starts. Note that the sender does not start an RTT measurement 
when it sends the ACK segment, because it does not consume a 
sequence number and there is no time-out. No RTT 
measurement starts for the second data segment because a 
measurement is already in progress. 
RTTM = 2.5 
RTTS = 7/8 (1.5) + 1/8 (2.5) = 1.625 
RTTD = 3/4 (7.5) + 1/4 |1.625 − 2.5| = 0.78 
RTO = 1.625 + 4 (0.78) = 4.74 
TCP/IP Protocol Suite 84
Figure 12.38 Example 10 
TCP/IP Protocol Suite 85
Note: 
TCP does not consider the RTT of a 
retransmitted segment in its 
calculation of a new RTO. 
TCP/IP Protocol Suite 86
Example 11 
Figure 12.39 is a continuation of the previous example. There 
is retransmission and Karn’s algorithm is applied. The first 
segment in the figure is sent, but lost. The RTO timer expires 
after 4.74 seconds. The segment is retransmitted and the timer 
is set to 9.48, twice the previous value of RTO. This time an 
ACK is received before the time-out. We wait until we send a 
new segment and receive the ACK for it before recalculating 
the RTO (Karn’s algorithm). 
TCP/IP Protocol Suite 87
Figure 12.39 Example 11 
TCP/IP Protocol Suite 88
12.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. 
TCP/IP Protocol Suite 89
Figure 12.40 Options 
TCP/IP Protocol Suite 90
Figure 12.41 End-of-option option 
TCP/IP Protocol Suite 91
Note: 
EOP can be used only once. 
TCP/IP Protocol Suite 92
Figure 12.42 No-operation option 
TCP/IP Protocol Suite 93
Note: 
NOP can be used more than once. 
TCP/IP Protocol Suite 94
Figure 12.43 Maximum-segment-size option 
TCP/IP Protocol Suite 95
Note: 
The value of MSS is determined 
during connection establishment and 
does not change during the 
connection. 
TCP/IP Protocol Suite 96
Figure 12.44 Window-scale-factor option 
TCP/IP Protocol Suite 97
Note: 
The value of the window scale factor 
can be determined only during 
connection establishment; it does not 
change during the connection. 
TCP/IP Protocol Suite 98
Figure 12.45 Timestamp option 
TCP/IP Protocol Suite 99
Note: 
One application of the timestamp 
option is the calculation of round trip 
time (RTT). 
TCP/IP Protocol Suite 100
Example 12 
Figure 12.46 shows an example that calculates the round-trip 
time for one end. Everything must be flipped if we want to 
calculate the RTT for the other end. 
The sender simply inserts the value of the clock (for example, 
the number of seconds past from midnight) in the timestamp 
field for the first and second segment. When an 
acknowledgment comes (the third segment), the value of the 
clock is checked and the value of the echo reply field is 
subtracted from the current time. RTT is 12 s in this scenario. 
TCP/IP Protocol Suite 101
Example 12 (Continued) 
The receiver’s function is more involved. It keeps track of the 
last acknowledgment sent (12000). When the first segment 
arrives, it contains the bytes 12000 to 12099. The first byte is 
the same as the value of lastack. It then copies the timestamp 
value (4720) into the tsrecent variable. The value of lastack is 
still 12000 (no new acknowledgment has been sent). When the 
second segment arrives, since none of the byte numbers in this 
segment include the value of lastack, the value of the 
timestamp field is ignored. When the receiver decides to send 
an accumulative acknowledgment with acknowledgment 
12200, it changes the value of lastack to 12200 and inserts the 
value of tsrecent in the echo reply field. The value of tsrecent 
will not change until it isreplaced by a new segment that 
carries byte 12200 (next segment). 
TCP/IP Protocol Suite 102
Example 12 (Continued) 
Note that as the example shows, the RTT calculated is the time 
difference between sending the first segment and receiving the 
third segment. This is actually the meaning of RTT: the time 
difference between a packet sent and the acknowledgment 
received. The third segment carries the acknowledgment for 
the first and second segments. 
TCP/IP Protocol Suite 103
Figure 12.46 Example 12 
TCP/IP Protocol Suite 104
Note: 
The timestamp option can also be used 
for PAWS. 
TCP/IP Protocol Suite 105
Figure 12.47 SACK 
TCP/IP Protocol Suite 106
Example 13 
Let us see how the SACK option is used to list out-of-order blocks. In 
Figure 12.48 an end has received five segments of data. 
The first and second segments are in consecutive order. An accumulative 
acknowledgment can be sent to report the reception of these two segments. 
Segments 3, 4, and 5, however, are out of order with a gap between the 
second and third and a gap between the fourth and the fifth. An ACK and a 
SACK together can easily clear the situation for the sender. The value of 
ACK is2001, which means that the sender need not worry about bytes 1 to 
2000. The SACK has two blocks. The first block announces that bytes 4001 
to 6000 have arrived out of order. The second block shows that bytes 8001 to 
9000 have also arrived out of order. This means that bytes 2001 to 4000 and 
bytes 6001 to 8000 are lost or discarded. The sender can resend only these 
bytes. 
TCP/IP Protocol Suite 107
Figure 12.48 Example 13 
TCP/IP Protocol Suite 108
Example 14 
The example in Figure 12.49 shows how a duplicate segment 
can be detected with a combination of ACK and SACK. In this 
case, we have some out-of-order segments (in one block) and 
one duplicate segment. To show both out-of-order and 
duplicate data, SACK uses the first block, in this case, to show 
the duplicate data and other blocks to show out-of-order data. 
Note that only the first block can be used for duplicate data. 
The natural question is how the sender, when it receives these 
ACK and SACK values knows that the first block is for 
duplicate data (compare this example with the previous 
example). The answer is that the bytes in the first block are 
already acknowledged in the ACK field; therefore, this block 
must be a duplicate. 
TCP/IP Protocol Suite 109
Figure 12.49 Example 14 
TCP/IP Protocol Suite 110
Example 15 
The example in Figure 12.50 shows what happens if one of the 
segments in the out-of-order section is also duplicated. In this 
example, one of the segments (4001:5000) is duplicated. The 
SACK option announces this duplicate data first and then the 
out-of-order block. This time, however, the duplicated block is 
not yet acknowledged by ACK, but because it is part of the out-of- 
order block (4001:5000 is part of 4001:6000), it is 
understood by the sender that it defines the duplicate data. 
TCP/IP Protocol Suite 111
Figure 12.50 Example 15 
TCP/IP Protocol Suite 112
12.11 TCP PACKAGE 
We present a simplified, bare-bones TCP package to simulate the heart of 
TCP. The package involves tables called transmission control blocks, a 
set of timers, and three software modules. 
The topics discussed in this section include: 
Transmission Control Blocks (TCBs) 
Timers 
Main Module 
Input Processing Module 
Output Processing Module 
TCP/IP Protocol Suite 113
Figure 12.51 TCP package 
TCP/IP Protocol Suite 114
Figure 12.52 TCBs 
TCP/IP Protocol Suite 115

More Related Content

What's hot

TCP- Transmission Control Protocol
TCP-  Transmission Control Protocol TCP-  Transmission Control Protocol
TCP- Transmission Control Protocol Akhil .B
 
System models in distributed system
System models in distributed systemSystem models in distributed system
System models in distributed systemishapadhy
 
UDP - User Datagram Protocol
UDP - User Datagram ProtocolUDP - User Datagram Protocol
UDP - User Datagram ProtocolPeter R. Egli
 
Congestion control
Congestion controlCongestion control
Congestion controlAman Jaiswal
 
Congestion control
Congestion controlCongestion control
Congestion controlNithin Raj
 
TCP/IP 3-way Handshake
TCP/IP 3-way Handshake TCP/IP 3-way Handshake
TCP/IP 3-way Handshake Alok Tripathi
 
TCP & UDP ( Transmission Control Protocol and User Datagram Protocol)
TCP & UDP ( Transmission Control Protocol and User Datagram Protocol)TCP & UDP ( Transmission Control Protocol and User Datagram Protocol)
TCP & UDP ( Transmission Control Protocol and User Datagram Protocol)Kruti Niranjan
 
Group Communication (Distributed computing)
Group Communication (Distributed computing)Group Communication (Distributed computing)
Group Communication (Distributed computing)Sri Prasanna
 
Socket Programming
Socket ProgrammingSocket Programming
Socket ProgrammingCEC Landran
 
TCP-IP Reference Model
TCP-IP Reference ModelTCP-IP Reference Model
TCP-IP Reference ModelMukesh Tekwani
 
Secure Socket Layer
Secure Socket LayerSecure Socket Layer
Secure Socket LayerNaveen Kumar
 
Chapter 4 data link layer
Chapter 4 data link layerChapter 4 data link layer
Chapter 4 data link layerNaiyan Noor
 
TCP - Transmission Control Protocol
TCP - Transmission Control ProtocolTCP - Transmission Control Protocol
TCP - Transmission Control ProtocolPeter R. Egli
 
Routing algorithm
Routing algorithmRouting algorithm
Routing algorithmBushra M
 

What's hot (20)

TCP- Transmission Control Protocol
TCP-  Transmission Control Protocol TCP-  Transmission Control Protocol
TCP- Transmission Control Protocol
 
TCP and UDP
TCP and UDP TCP and UDP
TCP and UDP
 
System models in distributed system
System models in distributed systemSystem models in distributed system
System models in distributed system
 
UDP - User Datagram Protocol
UDP - User Datagram ProtocolUDP - User Datagram Protocol
UDP - User Datagram Protocol
 
Congestion control
Congestion controlCongestion control
Congestion control
 
Congestion control
Congestion controlCongestion control
Congestion control
 
TCP/IP 3-way Handshake
TCP/IP 3-way Handshake TCP/IP 3-way Handshake
TCP/IP 3-way Handshake
 
TCP & UDP ( Transmission Control Protocol and User Datagram Protocol)
TCP & UDP ( Transmission Control Protocol and User Datagram Protocol)TCP & UDP ( Transmission Control Protocol and User Datagram Protocol)
TCP & UDP ( Transmission Control Protocol and User Datagram Protocol)
 
Group Communication (Distributed computing)
Group Communication (Distributed computing)Group Communication (Distributed computing)
Group Communication (Distributed computing)
 
Socket Programming
Socket ProgrammingSocket Programming
Socket Programming
 
Network layer tanenbaum
Network layer tanenbaumNetwork layer tanenbaum
Network layer tanenbaum
 
TCP-IP Reference Model
TCP-IP Reference ModelTCP-IP Reference Model
TCP-IP Reference Model
 
Datalinklayer tanenbaum
Datalinklayer tanenbaumDatalinklayer tanenbaum
Datalinklayer tanenbaum
 
Application Layer
Application LayerApplication Layer
Application Layer
 
Secure Socket Layer
Secure Socket LayerSecure Socket Layer
Secure Socket Layer
 
Data link layer
Data link layerData link layer
Data link layer
 
Message passing in Distributed Computing Systems
Message passing in Distributed Computing SystemsMessage passing in Distributed Computing Systems
Message passing in Distributed Computing Systems
 
Chapter 4 data link layer
Chapter 4 data link layerChapter 4 data link layer
Chapter 4 data link layer
 
TCP - Transmission Control Protocol
TCP - Transmission Control ProtocolTCP - Transmission Control Protocol
TCP - Transmission Control Protocol
 
Routing algorithm
Routing algorithmRouting algorithm
Routing algorithm
 

Viewers also liked

Viewers also liked (20)

Tcp and udp
Tcp and udpTcp and udp
Tcp and udp
 
Ch23
Ch23Ch23
Ch23
 
Tcp udp
Tcp udpTcp udp
Tcp udp
 
Sliding window and error control
Sliding window and error controlSliding window and error control
Sliding window and error control
 
Chap 11 udp
Chap 11 udpChap 11 udp
Chap 11 udp
 
Rfc768
Rfc768Rfc768
Rfc768
 
Ch24
Ch24Ch24
Ch24
 
Chap 14 rip, ospf
Chap 14 rip, ospfChap 14 rip, ospf
Chap 14 rip, ospf
 
Chap 17 dns
Chap 17 dnsChap 17 dns
Chap 17 dns
 
XPDS13: On Paravirualizing TCP - Congestion Control on Xen VMs - Luwei Cheng,...
XPDS13: On Paravirualizing TCP - Congestion Control on Xen VMs - Luwei Cheng,...XPDS13: On Paravirualizing TCP - Congestion Control on Xen VMs - Luwei Cheng,...
XPDS13: On Paravirualizing TCP - Congestion Control on Xen VMs - Luwei Cheng,...
 
Chap 12 tcp
Chap 12 tcpChap 12 tcp
Chap 12 tcp
 
Chap 08 ip
Chap 08 ipChap 08 ip
Chap 08 ip
 
Fellow Developers, Let's Discover Your Superpower
Fellow Developers, Let's Discover Your SuperpowerFellow Developers, Let's Discover Your Superpower
Fellow Developers, Let's Discover Your Superpower
 
Mobile Programming - 3 UDP
Mobile Programming - 3 UDPMobile Programming - 3 UDP
Mobile Programming - 3 UDP
 
Ch 22
Ch 22Ch 22
Ch 22
 
Chap 28 security
Chap 28 securityChap 28 security
Chap 28 security
 
User Datagram protocol For Msc CS
User Datagram protocol For Msc CSUser Datagram protocol For Msc CS
User Datagram protocol For Msc CS
 
Unit III IPV6 UDP
Unit III IPV6 UDPUnit III IPV6 UDP
Unit III IPV6 UDP
 
Chapter 11
Chapter 11Chapter 11
Chapter 11
 
Iphone programming: Objective c
Iphone programming: Objective cIphone programming: Objective c
Iphone programming: Objective c
 

Similar to Chap 12 tcp (20)

Transportlayer.ppt
Transportlayer.pptTransportlayer.ppt
Transportlayer.ppt
 
20CS2007 Computer Communication Networks
20CS2007 Computer Communication Networks 20CS2007 Computer Communication Networks
20CS2007 Computer Communication Networks
 
Ch12
Ch12Ch12
Ch12
 
Chap-13.ppt
Chap-13.pptChap-13.ppt
Chap-13.ppt
 
TransportLayerServices.ppt
TransportLayerServices.pptTransportLayerServices.ppt
TransportLayerServices.ppt
 
Internet technology unit 3
Internet technology unit 3Internet technology unit 3
Internet technology unit 3
 
unit 3 ns.ppt
unit 3 ns.pptunit 3 ns.ppt
unit 3 ns.ppt
 
UNIT IV-Transport Layer.pptx
UNIT IV-Transport Layer.pptxUNIT IV-Transport Layer.pptx
UNIT IV-Transport Layer.pptx
 
IGMP.ppt
IGMP.pptIGMP.ppt
IGMP.ppt
 
Chapter 23
Chapter 23Chapter 23
Chapter 23
 
User datagram protocol
User datagram protocolUser datagram protocol
User datagram protocol
 
Chap 11
Chap 11Chap 11
Chap 11
 
Ch21
Ch21Ch21
Ch21
 
Chapter 21
Chapter 21Chapter 21
Chapter 21
 
Cs8591 u4
Cs8591 u4Cs8591 u4
Cs8591 u4
 
Chap 14
Chap 14Chap 14
Chap 14
 
Simulation of a Wireless Sub Network using QualNET
Simulation of a Wireless Sub Network using QualNETSimulation of a Wireless Sub Network using QualNET
Simulation of a Wireless Sub Network using QualNET
 
Chap 13
Chap 13Chap 13
Chap 13
 
Chap 10 igmp
Chap 10 igmpChap 10 igmp
Chap 10 igmp
 
Chap 02 osi model
Chap 02 osi modelChap 02 osi model
Chap 02 osi model
 

Recently uploaded

Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 

Recently uploaded (20)

Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 

Chap 12 tcp

  • 1. Chapter 12 Transmission Control Protocol Objectives Upon completion you will be able to: • Be able to name and understand the services offered by TCP • Understand TCP’s flow and error control and congestion control • Be familiar with the fields in a TCP segment • Understand 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 familiar with the TCP options TCP/IP Protocol Suite 1
  • 2. Figure 12.1 TCP/IP protocol suite TCP/IP Protocol Suite 2
  • 3. 12.1 TCP SERVICES We explain the services offered by TCP to the processes at the application layer. The topics discussed in this section include: Process-to-Process Communication Stream Delivery Service Full-Duplex Communication Connection-Oriented Service Reliable Service TCP/IP Protocol Suite 3
  • 4. Table 12.1 Well-known ports used by TCP TCP/IP Protocol Suite 4
  • 5. Example 1 As we said in Chapter 11, in UNIX, the well-known ports are stored in a file called /etc/services. Each line in this file gives the name of the server and the well-known port number. We can use the grep utility to extract the line corresponding to the desired application. The following shows the ports for FTP. $ grep ftp /etc/services ftp-data 20/tcp ftp-control 21/tcp TCP/IP Protocol Suite 5
  • 6. Figure 12.2 Stream delivery TCP/IP Protocol Suite 6
  • 7. Figure 12.3 Sending and receiving buffers TCP/IP Protocol Suite 7
  • 8. Figure 12.4 TCP segments TCP/IP Protocol Suite 8
  • 9. 12.2 TCP FEATURES To provide the services mentioned in the previous section, TCP has several features that are briefly summarized in this section. The topics discussed in this section include: Numbering System Flow Control Error Control Congestion Control TCP/IP Protocol Suite 9
  • 10. Note: The bytes of data being transferred in each connection are numbered by TCP. The numbering starts with a randomly generated number. TCP/IP Protocol Suite 10
  • 11. Example 2 Suppose a TCP connection is transferring a file of 5000 bytes. The first byte is numbered 10001. What are the sequence numbers for each segment if data is sent in five segments, each carrying 1000 bytes? Solution The 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) TCP/IP Protocol Suite 11
  • 12. Note: The value in the sequence number field of a segment defines the number of the first data byte contained in that segment. TCP/IP Protocol Suite 12
  • 13. Note: The value of the acknowledgment field in a segment defines the number of the next byte a party expects to receive. The acknowledgment number is cumulative. TCP/IP Protocol Suite 13
  • 14. 12.3 SEGMENT A packet in TCP is called a segment The topics discussed in this section include: Format Encapsulation TCP/IP Protocol Suite 14
  • 15. Figure 12.5 TCP segment format TCP/IP Protocol Suite 15
  • 16. Figure 12.6 Control field TCP/IP Protocol Suite 16
  • 17. Table 12.2 Description of flags in the control field I TCP/IP Protocol Suite 17
  • 18. Figure 12.7 Pseudoheader added to the TCP datagram TCP/IP Protocol Suite 18
  • 19. Note: The inclusion of the checksum in TCP is mandatory. TCP/IP Protocol Suite 19
  • 20. Figure 12.8 Encapsulation and decapsulation TCP/IP Protocol Suite 20
  • 21. 12.4 A TCP CONNECTION TCP is connection-oriented. A connection-oriented transport protocol establishes a virtual path between the source and destination. All of the segments belonging to a message are then sent over this virtual 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 TCP/IP Protocol Suite 21
  • 22. Figure 12.9 Connection establishment using three-way handshaking TCP/IP Protocol Suite 22
  • 23. Note: A SYN segment cannot carry data, but it consumes one sequence number. TCP/IP Protocol Suite 23
  • 24. Note: A SYN + ACK segment cannot carry data, but does consume one sequence number. TCP/IP Protocol Suite 24
  • 25. Note: An ACK segment, if carrying no data, consumes no sequence number. TCP/IP Protocol Suite 25
  • 26. Figure 12.10 Data transfer TCP/IP Protocol Suite 26
  • 27. Note: The FIN segment consumes one sequence number if it does not carry data. TCP/IP Protocol Suite 27
  • 28. Figure 12.11 Connection termination using three-way handshaking TCP/IP Protocol Suite 28
  • 29. Note: The FIN + ACK segment consumes one sequence number if it does not carry data. TCP/IP Protocol Suite 29
  • 30. Figure 12.12 Half-close TCP/IP Protocol Suite 30
  • 31. 12.5 STATE TRANSITION DIAGRAM To keep track of all the different events happening during connection establishment, connection termination, and data transfer, the TCP software is implemented as a finite state machine. . The topics discussed in this section include: Scenarios TCP/IP Protocol Suite 31
  • 32. Table 12.3 States for TCP TCP/IP Protocol Suite 32
  • 33. Figure 12.13 State transition diagram TCP/IP Protocol Suite 33
  • 34. Figure 12.14 Common scenario TCP/IP Protocol Suite 34
  • 35. Note: The common value for MSL is between 30 seconds and 1 minute. TCP/IP Protocol Suite 35
  • 36. Figure 12.15 Three-way handshake TCP/IP Protocol Suite 36
  • 37. Figure 12.16 Simultaneous open TCP/IP Protocol Suite 37
  • 38. Figure 12.17 Simultaneous close TCP/IP Protocol Suite 38
  • 39. Figure 12.18 Denying a connection TCP/IP Protocol Suite 39
  • 40. Figure 12.19 Aborting a connection TCP/IP Protocol Suite 40
  • 41. 12.6 FLOW CONTROL Flow control regulates the amount of data a source can send before receiving 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 Silly Window Syndrome TCP/IP Protocol Suite 41
  • 42. Figure 12.20 Sliding window TCP/IP Protocol Suite 42
  • 43. Note: A sliding window is used to make transmission more efficient as well as to control the flow of data so that the destination does not become overwhelmed with data. TCP’s sliding windows are byte oriented. TCP/IP Protocol Suite 43
  • 44. Example 3 What is the value of the receiver window (rwnd) for host A if the receiver, host B, has a buffer size of 5,000 bytes and 1,000 bytes of received and unprocessed data? Solution The value of rwnd = 5,000 − 1,000 = 4,000. Host B can receive only 4,000 bytes of data before overflowing its buffer. Host B advertises this value in its next segment to A. TCP/IP Protocol Suite 44
  • 45. Example 4 What is the size of the window for host A if the value of rwnd is 3,000 bytes and the value of cwnd is 3,500 bytes? Solution The size of the window is the smaller of rwnd and cwnd, which is 3,000 bytes. TCP/IP Protocol Suite 45
  • 46. Example 5 Figure 12.21 shows an unrealistic example of a sliding window. The sender has sent bytes up to 202. We assume that cwnd is 20 (in reality this value is thousands of bytes). The receiver has sent an acknowledgment number of 200 with an rwnd of 9 bytes (in reality this value is thousands of bytes). The size of the sender window is the minimum of rwnd and cwnd or 9 bytes. Bytes 200 to 202 are sent, but not acknowledged. Bytes 203 to 208 can be sent without worrying about acknowledgment. Bytes 209 and above cannot be sent. TCP/IP Protocol Suite 46
  • 47. Figure 12.21 Example 5 TCP/IP Protocol Suite 47
  • 48. Example 6 In Figure 12.21 the server receives a packet with an acknowledgment value of 202 and an rwnd of 9. The host has already sent bytes 203, 204, and 205. The value of cwnd is still 20. Show the new window. Solution Figure 12.22 shows the new window. Note that this is a case in which the window closes from the left and opens from the right by an equal number of bytes; the size of the window has not been changed. The acknowledgment value, 202, declares that bytes 200 and 201 have been received and the sender needs not worry about them; the window can slide over them. TCP/IP Protocol Suite 48
  • 49. Figure 12.22 Example 6 TCP/IP Protocol Suite 49
  • 50. Example 7 In Figure 12.22 the sender receives a packet with an acknowledgment value of 206 and an rwnd of 12. The host has not sent any new bytes. The value of cwnd is still 20. Show the new window. Solution The value of rwnd is less than cwnd, so the size of the window is 12. Figure 12.23 shows the new window. Note that the window has been opened from the right by 7 and closed from the left by 4; the size of the window has increased. TCP/IP Protocol Suite 50
  • 51. Figure 12.23 Example 7 TCP/IP Protocol Suite 51
  • 52. Example 8 In Figure 12.23 the host receives a packet with an acknowledgment value of 210 and an rwnd of 5. The host has sent bytes 206, 207, 208, and 209. The value of cwnd is still 20. Show the new window. Solution The value of rwnd is less than cwnd, so the size of the window is 5. Figure 12.24 shows the situation. Note that this is a case not allowed by most implementations. Although the sender has not sent bytes 215 to 217, the receiver does not know this. TCP/IP Protocol Suite 52
  • 53. Figure 12.24 Example 8 TCP/IP Protocol Suite 53
  • 54. Example 9 How can the receiver avoid shrinking the window in the previous example? Solution The receiver needs to keep track of the last acknowledgment number and the last rwnd. If we add the acknowledgment number to rwnd we get the byte number following the right wall. If we want to prevent the right wall from moving to the left (shrinking), we must always have the following relationship. new ack + new rwnd ≥ last ack + last rwnd or new rwnd ≥ (last ack + last rwnd) − new ack TCP/IP Protocol Suite 54
  • 55. Note: To avoid shrinking the sender window, the receiver must wait until more space is available in its buffer. TCP/IP Protocol Suite 55
  • 56. Note: Some points about TCP’s sliding windows: ❏ The size of the window is the lesser of rwnd and cwnd. ❏ The source does not have to send a full window’s 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 temporarily shut down the window; the sender, however, can always send a segment of one byte after the window is shut down. TCP/IP Protocol Suite 56
  • 57. 12.7 ERROR CONTROL TCP provides reliability 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 Segments Some Scenarios TCP/IP Protocol Suite 57
  • 58. Note: ACK segments do not consume sequence numbers and are not acknowledged. TCP/IP Protocol Suite 58
  • 59. Note: In modern implementations, a retransmission occurs if the retransmission timer expires or three duplicate ACK segments have arrived. TCP/IP Protocol Suite 59
  • 60. Note: No retransmission timer is set for an ACK segment. TCP/IP Protocol Suite 60
  • 61. Note: Data may arrive out of order and be temporarily stored by the receiving TCP, but TCP guarantees that no out-of-order segment is delivered to the process. TCP/IP Protocol Suite 61
  • 62. Figure 12.25 Normal operation TCP/IP Protocol Suite 62
  • 63. Figure 12.26 Lost segment TCP/IP Protocol Suite 63
  • 64. Note: The receiver TCP delivers only ordered data to the process. TCP/IP Protocol Suite 64
  • 65. Figure 12.27 Fast retransmission TCP/IP Protocol Suite 65
  • 66. Figure 12.28 Lost acknowledgment TCP/IP Protocol Suite 66
  • 67. Figure 12.29 Lost acknowledgment corrected by resending a segment TCP/IP Protocol Suite 67
  • 68. Note: Lost acknowledgments may create deadlock if they are not properly handled. TCP/IP Protocol Suite 68
  • 69. 12.8 CONGESTION CONTROL Congestion control refers to the mechanisms and techniques to keep the load below the capacity. The topics discussed in this section include: Network Performance Congestion Control Mechanisms Congestion Control in TCP TCP/IP Protocol Suite 69
  • 70. Figure 12.30 Router queues TCP/IP Protocol Suite 70
  • 71. Figure 12.31 Packet delay and network load TCP/IP Protocol Suite 71
  • 72. Figure 12.32 Throughput versus network load TCP/IP Protocol Suite 72
  • 73. Figure 12.33 Slow start, exponential increase TCP/IP Protocol Suite 73
  • 74. Note: In the slow start algorithm, the size of the congestion window increases exponentially until it reaches a threshold. TCP/IP Protocol Suite 74
  • 75. Figure 12.34 Congestion avoidance, additive increase TCP/IP Protocol Suite 75
  • 76. Note: In the congestion avoidance algorithm the size of the congestion window increases additively until congestion is detected. TCP/IP Protocol Suite 76
  • 77. Note: Most implementations react differently to congestion detection: ❏ If detection is by time-out, a new slow start phase starts. ❏ If detection is by three ACKs, a new congestion avoidance phase starts. TCP/IP Protocol Suite 77
  • 78. Figure 12.35 TCP congestion policy summary TCP/IP Protocol Suite 78
  • 79. Figure 12.36 Congestion example TCP/IP Protocol Suite 79
  • 80. 12.9 TCP TIMERS To perform its operation smoothly, most TCP implementations use at least four timers. The topics discussed in this section include: Retransmission Timer Persistence Timer Keepalive Timer TIME-WAIT Timer TCP/IP Protocol Suite 80
  • 81. Figure 12.37 TCP timers TCP/IP Protocol Suite 81
  • 82. Note: In TCP, there can be only be one RTT measurement in progress at any time. TCP/IP Protocol Suite 82
  • 83. Example 10 Let us give a hypothetical example. Figure 12.38 shows part of a connection. The figure shows the connection establishment and part of the data transfer phases. 1. When the SYN segment is sent, there is no value for RTTM , RTTS , or RTTD . The value of RTO is set to 6.00 seconds. The following shows the value of these variables at this moment: RTTM = 1.5 RTTS = 1.5 RTTD = 1.5 / 2 = 0.75 RTO = 1.5 + 4 . 0.75 = 4.5 2. When the SYN+ACK segment arrives, RTTM is measured and is equal to 1.5 seconds. The next slide shows the values of these variables: TCP/IP Protocol Suite 83
  • 84. Example 10 (continued) RTTM = 1.5 RTTS = 1.5 RTTD = 1.5 / 2 = 0.75 RTO = 1.5 + 4 . 0.75 = 4.5 3.When the first data segment is sent, a new RTT measurement starts. Note that the sender does not start an RTT measurement when it sends the ACK segment, because it does not consume a sequence number and there is no time-out. No RTT measurement starts for the second data segment because a measurement is already in progress. RTTM = 2.5 RTTS = 7/8 (1.5) + 1/8 (2.5) = 1.625 RTTD = 3/4 (7.5) + 1/4 |1.625 − 2.5| = 0.78 RTO = 1.625 + 4 (0.78) = 4.74 TCP/IP Protocol Suite 84
  • 85. Figure 12.38 Example 10 TCP/IP Protocol Suite 85
  • 86. Note: TCP does not consider the RTT of a retransmitted segment in its calculation of a new RTO. TCP/IP Protocol Suite 86
  • 87. Example 11 Figure 12.39 is a continuation of the previous example. There is retransmission and Karn’s algorithm is applied. The first segment in the figure is sent, but lost. The RTO timer expires after 4.74 seconds. The segment is retransmitted and the timer is set to 9.48, twice the previous value of RTO. This time an ACK is received before the time-out. We wait until we send a new segment and receive the ACK for it before recalculating the RTO (Karn’s algorithm). TCP/IP Protocol Suite 87
  • 88. Figure 12.39 Example 11 TCP/IP Protocol Suite 88
  • 89. 12.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. TCP/IP Protocol Suite 89
  • 90. Figure 12.40 Options TCP/IP Protocol Suite 90
  • 91. Figure 12.41 End-of-option option TCP/IP Protocol Suite 91
  • 92. Note: EOP can be used only once. TCP/IP Protocol Suite 92
  • 93. Figure 12.42 No-operation option TCP/IP Protocol Suite 93
  • 94. Note: NOP can be used more than once. TCP/IP Protocol Suite 94
  • 95. Figure 12.43 Maximum-segment-size option TCP/IP Protocol Suite 95
  • 96. Note: The value of MSS is determined during connection establishment and does not change during the connection. TCP/IP Protocol Suite 96
  • 97. Figure 12.44 Window-scale-factor option TCP/IP Protocol Suite 97
  • 98. Note: The value of the window scale factor can be determined only during connection establishment; it does not change during the connection. TCP/IP Protocol Suite 98
  • 99. Figure 12.45 Timestamp option TCP/IP Protocol Suite 99
  • 100. Note: One application of the timestamp option is the calculation of round trip time (RTT). TCP/IP Protocol Suite 100
  • 101. Example 12 Figure 12.46 shows an example that calculates the round-trip time for one end. Everything must be flipped if we want to calculate the RTT for the other end. The sender simply inserts the value of the clock (for example, the number of seconds past from midnight) in the timestamp field for the first and second segment. When an acknowledgment comes (the third segment), the value of the clock is checked and the value of the echo reply field is subtracted from the current time. RTT is 12 s in this scenario. TCP/IP Protocol Suite 101
  • 102. Example 12 (Continued) The receiver’s function is more involved. It keeps track of the last acknowledgment sent (12000). When the first segment arrives, it contains the bytes 12000 to 12099. The first byte is the same as the value of lastack. It then copies the timestamp value (4720) into the tsrecent variable. The value of lastack is still 12000 (no new acknowledgment has been sent). When the second segment arrives, since none of the byte numbers in this segment include the value of lastack, the value of the timestamp field is ignored. When the receiver decides to send an accumulative acknowledgment with acknowledgment 12200, it changes the value of lastack to 12200 and inserts the value of tsrecent in the echo reply field. The value of tsrecent will not change until it isreplaced by a new segment that carries byte 12200 (next segment). TCP/IP Protocol Suite 102
  • 103. Example 12 (Continued) Note that as the example shows, the RTT calculated is the time difference between sending the first segment and receiving the third segment. This is actually the meaning of RTT: the time difference between a packet sent and the acknowledgment received. The third segment carries the acknowledgment for the first and second segments. TCP/IP Protocol Suite 103
  • 104. Figure 12.46 Example 12 TCP/IP Protocol Suite 104
  • 105. Note: The timestamp option can also be used for PAWS. TCP/IP Protocol Suite 105
  • 106. Figure 12.47 SACK TCP/IP Protocol Suite 106
  • 107. Example 13 Let us see how the SACK option is used to list out-of-order blocks. In Figure 12.48 an end has received five segments of data. The first and second segments are in consecutive order. An accumulative acknowledgment can be sent to report the reception of these two segments. Segments 3, 4, and 5, however, are out of order with a gap between the second and third and a gap between the fourth and the fifth. An ACK and a SACK together can easily clear the situation for the sender. The value of ACK is2001, which means that the sender need not worry about bytes 1 to 2000. The SACK has two blocks. The first block announces that bytes 4001 to 6000 have arrived out of order. The second block shows that bytes 8001 to 9000 have also arrived out of order. This means that bytes 2001 to 4000 and bytes 6001 to 8000 are lost or discarded. The sender can resend only these bytes. TCP/IP Protocol Suite 107
  • 108. Figure 12.48 Example 13 TCP/IP Protocol Suite 108
  • 109. Example 14 The example in Figure 12.49 shows how a duplicate segment can be detected with a combination of ACK and SACK. In this case, we have some out-of-order segments (in one block) and one duplicate segment. To show both out-of-order and duplicate data, SACK uses the first block, in this case, to show the duplicate data and other blocks to show out-of-order data. Note that only the first block can be used for duplicate data. The natural question is how the sender, when it receives these ACK and SACK values knows that the first block is for duplicate data (compare this example with the previous example). The answer is that the bytes in the first block are already acknowledged in the ACK field; therefore, this block must be a duplicate. TCP/IP Protocol Suite 109
  • 110. Figure 12.49 Example 14 TCP/IP Protocol Suite 110
  • 111. Example 15 The example in Figure 12.50 shows what happens if one of the segments in the out-of-order section is also duplicated. In this example, one of the segments (4001:5000) is duplicated. The SACK option announces this duplicate data first and then the out-of-order block. This time, however, the duplicated block is not yet acknowledged by ACK, but because it is part of the out-of- order block (4001:5000 is part of 4001:6000), it is understood by the sender that it defines the duplicate data. TCP/IP Protocol Suite 111
  • 112. Figure 12.50 Example 15 TCP/IP Protocol Suite 112
  • 113. 12.11 TCP PACKAGE We present a simplified, bare-bones TCP package to simulate the heart of TCP. The package involves tables called transmission control blocks, a set of timers, and three software modules. The topics discussed in this section include: Transmission Control Blocks (TCBs) Timers Main Module Input Processing Module Output Processing Module TCP/IP Protocol Suite 113
  • 114. Figure 12.51 TCP package TCP/IP Protocol Suite 114
  • 115. Figure 12.52 TCBs TCP/IP Protocol Suite 115