Transport Layer
Transport Layer
• Listen: executed by server. It means server is ready to accept connection. It blocks the
process of server until connection request comes.
• Connect: executed by client to request the connection. It sends connection req.
TPDU(transport protocol data unit) (packet) to server. If server is able to handle
connection then it sends Connection accepted TPDU.
• Send: executed to send data to other end.
• Receive: when ever client or server is waiting for data, It executes Receive primitive. This
is also blocking primitive.
• Disconnect: to disconnect connection.
• Two variants of disconnect. 1. Asymmetric: either side issues disconnect, connection will
be released. 2. Symmetric: both the side need to separately execute disconnect.
Berkeley Sockets
Socket is used for establishing a TCP Connection
The socket primitives for TCP
Elements of Transport Protocols
• Addressing
• Connection Establishment
• Connection Release
• Flow Control and Buffering
• Multiplexing
• Crash Recovery
Addressing
• When an application (e.g., a user) process wishes to set up a connection to a
remote application process, it must specify which one to connect to.
• The method normally used is to define transport addresses to which processes
can listen for connection requests. In the Internet, these end points are called
ports.
• We will use the generic term TSAP, (Transport Service Access Point).The
analogous end points in the network layer (i.e., network layer addresses) are then
called NSAPs. IP addresses are examples of NSAPs
Addressing
Three-way handshake protocol
• Once both transport entities have agreed on the initial sequence number, any
sliding window protocol can be used for data flow control.
• Three-way handshake protocol is used. This protocol does not require both sides
to begin sending with the same sequence number.
• Host 1 chooses a sequence number, x, and sends a CONNECTION REQUEST TPDU
containing it to host 2.
• Host 2 replies with an ACK TPDU acknowledging x and announcing its own initial
sequence number, y.
• Finally, host 1 acknowledges host 2's choice of an initial sequence number in the
first data TPDU that it sends.
Connection Establishment
CR denotes CONNECTION REQUEST. (a) Normal operation, (b) Old CONNECTION
REQUEST appearing out of nowhere. (c) Duplicate CONNECTION REQUEST and
duplicate ACK.
Connection Release
Figure: Four protocol scenarios for releasing a connection. (a) Normal case of a three-way handshake.
(b) final ACK lost.
Connection Release
Figure : (c) Response lost. (d) Response lost and subsequent DRs lost.
Flow Control And Buffering
Figure (a) Chained fixed-size buffers. (b) Chained variable-sized buffers. (c) One large circular buffer per
connection
Multiplexing
• If hosts and routers are subject to crashes, recovery from these crashes becomes
an issue. If the transport entity is entirely within the hosts, recovery from
network and router crashes is straightforward.
• 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.
Crash Recovery
• Consider, for example, the situation in which the server's transport entity
first sends an acknowledgement, and then, when the acknowledgement
has been sent, writes to the application process. Writing a TPDU onto the
output stream and sending an acknowledgement are two distinct events
that cannot be done simultaneously.
• If a crash occurs after the acknowledgement has been sent but before the
write has been done, the client will receive the acknowledgement and
thus be in state S0.
• when the crash recovery announcement arrives. The client will therefore
not retransmit,(incorrectly) thinking that the TPDU has arrived. This
decision by the client leads to a missingTPDU.
Crash Recovery
• At this point you may be thinking: ''That problem can be solved easily.
All you have to do is reprogram the transport entity to first do the
write and then send the acknowledgement.''
• Try again. Imagine that the write has been done but the crash occurs
before the acknowledgement can be sent. The client will be in state
S1 and thus retransmit, leading to an undetected duplicate TPDU in
the output stream to the server application process.
A Simple Transport Protocol
• The Example Service Primitives
• Our concrete service definition consists of five primitives: CONNECT, LISTEN,
DISCONECT, SEND, and RECEIVE.
• Each primitive corresponds exactly to a library procedure that executes the primitive.
• The parameters for the service primitives and library procedures are as follows:
• – Connum = LISTEN(local)
• – Connum = CONNECT(local, remote)
• – Status = SEND (connum, buffer, bytes)
• – Status = RECEIVE (connum, buffer, bytes)
• – Status = DISCONNECT (connum)
The Example Service Primitives
• UDP provides a way for applications to send encapsulated IP datagrams and send
them without having to establish a connection.
• UDP transmits segments consisting of an 8-byte header followed by the payload.
• When a UDP packet arrives, its payload is handed to the process attached to the
destination port.
• The source port is primarily needed when a reply must be sent back to the source.
• The UDP length field includes the 8-byte header and the data. The UDP checksum is
optional and stored as 0 if not computed.
• UDP does not do flow control, error control, or retransmission upon receipt of a bad
segment.
• One area where UDP is especially useful is in client-server situations.
The UDP header
Remote Procedure Call
• When a process on machine 1 calls a procedure on machine 2, the
calling process on 1 is suspended and execution of the called
procedure takes place on 2.
• Information can be transported from the caller to the callee in the
parameters and can come back in the procedure result.
• No message passing is visible to the programmer. This technique is
known as RPC (Remote Procedure Call).
• Traditionally, the calling procedure is known as the client and the
called procedure is known as the server.
Remote Procedure Call
• Traditionally, the calling procedure is known as the client and the called
procedure is known as the server.
• The idea behind RPC is to make a remote procedure call look as much as
possible like a local one.
• In the simplest form, to call a remote procedure,
• The client program must be bound with a small library procedure, called the
client stub, that represents the server procedure in the client's address space.
• Similarly, the server is bound with a procedure called the server stub. These
procedures hide the fact that the procedure call from the client to the server
is not local.
Remote Procedure Call
• The actual steps in making an RPC are :
• Step 1 is the client calling the client stub. This call is a local procedure call, with
the parameters pushed onto the stack in the normal way.
• Step 2 is the client stub packing the parameters into a message and making a
system call to send the message. Packing the parameters is called marshaling.
• Step 3 is the kernel sending the message from the client machine to the server
machine.
• Step 4 is the kernel passing the incoming packet to the server stub. Finally,
• Step 5 is the server stub calling the server procedure with the unmarshaled
parameters. The reply traces the same path in the other direction.
Remote Procedure Call
The Real-Time Transport Protocol
• At the other end of the socket (in the operating system kernel), UDP packets are
generated and embedded in IP packets. If the computer is on an Ethernet, the IP
packets are then put in Ethernet frames for transmission.
• Figure: (a)The position of RTP in the protocol stack. (b) Packet nesting
The Real-Time Transport Protocol
• It is a little hard to say which layer RTP is in. Since it runs in user space and is linked to
the application program,
• It certainly looks like an application protocol.
• On the other hand, it is a generic, application-independent protocol that just provides
transport facilities,
• so it also looks like a transport protocol.
• Probably the best description is that it is a transport protocol that is implemented in the
application layer.
• The basic function of RTP is to multiplex several real-time data streams onto a single
stream of UDP packets.
• The UDP stream can be sent to a single destination (unicasting) or to multiple
destinations (multicasting).
The Real-Time Transport Protocol
• Each packet sent in an RTP stream is given a number one higher than its
predecessor. This numbering allows the destination to determine if any packets
are missing.
• If a packet is missing, the best action for the destination to take is to approximate
the missing value by interpolation.
• Retransmission is not a practical option since the retransmitted packet would
probably arrive too late to be useful.
• As a consequence, RTP has no flow control, no error control, no
acknowledgements, and no mechanism to request retransmissions
The RTP header
The RTP header
• The RTP header consists of three 32-bit words and potentially some extensions.
• The first word contains the Version field, which is already at 2.
• The P bit indicates that the packet has been padded to a multiple of 4 bytes. The last
padding byte tells how many bytes were added.
• The X bit indicates that an extension header is present, the first word of the extension
gives the length.
• The CC field tells how many contributing sources are present, from 0 to 15.
• The M bit is an application-specific marker bit. It can be used to mark the start of a video
frame, the start of a word in an audio channel, or something else that the application
understands.
• The Payload type field tells which encoding algorithm has been used (e.g.,
uncompressed 8-bit audio, MP3, etc.).
The RTP header
• The Sequence number is just a counter that is incremented on each RTP packet sent. It is
used to detect lost packets.
• 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 at the receiver by decoupling the
playback from the packet arrival time.
• 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.
• Finally, the Contributing source identifiers, if any, are used when mixers are present in the
studio.
• RTP has a little sister protocol (little sibling protocol?) called RTCP (Realtime Transport
Control Protocol). It handles feedback, synchronization, and the user interface but does not
transport any data.
Introduction to TCP
• TCP (Transmission Control Protocol) was specifically designed to
provide a reliable end-to-end byte stream over an unreliable
internetwork.
• An internetwork differs from a single network because different parts
may have wildly different topologies, bandwidths, delays, packet sizes,
and other parameters.
• The IP layer gives no guarantee that datagrams will be delivered
properly, so it is up to TCP to time out and retransmit them as need
be.
• Datagrams that do arrive may well do so in the wrong order; it is also
up to TCP to reassemble them into messages in the proper sequence.
• In short, TCP must furnish the reliability that most users want and that
IP does not provide.
The TCP Service Model
• TCP service is obtained by both the sender and receiver creating end
points, called sockets.
• Each socket has a socket number (address) consisting of the IP address
of the host and a 16-bit number local to that host, called a port.
• A port is the TCP name for a TSAP.
• For TCP service to be obtained, a connection must be explicitly
established between a socket on the sending machine and a socket on
the receiving machine.
• Port numbers below 1024 are called well-known ports and are
reserved for standard services.
• For example, any process wishing to establish a connection to a host
to transfer a file using FTP can connect to the destination host's port
21 to contact its FTP daemon.
The TCP Service Model
TCP Header.
The TCP Segment Header
• Every segment begins with a fixed-format, 20-byte header. The fixed
header may be followed by header options.
• After the options, if any, up to 65,535 - 20 - 20 = 65,495 data bytes
may follow, where the first 20 refer to the IP header and the second to
the TCP header.
• Segments without any data are legal and are commonly used for
acknowledgements and control messages.
• The Source port and Destination port fields identify the local end
points of the connection.
• The source and destination end points together identify the
connection.
• A port plus its host's IP address forms a 48-bit unique end point.
The TCP Segment Header
6-31