Chap13-The Transport Layer Protocols
Chap13-The Transport Layer Protocols
Host A Host B
Application
TCP/UDP
IP
Data link
Physical
number field. When taken together, the fields uniquely identify an application process
running on the destination host.
er host C
Client host B
Figure 13.2: Multiplexing of two client applications, using the same port numbers
In order to be able to demultiplex the application when the two sessions have
exactly the same port number pair segments the server also uses the IP addresses in the IP
datagrams carrying these segments. The situation is illustrated in Figure 13.2, in which
host A initiates two FTP sessions to host C, and host B initiates one FTP session to host C.
Hosts A, B and C each has its own unique IP address. Host A assigns two different source
port (SP) numbers (x and y) to the two FTP connections emanating from host A. But
because host B is choosing source port numbers independently from A, it can also assign
SP=x to its FTP connection. Nevertheless, host C is still able to demultiplex the two
connections since the two connections have different source IP addresses.
W When a destination host receives data from the network layer, the triplet (source IP address, source port nu
0 4 8 16 19 31
Destenation Port
Sequence number
acknowledgment number
number, which is chosen randomly by the transmitter, and each subsequent data
segment has a sequence number accordingly greater than the previous segment.
The increment in the sequence number depends upon the number of octets in the
previous segment. The sequence number thus counts octets, but its value also
uniquely identifies a particular segment. The sequence number restarts from 0
after the number reaches 232 - 1.
Suppose that a process in host A wants to send a stream of data to a process in host B
over a TCP connection. The TCP in host A will implicitly number each byte in the
data stream. Suppose that the data stream consists of a file consisting of 100,000 bytes,
that the MSS is 500 bytes, and that the first byte of the data stream is numbered
100. As shown in Figure13.4, TCP constructs 200 segments out of the data stream. The
first segment gets assigned sequence number 100, the second segment gets
assigned sequence number 600, the third segment gets assigned sequence number
1100, and so on.. Each sequence number is inserted in the sequence number field in
the header of the appropriate TCP segment.
S Options: is a variable-length field that specifies the functions that are not
available as part of the basic header. A receiver can use this option to specify the
maximum segment size it can receive. It can use this field also to scaling the
advertised beyond the specified 216 - 1 in the header. The advertised window can
be scaled to a maximum of 214.
S Data (variable): This field may contain one segment of an information sequence
generated by an application layer protocol.
& Both the sequence number and the acknowledgement number can be incremented up to the value 2' 2
& The reuse of sequence numbers can cause a problem, if there is any chance that two segments might
When one of the hosts wants to end the connection, it sends a segment with the RST
bit is set to 1. If the application has no data to transmit, the sender sends a segment
with the FIN bit set to 1. The receiver acknowledges receipt of this segment by responding
with an ACK and notifies the application that the connection is terminated. Now, the flow
from the sender to the receiver is terminated. However, in such cases, the flow from the
receiver to the sender is still open. The receiver then sends a segment with the FIN bit
is set to 1. Once the sender acknowledges this by responding with an ACK, the
connection is terminated at both ends.
Host B
time time
Figure 13.5: TCP connection establishment
link layer. The same algorithms can be used here to handle the problem of segments flow
control in transport layer.
As the application process at B empties the buffer, TCP does not send new segments with
new RcvWi ndows to host A. Therefore host A is never informed that some space has
opened up in host B’s receive buffer. In this case host A is blocked and can transmit
no more data!
To solve this problem TCP specification requires host A to continue to send
segments with one data byte when B's receive window is zero. These segments will be
acknowledged by the receiver. Eventually the buffer will begin to empty and the
acknowledgements will contain non-zero RcvWi ndow.
13.5.3.2 Round Trip Time and Timeout
TCP uses timing mechanisms for several critical functions. Each time a segment is
transmitted, a timer is set. If that timer expires (that is, decrements to 0) before an
acknowledgment is received, the segment is assumed to be lost. Consequently, it is
retransmitted. In theory, transmission of segments is throttled back until timeouts cease
occurring (this is the time from when the timer is started until when it expires). The
timeout should be larger than the connection's round-trip time. But the timeout should not
be much larger than the round-trip time to insure quick retransmition the segment, thereby
introducing significant data transfer delays into the application.
& Congestion control has to do with making sure the subnet is able to carry the offered traffic. It is a global is
THE TRANSPORT LAYER 42
M Flow control, in contrast, relates to the point-to-point traffic between a given sender and a given re
TCP attempts to achieve this goal by dynamically manipulating the window size.
When a connection is established, a suitable window size has to be chosen (Based
on the buffer size of receiver). But even if the sender sticks to this window size:
S congestion will occur due to buffer overflow at the receiving end (Figure 13.7 (a)).
S congestion may still occur due to internal congestion within the network (Figure
13.7 (b)).
Transmission rate
congestion
adjustment
Transmission network
Transmission rate
Internal
adjustment
congestion
Transmission network
Figure 13.7: Illustration of congestion (a) A fast network feeding a low-capacity receiver.
(b) A slow network feeding a high-capacity receiver.
The Internet solution is to realize that two potential problems exist
S network capacity
S receiver capacity
Each sender maintains two windows each reflects the number of bytes the sender
may transmit:
1. the window the receiver has granted
2.the congestion window
The number of bytes that may be sent is the minimum of the two windows.
Thus, the effective window is the minimum of what the sender thinks is all right and
what the receiver thinks is all right.
13.5.4.1 Slow Start Congestion Control Algorithm:
When a connection is established
430 COMPUTER NETWORKS AND COMMUNICATIONS
S the sender initializes the congestion window to the size of the maximum segment
in use on the connection
S sends one maximum segment
S If this segment is acknowledged before the timer goes off, it doubles the
congestion window to make it two maximum size segments and sends two
segments
S As each of these segments is acknowledged, the congestion window is doubled. In
effect each burst acknowledged doubles the congestion window.
S The congestion window keeps growing exponentially until either a timeout occurs
or the receiver's window is reached.
The idea is that if bursts of size, say, n, 2n, and 4n bytes work fine but a burst of 8n
bytes gives a timeout, the congestion window should be set to 4n to avoid congestion. As
long as the congestion window remains at 4n, no bursts longer than that will be sent,
no matter how much window space the receiver grants.
13.5.4.2 Internet Congestion Control Algorithm
This algorithm is slightly different from the previous one in the manner that it is
used to accommodate data flow. It uses a third parameter, the threshold, initially 64 KB, in
addition to the receiver and congestion windows, and works as follows (see Figure 13.8):
Timeout
36 — Threshold "
32
Congestion window
Threshold . “
8— •
4—•
024681012141618202224
Transmission number
W Other transport protocols are sometimes used in a misguided attempt to handle some of the security i
client sends a short UDP request to a server, it may assume that the packet is lost if no
response is returned within an established period of time; this is one way the Domain
Name System (DNS) works. (DNS can also operate over TCP.) In fact, you could
implement a reliable file transfer protocol using UDP, and many people have: Network
File System (NFS), Trivial FTP (TFTP), and FSP, a more distant relative of FTP, all
use UDP. (The latest version of NFS can use either UDP or TCP.) In these protocols,
the application is responsible for reliability; UDP doesn't take care of it. That is, the
application must handle missing or out-of-order packets. This is a lot of work, but there's
no reason it can’t be done—although if you find yourself writing this code, think carefully
about whether you might be better off with TCP.Table 10.4 lists popular Internet
applications and the transport protocols that they use.
& The correct amount of data to stuff into one packet depends on the situation. If the network is highly
host moves, all of elements remain fixed and the TCP connection can be preserved.
However, if either ends of the connection moves, the following problem will take place:
S If the mobile host acquires a new IP address, then its associated TCP connection
identifier also changes. This causes all TCP connections involving the mobile host
to break.
S If the mobile retains its address, then the routing system cannot forward packets to
its new location.
In wireless mobile networks, both UDP and TCP have their own applications.
However, some modifications are needed in these protocols to become appropriate for
wireless networks.
station
may not become aware of the disconnection as the wired portion is still in tact, and the
Base station still delivers the TCP segments to the mobile host. Consequently, the sender
of segments may not know of segments being delivered to the mobile host. A TCP
connection on the wireless link can separately support disconnections, and user mobility in
addition to wired TCP features such as notification to higher layers on changes in the
available bandwidth. Also, the flow control and congestion control mechanisms on the
wireless link remain separated from those on the wired link. In the I-TCP scheme, the TCP
acknowledgments are separate for the wireless and the wired links of the connection.
13.8.1.2 Fast Retransmit Mobile TCP
This scheme does not split the TCP connection to wireless and wired connections.
Fast Retransmit improves the connection throughput especially during a cell handoff.
Once two wireless cell MSCs hand off the switching function for a mobile host, the mobile
host stops receiving TCP segments. The sender may interpret this as a situation of
congestion leading to implement a congestion control such as window size reduction or
retransmitting. This may also result in a long timeout causing the mobile host to wait a
long period of time. With the fast retransmit TCP, the last old acknowledgment is
triplicated and retransmitted by the mobile host as soon as it finishes a handoff. This
results in significant reduction of the congestion window.
& Sockets provide a mechanism for building distributed network applications such as client/server appl
network.
436 COMPUTER NETWORKS AND COMMUNICATIONS
Logical connection
Physical connection
I
Figure 13.11: Socket communication between two processes over the network using TCP.
The socket serves as an interface between the application layer and the transport
layer within a host. It is a logical endpoint for communication between two hosts on a
TCP/IP network. A socket is an application programming interface (API) for establishing,
maintaining, and tearing down communication between TCP/IP hosts. Sockets were first
developed as a way of providing support for creating virtual connections between different
processes.
The socket is uniquely identified by three attributes:
S The host’s IP address
S The type of service needed and consequently the transport layer protocol to use. If
applications need to guarantee the delivery of data, the socket chooses the
connection-oriented service (TCP). If the applications do not need to guarantee
data delivery, the socket chooses the connectionless service (UDP). Once the
application developer chooses a transport protocol, the application is built using
the transport layer the services offered by that protocol.
S The application or service that will use this socket. The application is defined by a
port number used by this application or service running on the host.
So the socket can perform the following basic operations:
S Connect to a remote machine
S Send data
S Receive data
S Close a connection
S Bind to a port
H Listen for incoming data
S Accept connections from remote machines on the bound port
We can refer to the previous Figure to illustrate how the sockets work:
1. The client process passes a stream of data through the socket
2. TCP directs this data to the connection's send buffer
THE TRANSPORT LAYER 43
3. From time to time, TCP will "grab" chunks of data (Maximum Segment Size
MSS) from the send buffer.
4. TCP encapsulates each MSS of client data with TCP header, thereby forming TCP
segments.
5. The segments are passed down to the network layer, where they are separately
encapsulated within network-layer IP datagrams.
6. The IP datagrams are then sent into the network.
7. The IP datagrams are received from the network.
8. The datagrams are passed up to the network layer, where they are decapsulated to
a separate TCP segments
9. TCP decapsulates each TCP segments, thereby forming MSS.
10. The MSS is placed in the TCP connection’s receive buffer
11. The MSSs in the TCP connection's receive buffer perform a stream of data
12. The application reads the stream of data from this buffer
The application developer has control of everything on the application-layer side of
the socket but has little control of the transport-layer side of the socket. The only control
that the application developer has on the transport-layer side is
S the choice of transport protocol
S the ability to fix a few transport-layer parameters such as maximum buffer and
maximum segment sizes.
Sockets are a nearly standard programming interface to IP and IP transport protocols
that allow applications to be written in a portable way and run on different systems, getting
the same level of access to the IP transport. Sockets implementations themselves provide a
level of queuing of messages and buffering of data that is of great help to an
application implementer.
Note that sockets implementations exist to provide access to UDP and TCP. Direct access to IP (withou
Although sockets are a roughly standardized solution, it should be noted that they
are not part of the specification of IP or the IP transport protocols but are only a means of
access to them. Many application implementations choose to use sockets because of their
convenience or because they provide the only access to the IP or IP transport support
in the systems in which they will run.
The sockets API deviates slightly from one implementation to another, with the
result that unless an application is to be run on a single well-known platform, it is usually
constrained to a subset of the API to ensure that it can be ported.
Each transport-layer segment has fields that help to perform the demultiplexing
and multiplexing jobs.
TCP is a connection-oriented transport protocol that sends data as an unstructured
stream of bytes using a three-step hand shaking. It provides reliable packet
delivery, congestion control, error controlling, and full-duplex data exchange.
Sliding window flow control is achieved by maintain a variable called the receive
window to give the sender an idea about how much free buffer space is available at
the receiver.
Congestion is the situation when too many packets are present in a part of the
subnet, causing the performance to degrade.
Slow start congestion control algorithm and Internet congestion control algorithm
are used to prevent the Congestion from occurring.
UDP) is a connectionless unreliable transport protocol, no handshaking between
sending and receiving points occurs before sending a segment. It does not provide
a reliable service. It does not provide acknowledgment. But it tends to run
faster than TCP, less overhead. UDP is useful in applications that are
command/response oriented and in which the commands and responses can be
sent in a single datagram.
In order to retain transport layer connections, a mobile host’s address must be
preserved regardless of its point of attachment to the network. If either ends of the
connection moves, many problems will take place.
Mobile computing systems are characterized a poor link quality typically causes to
lose TCP data segments which lead to a possible timeout.
Disallowing a sender to shrink its congestion window when packets are lost for
any reason, serves as an option to solve this problem..
The Indirect Transmission Control Protocol (I-TCP), and the fast transmit will be
the focus of our discussion are two other protocols are use too to solve this
problem.
Since the traditional UDP does not use acknowledgments and does not perform
flow control it is modified to accommodate the process of registering with a
foreign agent.
Any network application involves at lest two processes in two different hosts
communicating with each other over the network using sockets.
The socket serves as an interface between the application layer and the transport
layer within a host. It is a logical endpoint for communication between two hosts
on a TCP/IP network.
4. What is the role of sequence and acknowledge field numbers contained in the TCP
data unit?
5. List the main services provided by TCP?
6. Explain the structure of TCP data unit.
7. How does TCP setup the connection between the source and the destination?
8. How can the flow control be distinguished from the congestion control?
9. What are the main aspects of the sliding window algorithm?
10. How dose the receive window effectively grant the sender permission to send a
certain number more bytes?
11. How does the round trip time affect the Timeout of the timer?
12. What are the reasons that may cause congestion?
13. What TCP does try to prevent congestion from occurring in the first place?
14. What are the differences between slow start congestion and the Internet congestion
control algorithm?
15. List the main characteristics of the UDP.
16. What are the main fields in the UDP data unit?
17. Where are the UDP and TCP applicable?
18. How dose the correct amount of data stuffed one packet chosen?
19. What are the problems that will take place if either ends of the connection moves?
20. What are the differences between the Indirect and the fast transmit Transmission
Control Protocols?
21. How is the UDP modified to accommodate mobility?
22. What are the differences between the server socket and the client socket?
23. How does the server socket work?
24. How does the client socket work?
B- Identify the choice that best completes the statement or answers the
question.
1. Which two protocols carried within IP datagrams operate at the transport layer of the
OSI model?
I. IMCP II. TCP III. UDP
IV. IGMP V.ARP VI.
a. I, II and III c. II and III
b. II, III and d. V, VI
IV
2. TCP is
a. a data-link layer protocol
b. an application layer protocol
c. a transport layer protocol
d. a network layer protocol
3. Which of the followin protocols uses a handshake to establish a connection before
sending data?
a. Connection-oriented protocol
b. Routing protocol
c. Connectionless protocol
d. File Transfer Protocol
440 COMPUTER NETWORKS AND COMMUNICATIONS