2. The Transport Layer
The transport layer is the heart of the protocol
hierarchy.
The network layer provides end-to-end packet
delivery using datagrams or virtual circuits.
The transport layer builds on the network layer
to provide data transport from a process on a
source machine to a process on a destination
machine with a desired level of reliability
3. The Transport Service
• Services Provided to the Upper Layers
• Transport Service Primitives
• Berkeley Sockets
• An Example of Socket Programming:
An Internet File Server
4. Services Provided to the Upper Layers
The ultimate goal of the transport layer is to provide
efficient, reliable, and cost-effective data transmission
service to its users, normally processes in the
application layer.
To achieve this, the transport layer makes use of the
services provided by the network layer. The software
and/or hardware within the transport layer that does
the work is called the transport entity
5. Services Provided to the Upper Layers
The (logical) relationship of the network, transport, and
application layers .
6. Transport Service Primitives
To allow users to access the transport service, the
transport layer must provide some operations to
application programs, that is, a transport service
interface.
Each transport service has its own interface.
This transport interface is truly bare bones, but it
gives the essential flavor of what a connection-
oriented transport interface has to do. It allows
application programs to establish, use, and then
release connections, which is sufficient for many
applications
7. Transport Service Primitives
the purpose of the transport layer—to provide a
reliable service on top of an unreliable network
To get an idea of what a transport service might be
like, consider the five primitives .
To start with, the server executes a LISTEN primitive,
typically by calling a library procedure that makes a
system call that blocks the server until a client turns
up. When a client wants to talk to the server, it
executes a CONNECT primitive.
The transport entity carries out this primitive by
blocking the caller and sending a packet to the server.
9. Transport Service Primitives
the term segment for messages sent from transport entity
to transport entity. TCP, UDP and other Internet
protocols use this term.
Thus, segments (exchanged by the transport layer) are
contained in packets (exchanged by the network layer).
In turn, these packets are contained in frames (exchanged
by the data link layer). When a frame arrives, the data link
layer processes the frame header and, if the destination
address matches for local delivery, passes the contents of
the frame payload field up to the network entity.
The network entity similarly processes the packet header
and then passes the contents of the packet payload up to
the transport entity
11. Transport Service Primitives (2)
A state diagram for a simple connection management scheme.
Transitions labeled in italics are caused by packet arrivals. The
solid lines show the client's state sequence. The dashed lines show
the server's state sequence.
12. Berkeley Sockets
This is another set of transport primitives, the socket
primitives as they are used for TCP.
Sockets were first released as part of the Berkeley
UNIX 4.2BSD software distribution in 1983.
The primitives are now widely used for Internet
programming on many operating systems, especially
UNIX-based systems, and there is a socket-style API
for Windows called ‘‘winsock.’’ it is used for
inter-process communication (IPC)
13. Berkeley Sockets
socket() creates a new socket of a certain socket type,
identified by an integer number, and allocates system
resources to it.
bind() is typically used on the server side, and associates a
socket with a socket address structure, i.e. a specified local
port number and IP address.
listen() is used on the server side, and causes a bound TCP
socket to enter listening state.
accept() is used on the server side. It accepts a received
incoming attempt to create a new TCP connection from the
remote client, and creates a new socket associated with the
socket address pair of this connection.
This is a methods provided by the Berkeley sockets API library:
14. Berkeley Sockets
connect() is used on the client side, and assigns a
free local port number to a socket. In case of a
TCP socket, it causes an attempt to establish a
new TCP connection.
send() and recv(), or write() and read(),
or sendto() and recvfrom(), are used for sending
and receiving data to/from a remote socket.
close() causes the system to release resources
allocated to a socket. In case of TCP, the
connection is terminated.
15. Berkeley Sockets
The first four primitives in the list are executed in that
order by servers. The SOCKET primitive creates a new
endpoint and allocates table space for it within the
transport entity.
The parameters of the call specify the addressing format to
be used, the type of service desired and the protocol. A
successful SOCKET call returns an ordinary file descriptor
for use in succeeding calls, the same way an OPEN call on
a file does.
Newly created sockets do not have network addresses.
These are assigned using the BIND primitive.
Once a server has bound an address to a socket, remote
clients can connect to it.