Hvi 4
Hvi 4
TRANSPORT LAYER
UDP – Segment header
Remote procedure call
Real-time transport protocols
TCP – service model
Protocol, Segment header
Connection establishment
Connection release
Sliding window
Timer management
Congestion control
UNIT-IV
TRANSPORT LAYER
The Transport Service
• Services Provided to the Upper Layers
• Transport Service Primitives
• Berkeley Sockets
• It is the heart of the whole protocol hierarchy.
• Its task is to provide reliable, cost-effective data transport from the source
machine to the destination machine, independently of the physical network
or networks currently in use.
• In the following sections we will provide an introduction to the transport
service.
• We look at what kind of service is provided to the application layer.
• To make the issue of transport service more concrete, we will examine two
sets of transport layer primitives.
SERVICES PROVIDED TO THE UPPER LAYERS
• To achieve this goal, the transport layer makes use of the services
provided by the network layer.
• The hardware and/or software within the transport layer that does the
work is called the transport entity.
• The transport entity can be located in the operating system kernel, in a
separate user process, in a library package bound into network
applications, or conceivably on the network interface card.
• The (logical) relationship of the network, transport, and application
layers is illustrated in next slide.
Connection Establishment
• Establishing a connection sounds easy, but it is actually surprisingly tricky.
• At first glance, it would seem sufficient for one transport entity to just send
a CONNECTION REQUEST TPDU to the destination and wait for a
CONNECTION ACCEPTED reply.
• The problem occurs when the network can lose, store, and duplicate
packets. This behavior causes serious complications.
• The problem is with delayed duplicates.
• Solutions:
• One way is to use throw-away transport addresses.
• Another possibility is to give each connection a connection identifier .
• transport entity to maintain a certain amount of history information
indefinitely.
• Instead, Rather than allowing packets to live forever within the subnet, we
must devise a mechanism to kill off aged packets that are still hobbling
about.
• If we can ensure that no packet lives longer than some known time, the
problem becomes somewhat more manageable.
• Packet lifetime can be restricted to a known maximum using one (or more)
of the following techniques:
• Restricted subnet design.
• includes any method that prevents packets from looping
• Putting a hop counter in each packet.
• Timestamping each packet.
• The clock-based method solves the delayed duplicate problem for data
TPDUs, but for this method to be useful, a connection must first be
established.
• Since control TPDUs may also be delayed, there is a potential problem in
getting both sides to agree on the initial sequence number.
• To solve this problem, Tomlinson (1975) introduced the three-way
handshake.
• This establishment protocol does not require both sides to begin sending
with the same sequence number.
Connection Release
• There are two styles of terminating a connection: asymmetric release and
symmetric release.
• Asymmetric release is the way the telephone system works: when one
party hangs up, the connection is broken.
• Symmetric release treats the connection as two separate unidirectional
connections and requires each one to be released separately.
Asymmetric release is abrupt (sudden / unexpected) and may result in data loss.
Connection Release
Asymmetric release is abrupt (sudden / unexpected) and may result in data loss.
• Potential problems with buffer allocation schemes of this kind can arise in
datagram networks if control TPDUs can get lost.
• Look at line 16. B has now allocated more buffers to A, but the allocation
TPDU was lost. Since control TPDUs are not sequenced or timed out, A is
now deadlocked.
• To prevent this situation, each host should periodically send control TPDUs
giving the acknowledgement and buffer status on each connection. That
way, the deadlock will be broken, sooner or later.
• When buffer space no longer limits the maximum flow, another bottleneck
will appear: the carrying capacity of the subnet.
• If adjacent routers can exchange at most x packets/sec and there are k
disjoint paths between a pair of hosts, there is no way that those hosts can
exchange more than kx TPDUs/sec, no matter how much buffer space is
available at each end.
• If the sender pushes too hard (i.e., sends more than kx TPDUs/sec), the
subnet will become congested because it will be unable to deliver TPDUs as
fast as they are coming in.
Multiplexing
• In the transport layer the need for multiplexing can arise in a number of
ways.
• For example, if only one network address is available on a host, all
transport connections on that machine have to use it.
• When a TPDU comes in, some way is needed to tell which process to give it
to. This situation, called upward multiplexing.
• Suppose, that a subnet uses virtual circuits internally and imposes a
maximum data rate on each one.
• If a user needs more bandwidth than one virtual circuit can provide, a way
out is to open multiple network connections and distribute the traffic
among them on a round-robin basis, as indicated in Fig. 6-17(b). This is
called downward multiplexing.
Elements of Transport Protocols
• Addressing
• Connection Establishment
• Connection Release
• Flow Control and Buffering
• Multiplexing
• Crash Recovery
Crash Recovery
Different combinations of client and server strategy.
• In an attempt to recover its previous status, the server might send a
broadcast TPDU to all other hosts, announcing that it had just crashed and
requesting that its clients inform it of the status of all open connections.
• Each client can be in one of two states: one TPDU outstanding, S1, or no
TPDUs outstanding, S0.
• Based on only this state information, the client must decide whether to
retransmit the most recent TPDU.
(a) The position of RTP in the protocol stack. (b) Packet nesting.
• Because RTP just uses normal UDP, its packets are not treated specially by
the routers unless some normal IP quality-of-service features are enabled.
• The last padding byte tells how many bytes were added.
• The format and meaning of the extension header are not defined. The only
thing that is defined is that the first word of the extension gives the length.
• The CC field tells how many contributing sources are present. It can be used
to , from 0 to 15 .
• The Payload type field tells which encoding algorithm has been used (e.g.,
uncompressed 8-bit audio, MP3, etc.).
• The timestamp is produced by the stream's source to note when the first
sample in the packet was made. This value can help reduce jitter.
• The Synchronization source identifier tells which stream the packet belongs
to. It is the method used to multiplex and demultiplex multiple data
streams onto a single stream of UDP packets.
• This information can be used by the encoding process to increase the data
rate (and give better quality) when the network is functioning well and to
cut back the data rate when there is trouble in the network.
• Transactional TCP
Transitional TCP
The nine packets are as follows:
• The efficiency of RPC using UDP (just two messages) with the reliability of
TCP. The answer is: Almost.
• The central idea here is to modify the standard connection setup sequence
slightly to allow the transfer of data during setup. The T/TCP protocol is
illustrated in Fig. 6-40(b).
• The client's first packet contains the SYN bit, the request itself, and the FIN.
In effect it says: I want to establish a connection, here is the data, and I am
done.
• When the server gets the request, it looks up or computes the reply, and
chooses how to respond. If the reply fits in one packet, it gives the reply of
Fig. 6-40(b), which says: I acknowledge your FIN, here is the answer, and I
am done. The client then acknowledges the server's FIN and the protocol
terminates in three messages.
• TCP service is obtained by both the sender and receiver creating end points,
called sockets.
• Port numbers below 1024 are called well-known ports and are reserved for
standard services.
• For example, if the sending process does four 512-byte writes to a TCP
stream, these data may be delivered to the receiving process as four 512-
byte chunks, two 1024-byte chunks, one 2048-byte chunk , or some other
way.
(b) The 2048 bytes of data delivered to the application in a single READ CALL.
The TCP Segment Header
• Source port address. The source port address defines the application
program in the source computer.
• Acknowledgement number.
• This number is valid only if the ACK bit in the control field(explained later) is
set. In this case, it defines the byte sequence number that is next expected.
• Header Length (HLEN).
• The four-bit HLEN field indicates the number of 32-bit (four-byte) words in
the TCP header.
• CWR is set to signal Congestion Window Reduced from the TCP sender to
the TCP receiver so that it knows the sender has slowed down and can stop
sending the ECN-Echo.
• URG is set to 1 if the Urgent pointer is in use. The Urgent pointer is used to
indicate a byte offset from the current sequence number at which urgent
data are to be found. This facility is in lieu of interrupt messages.
• The PSH bit indicates PUSHed data. The receiver is hereby kindly requested
to deliver the data to the application upon arrival and not buffer it until a
full buffer has been received (which it might otherwise do for efficiency).
• The RST bit is used to reset a connection that has become confused due to
a host crash or some other reason. It is also used to reject an invalid
segment or refuse an attempt to open a connection.
• The connection request has SYN = 1 and ACK = 0 to indicate that the
piggyback acknowledgement field is not in use.
• Both SYN and FIN segments have sequence numbers and are thus
guaranteed to be processed in the correct order.
• Window size. The window is a 16-bit field that defines the size of the sliding
window.
• Urgent pointer. This is the last required field in the header. Its value is valid
only if the URG bit in the control field is set. In this case, the sender is
informing the receiver that there are urgent data in the data portion of the
segment. This pointer defines the end of urgent data and the start of
normal data.
• Options and padding. The remainder of the TCP header defines the
optional fields. They are used to convey additional information to the
receiver or for alignment purposes.
The TCP Segment Header (2)
The pseudoheader included in the TCP checksum.
• To establish a connection, one side, say, the server, passively waits for an
incoming connection by executing the LISTEN and ACCEPT primitives, either
specifying a specific source or nobody in particular.
• The other side, say, the client, executes a CONNECT primitive, specifying
the IP address and port to which it wants to connect, the maximum TCP
segment size it is willing to accept, and optionally some user data (e.g., a
password). The CONNECT primitive sends a TCP segment with the SYN bit
on and ACK bit off and waits for a response.
• When this segment arrives at the destination, the TCP entity there checks
to see if there is a process that has done a LISTEN on the port given in the
Destination port field.
• If not, it sends a reply with the RST bit on to reject the connection
(a) TCP connection establishment in the normal case.
• To release a connection, either party can send a TCP segment with the FIN
bit set, which means that it has no more data to transmit.
• When the FIN is acknowledged, that direction is shut down for new data.
• When both directions have been shut down, the connection is released.
• The other side will eventually notice that nobody seems to be listening to it
any more and will time out as well.
• What Nagle suggested is simple: when data come into the sender in small
pieces, just send the first piece and buffer all the rest until the first piece is
acknowledged.
• Then send all the buffered data in one TCP segment and start buffering
again until the next segment is acknowledged.
• That is, only one short packet can be outstanding at any time.
• If many pieces of data are sent by the application in one round-trip time,
Nagle’s algorithm will put the many pieces in one segment, greatly reducing
the bandwidth used.
• Specifically, the receiver should not send a window update until it can
handle the maximum segment size it advertised when the connection was
established or until its buffer is half empty, whichever is smaller
• Nagle’s algorithm and Clark’s solution to the silly window syndrome are
complementary.
• Nagle was trying to solve the problem caused by the sending application
delivering data to TCP a byte at a time.
• Clark was trying to solve the problem of the receiving application sucking
the data up from TCP a byte at a time. Both solutions are valid and can
work together.
• The goal is for the sender not to send small segments and the receiver not
to ask for them.
• Acknowledgements can be sent only when all the data up to the byte
acknowledged have been received. This is called a cumulative
acknowledgement.
– Retransmission timer.
– Persistence timer
– Keepalive timer
• If, on the other hand, the timer goes off before the acknowledgement
comes in, the segment is retransmitted.
• The question that arises is: How long should the timeout interval be?
• Since acknowledgements are rarely delayed in the data link layer (due to
lack of congestion), the absence of an acknowledgement at the expected
time generally means either the frame or the acknowledgement has been
lost.
Persistence timer
• It is designed to prevent the following deadlock.
• The receiver sends an acknowledgement with a window size of 0, telling the
sender to wait. Later, the receiver updates the window, but the packet with
the update is lost. Now both the sender and the receiver are waiting for
each other to do something.
• When the persistence timer goes off, the sender transmits a probe to the
receiver. The response to the probe gives the window size. If it is still zero,
the persistence timer is set again and the cycle repeats. If it is nonzero, data
can now be sent.
Keepalive timer
• When a connection has been idle for a long time, the keepalive timer may
go off to cause one side to check whether the other side is still there.
• If it fails to respond, the connection is terminated.
TCP Congestion Control
• A transport protocol using an AIMD (Additive Increase Multiplicative
Decrease) control law in response to binary congestion signals from the
network would converge to a fair and efficient bandwidth allocation.
• TCP congestion control is based on implementing this approach using a
window and with packet loss as the binary signal.
• To do so, TCP maintains a congestion window whose size is the number of
bytes the sender may have in the network at any time.
• The corresponding rate is the window size divided by the round-trip time of
the connection.
• TCP adjusts the size of the window according to the AIMD rule.
• Before discussing how TCP reacts to congestion, let us first describe what it
does to try to prevent congestion from occurring in the first place.
• When a connection is established, a suitable window size has to be chosen.
• The receiver can specify a window based on its buffer size.
• If the sender sticks to this window size, problems will not occur due to
buffer overflow at the receiving end, but they may still occur due to
internal congestion within the network.
• The below figure shows what happens when a sender on a fast network
(the 1- Gbps link) sends a small burst of four packets to a receiver on a slow
network (the 1- Mbps link) that is the bottleneck or slowest part of the
path. Initially the four packets travel over the link as quickly as they can be
sent by the sender. At the router, they are queued while being sent
because it takes longer to send a packet over the slow link than to receive
the next packet over the fast link. But the queue is not large because only a
small number of packets were sent at once. Note the increased length of
the packets on the slow link. The same packet, of 1 KB say, is now longer
because it takes more time to send it on a slow link than on a fast one.
• the acknowledgements return to the sender at about the rate that packets
can be sent over the slowest link in the path. This is precisely the rate that
the sender wants to use.
• If it injects new packets into the network at this rate, they will be sent as
fast as the slow link permits, but they will not queue up and congest any
router along the path.
• This timing is known as an ack clock. It is an essential part of TCP. By using
an ack clock, TCP smoothes out traffic and avoids unnecessary queues at
routers.
• A second consideration is that the AIMD rule will take a very long time to
reach a good operating point on fast networks if the congestion window is
started from a small size.
• To keep slow start under control, the sender keeps a threshold for the
connection called the slow start threshold. Initially this value is set
arbitrarily high, to the size of the flow control window, so that it will not
limit the connection.
• TCP keeps increasing the congestion window in slow start until a timeout
occurs or the congestion window exceeds the threshold.
• Whenever a packet loss is detected, for example, by a timeout, the slow
start threshold is set to be half of the congestion window and the entire
process is restarted.
• Additive increase is shown in below figure, for the same situation as slow
start. At the end of every RTT, the sender’s congestion window has grown
enough that it can inject an additional packet into the network.
Additive increase from an initial congestion window of one segment