Unit 4
Unit 4
3
Transport Layer: What TCP does?
• TCP: End -To- End (Process-To-Process) Communication
4
Transport Layer: What TCP does?
• TCP: Reliability
• Causes of problems
• Failure of the IP system to deliver information reliably
• Messages may be duplicated, lost, delayed or delivered out of order.
• Reboot of a host computer
• Two programs make a connection.
• One computer reboots.
• New connection is formed.
• Messages from first session now arrive.
5
Transport Layer: What TCP does?
• TCP: Reliability
• Packet Loss and Retransmission
Host 1 Host 2
Send P1 Receive P1
Start timer Send ack1
Receive ack1
Send P2
Start timer
Packet Loss
Timer expires
Retransmit P2 Receive P2
Start timer Send ack2
Receive ack2
6
Transport Layer: What TCP does?
• TCP: Buffers and Windows
• Sending and Receiving host can have a buffer.
• Acknowledgements send between sender and receiver can contain
information about amount of free buffer space available (Window).
• Sender will not send more data than buffer (receiver’s) will hold.
• Receiver, as buffer space increases (i.e. application consumes from buffer)
sends additional acks to sender to update it’s buffer space available.
7
Transport Layer: What TCP does?
• TCP: Sliding Window
• TCP uses a sliding window to handle flow control and error control.
• The sliding window protocol used by TCP, however, is something between
the Go-Back-N and Selective Repeat sliding window.
• The sliding window protocol in TCP looks like the Go-Back-N protocol
because it does not use NAKs;
• It looks like Selective Repeat because the receiver holds the out-of-order
segments until the missing ones arrive.
• Main difference between TCP sliding window and the one we uses at the
data link layer is.
• The sliding window of TCP is byte-oriented; whereas in the data link
layer it is frame-oriented.
8
Transport Layer: What TCP does?
• TCP: Sliding Window
1
0
Transport Layer: What TCP does?
• TCP: provides Multiplexing and De-Multiplexing
• Multiplexing: At sender site, there may be several processes that need to
send packets. However, there is only one transport layer protocol (TCP).
• This is a many-to-one relationship and requires multiplexing.
• The protocol (TCP) accepts messages from different processes,
differentiated by their assigned port numbers.
• De-Multiplexing: At the receiver site, the relationship is one-to-many
and requires de-multiplexing.
• The transport layer (TCP) receives datagram from the network layer. After
error checking and dropping of the header, the transport layer (TCP)
delivers each message to the appropriate process based on the port number.
• TCP: Port Numbers
• At transport layer, we need a transport layer address called a port number
to choose among multiple processes running on the destination host.
• Multiple connections from many hosts.
• Multiple connections from one host.
1
1
Transport Layer: What TCP does?
• TCP: provides Reliable Connection Startup
• The connection establishment in TCP is called three way handshaking.
• An application program, called the client, wants to make a connection
with another application program, called the server, using TCP.
• The server program tells its TCP that it is ready to accept a connection.
This is called a request for a passive open.
• The client program issues a request for an active open. A client that
wishes to connect to an open server tells its TCP that it needs to be
connected to that particular server.
• TCP can now start the three-way handshaking process as shown in Figure.
• TCP: provides graceful Connection Shutdown
• Most implementations today allow three-way handshaking for connection
termination as shown in Figure.
1
2
Transport Layer: What TCP does?
• TCP: Connection establishment using three-way handshaking.
• TCP: Connection termination using three-way handshaking.
1
3
Transport Layer Services
16
Continue….
• In the Internet model, the port numbers are 16-bit integers
between 0 and 65,535.
• Dynamic ports:- The ports ranging from 49,152 to 65,535 are neither controlled
nor registered. They can be used by any process. These are the ephemeral ports.
• The destination IP address defines the host among the different hosts in the
world.
• After the host has been selected, the port number defines one of the processes
on this particular host.
18
IP addresses versus port numbers
Socket Addresses
• Process-to-process delivery needs two identifiers, IP address and the port
number, at each end to make a connection.
• The client socket address defines the client process uniquely just as the server
socket address defines the server process uniquely.
20
Multiplexing and Demultiplexing
Multiplexing (or muxing) is a way of sending multiple signals or streams of information over
a communications link at the same time in the form of a single, complex signal; the receiver
recovers the separate signals, a process calleddemultiplexing (or demuxing).
21
Connectionless Versus Connection-Oriented Service
• In a connectionless service, the packets are sent from one party to another with
no need for connection establishment or connection release.
• The packets are not numbered; they may be delayed or lost or may arrive out of
sequence. There is no acknowledgment either.
22
Connection oriented
23
Reliable Versus Unreliable : Error control
Position of UDP, TCP, and SCTP in TCP/IP suite
User Datagram Protocol (UDP)
• If a process wants to send a small message and does not care much about
reliability, it can use UDP.(using UDP takes much less interaction between the
sender and receiver than using TCP or SCTP)
26
27
User Datagram
29
UDP Operations
• Connectionless services
• Flow control and error control
• Encapsulation and decapsulation
• Queuing
Queues in UDP
Introduction to TCP
32
1 TCP SERVICES
We explain the services offered by TCP to the processes at the application
layer.
Process-to-Process Communication
Stream Delivery Service
Full-Duplex Communication
Connection-Oriented Service
Reliable Service
33
TCP provides process-to-process communication using port numbers.
34
Example 1
35
Figure 2 Stream delivery
36
Figure 3 Sending and receiving buffers
37
Figure 4 TCP segments
Numbering System
Flow Control
Congestion Control
39
Note:
40
Example 2
41
Note:
42
3 SEGMENT
A packet in TCP is called a segment
Format
Encapsulation
43
Figure 5 TCP segment format 20 to 60 Bytes
44
TCP segment format fields.
• The segment consists of a 20 to 60 byte header.
• Source port address: This is a 16-bit field that defines the port
number of the application program in the host that is sending
the segment.
45
Continue..
• Sequence number:- This 32-bit field defines the number
assigned to the first byte of data contained in this segment.
46
Figure Control field
47
Continue..
• Window size:- This value is normally referred to as the
receiving window (rwnd) and is determined by the receiver(16
bit field, which means that the maximum size of the window is
65,535 bytes. )
48
Note:
49
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.
Connection Establishment
Data Transfer
Connection Termination
Connection Reset
50
Figure .9 Connection establishment using three-way handshaking
51
Note:
52
Note:
53
Note:
54
Figure Data transfer
55
Figure Connection termination using three-way handshaking
56
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.
57
Figure 12.20 Sliding window
58
Flow control
• The imaginary window has two walls: one left and
one right.
• Shrinking the window means moving the right wall to the left.
• The size of the window at one end is determined by the lesser of two
values: receiver window (rwnd) or congestion window (cwnd).
60
Continue..
• It is the number of bytes the other end can accept before its buffer
overflows and data are discarded.
61
Note:
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.
63
Example 2
64
Figure 1 Example 2
65
Note:
66
CONGESTION CONTROL
Congestion control refers to the mechanisms and techniques to keep the
load below the capacity.
Network Performance
Congestion Control Mechanisms
Congestion Control in TCP
67
Figure 12.30 Router queues
68
Figure 12.31 Packet delay and network load
69
Figure 12.32 Throughput versus network load
70
Figure 12.33 Slow start, exponential increase
71
Note:
72
Figure 12.34 Congestion avoidance, additive increase
73
Note:
74
Note:
75
Figure 12.35 TCP congestion policy summary
76
Figure 12.36 Congestion example
77
12.9 TCP TIMERS
To perform its operation smoothly, most TCP implementations use at least
four timers.
Retransmission Timer
Persistence Timer
Keepalive Timer
TIME-WAIT Timer
78
Figure 12.37 TCP timers
79
Note:
80
Example 10
81
Example 10 (continued)
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
82
Figure 12.38 Example 10
83
Note:
84
Example 11
85
Figure 12.39 Example 11
86
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.
87
Figure 12.40 Options
88
Figure 12.41 End-of-option option
89
Note:
90
Figure 12.42 No-operation option
91
Note:
92
Figure 12.43 Maximum-segment-size option
93
Note:
94
Figure 12.44 Window-scale-factor option
95
Note:
96
Figure 12.45 Timestamp option
97
Note:
98
Example 12
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.
99
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.
101
Figure 12.46 Example 12
102
Note:
103
Figure 12.47 SACK
104
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.
105
Figure 12.48 Example 13
106
Example 14
107
Figure 12.49 Example 14
108
Example 15
109
Figure 12.50 Example 15
110
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.
111
Figure 12.51 TCP package
112
Figure 12.52 TCBs
113
Quality of Service
24.114
QUALITY OF SERVICE
24.116
Reliability
24.117
Jitter
Jitter is defined as the variation in the packet delay
• Jitter is the variation in delay for packets belonging to the same flow.
• For example, if four packets depart at times 0, 1, 2, 3 and arrive at 20, 21, 22, 23,
all have the same delay, 20 units of time.
• On the other hand, if the above four packets arrive at 21, 23, 21, and 28, they will
have different delays: 21,22, 19, and 24.
• For applications such as audio and video, the first case is completely acceptable;
the second case is not.
24.118
Bandwidth
24.119
24-6 TECHNIQUES TO IMPROVE QoS
• Packets from different flows arrive at a switch or router for processing. A good
scheduling technique treats the different flows in a fair and appropriate manner.
24.121
Figure FIFO queue
24.122
Figure Priority queuing
A priority queue can provide better QoS than the FIFO queue
because higher priority traffic, such as multimedia, can reach
the destination with less delay.
Figure Weighted fair queuing
Traffic Shaping
• Two techniques can shape traffic: leaky bucket and token bucket.
24.125
Figure Leaky bucket
24 Mbits of data
6 Mbits of data
Figure 24.20 Leaky bucket implementation
24.127
Leaky bucket implementation
24.128
The following is an algorithm for variable-length packets
24.129
Note
24.130
Disadvantage of leaky bucket algorithm
• In leaky bucket algorithm the time when the host was idle is not
taken into account.
• On the other hand, the token bucket algorithm allows idle hosts to
accumulate credit for the future in the form of tokens.
• For each tick of the clock, the system sends n tokens to the bucket.
24.131
Figure Token bucket
24.132
Continue..
• The system removes one token for every cell (or byte)
of data sent.
24.134
Note
24.135
Figure Token bucket
24.136
INTEGRATED SERVICES
24.138
Signaling
• IP is connectionless, datagram , packet-switching
protocol.
• How can we implement flow based model over a
connectionless protocol?
• Solution- signaling protocol to run over IP that
provides signaling mechanism for making a
reservation.
• RSVP- Resource Reservation Protocol
24.139
Flow Specification
24.140
Admission
24.141
RSVP
24.142
Figure Path messages
24.143
Figure Resv messages
24.144
Figure Reservation merging
24.145
Problems with Integrated Services
• Scalability
The Integrated Services model requires that each router keep
information for each flow.
• Service-Type Limitation
The Integrated Services model provides only two types of services,
guaranteed and control-load.
24.146
DIFFERENTIATED SERVICES
24.147
Two fundamental changes were made:
• The routers do not have to store information about flows.
The applications, or hosts, define the type of service they
need each time they send a packet.
24.148
Note
24.149
Differentiated Service
• In Diffserv, each packet contains a field called the DS
field. The value of this field is set at the boundary of
the network by the host or the first router designated
as the boundary router.
24.150
Continue..
• The Diffserv capable node (router) uses the DSCP 6 bits as an index to
a table defining the packet-handling mechanism for the current
packet being processed.
• The Diffserv model defines per-hop behaviors (PHBs) for each node
that receives a packet.
24.151
Figure DS field
24.152
Traffic Conditioner
• Meters:- The meter checks to see if the incoming flow matches the
negotiated traffic profile. The meter also sends this result to other
components. The meter can use several tools such as a token bucket
to check the profile.
24.153
• Marker A marker can remark a packet that is using best-effort delivery (OSCP:
000000) or down-mark a packet based on information received from the meter.
Downmarking (lowering the class of the flow) occurs if the flow does not match
the profile. A marker does not up-mark (promote the class) a packet.
• Shaper A shaper uses the information received from the meter to reshape the
traffic if it is not compliant with the negotiated profile.
24.154
Figure 24.27 Traffic conditioner
24.155