Professional Documents
Culture Documents
The transport layer is the fourth layer from the bottom in the OSI reference model. It is
responsible for message delivery from process running in source computer to the process running
in the destination computer. Transport layer does not perform any function in the intermediate
nodes. It is active only in the end systems. The various functions of transport layer are:
Connectionless Service:
In the service, the packets are sent from sender to receiver without the establishment of
connection.
In such service, packets are not numbered.
The packets may be lost, corrupted, delayed or disordered.
Connectionless service is unreliable.
Transport layer protocol that provides this service is UDP
.
Addressing:
In order to deliver data from one process to another, address is required.
In order to deliver data from one node to another, MAC address is required. Such an
address is implemented at Data Link Layer and is called Physical Addressing.
In order to deliver data from one network to another, IP address is required. Such an
address is implemented at Network Layer and is called Logical Addressing.
Similarly, in order to deliver data from a process running on source to process running on
destination, transport layer defines the Service Point Address or Port Numbers.
.
Port Numbers:
Each communicating process is assigned a specific port number.
In order to select among multiple processes running on a destination host, a port number
is required.
The port numbers are 16 bit integers between 0 and 65,535.
Port numbers are assigned by Internet Assigned Number Authority (IANA).
IANA has divided the port numbers in three categories:
1. Well Known Ports: The ports ranging from 0 to 1023. For e.g.: HTTP: 80,
SMTP: 25, FTP: 21.
2. Registered Ports: The ports ranging from 1024 to 49,151. These are not
controlled by IANA.
3. Dynamic Ports: The ports ranging from 49,152 to 65,535. These can be used by
any process.
Socket Address:
Socket address is a combination of IP address and port number.
In order to provide communication between two different processes on different
networks, both IP address and port number, i.e. socket address is required
TCP Segment
TCP segment is the unit of data transferred between two processes. Each TCP segment consists
of two parts:
1. Header Part
2. Data Part
The TCP datagram format is shown in Figure. A brief explanation of the functions of different
fields is given below:
Source port (16 bits): It defines the port number of the application program in the host of
the sender.
Destination port (16 bits): It defines the port number of the application program in the
host of the receiver;
Sequence number (32 bits): It conveys the receiving host which octet in this sequence
comprises the first byte in the segment
Acknowledgement number (32 bits): This specifies the sequence number of the next octet
that receiver expects to receive.
HLEN (4 bits): This field specifies the number of 32-bit words present in the TCP header.
Control flag bits (6 bits):
o URG: Urgent pointer
o ACK: Indicates whether acknowledge field is valid
o PSH: Push the data without buffering
o RST: Resent the connection
o SYN: Synchronize sequence numbers during connection establishment
o FIN: Terminate the connection
Window (16 bits): Specifies the size of window
Checksum (16 bits): Checksum used for error detection.
User pointer (16 bits): Used only when URG flag is valid
Options: Optional 40 bytes of information
Operation of TCP
TCP is a connection oriented protocol. It establishes a virtual connection between the running
application programs (process) at the two communication end points. TCP uses port number for
this purpose. Each port number is relevant to an application. The stream of data is sent from the
process to the transport layer. TCP establishes a connection between the transport layers of the
transmitter and receiver stations. It then divides the stream of data into units called segments.
Segments are numbered and transmitted one by one. The TCP protocol at the receiver side
checks the arriving segments for error, loss, and duplication. It orders the segments, makes a
stream, and transfers the stream to the receiver side process. TCP provides stream delivery
service. Both the sender and the receiver processes deal with the stream of bytes and are not
aware of stream segmentation in the lower layers. After all segments are transmitted, TCP at the
transmitter side closes the connection.
Connection-oriented service
TCP performs data communication in full-duplex mode, that is both the sender and receiver
processes can send segments simultaneously. For connection establishment in full-duplex mode,
a four-way protocol can be used. However, the second and third steps can be combined to form a
three-way handshaking protocol with the following three steps as shown in figure.
Step 1: The client sends SYN segment, which includes, source and destination port
numbers, and an initialization sequence number (ISN), which is essentially the byte
number to be sent from the client to the server.
Step 2: The server sends a segment, which is a two-in-one segment. It acknowledges the
receipt of the previous segment and it also acts as initialization segment for the server.
Step3: The sends an ACK segment, which acknowledges the receipt of the second
segment.
Application of TCP
Bandwidth Management
Error Control &and Flow Control
Multiplexing
Congestion Control
Timer Management
Crash Recovery
User Datagram protocol (UDP)
UDP Datagram
The UDP datagram format is shown in Figure. A brief description of different fields of the
datagram is given below:
Source port (16 bits): It defines the port number of the application program in the host of
the sender
Destination port (16 bits): It defines the port number of the application program in the
host of the receiver
Length: It provides a count of octets in the UDP datagram, minimum length = 8
Checksum: It is optional, 0 in case it is not in use
Operation of UDP
UDP serves the application layer and network layer like TCP, but with more ease. UDP uses port
number for application to application communication, but it does not establish a connection as
TCP does, so it is termed as connectionless. UDP sender transmits the data unit of the upper
layer process and does not care if the transmission is reliable. In other words, if the data unit gets
lost due to the congestion or duplicated in the path, UDP does not recognize it. UDP does not
deploy ACK, flow and congestion control. Thats why UDP is unreliable. There is minimal error
detection, and erroneous packets will be simply discarded. The beauty of UDP is its simplicity.
The only overhead that UDP adds to the packet is to establish process to process communication,
rather than a host to host communication of IP layer. Therefore, UDP is very suitable for small
message communications or applications that do not need strong reliability, such as client/server
request/reply or video conferencing. It can also be used in applications that have internal error
and flow control, such as Trivial File Transfer Protocol (TFTP).
UDP application
BSD Sockets generally relies upon client/server architecture. For TCP communications, one host
listens for incoming connection requests. When a request arrives, the server host will accept it, at
which point data can be transferred between the hosts. UDP is also allowed to establish a
connection, though it is not required. Data can simply be sent to or received from a host.
The Sockets API makes use of two mechanisms to deliver data to the application level: ports and
sockets. Ports and sockets are one of the most misunderstood concepts in sockets programming.
All TCP/IP stacks have 65,536 ports for both TCP and UDP. There is a full compliment of ports
for UDP (numbered 0-65535) and another full compliment, with the same numbering scheme,
for TCP. The two sets do not overlap. Thus, communication over both TCP and UDP can take
place on port 15 (for example) at the same time.
A port is not a physical interface - it is a concept that simplifies the concept of Internet
communications for humans. Upon receiving a packet, the protocol stack directs it to the specific
port. If there is no application listening on that port, the packet is discarded and an error may be
returned to the sender. However, applications can create sockets, which allow them to attach to a
port. Once an application has created a socket and bound it to a port, data destined to that port
will be delivered to the application. This is why the term socket is used - it is the connection
mechanism between the outside world (the ports) and the application. A common
misunderstanding is that sockets-based systems can only communicate with other sockets-based
systems. This is not true. TCP/IP or UDP/IP communications are handled at the port level - the
underlying protocols do not care what mechanisms exist above the port. Any Internet host can
communicate with any other, be it Berkeley Sockets, WinSock, or anything else. "Sockets" is
just an API that allows the programmer to access Internet functionality - it does not modify the
manner in which communications occur. Let us use the example of an office building to illustrate
how sockets and ports relate to each other. The building itself is analogous to an Internet host.
Each office represents a port, the receptionist is a socket, and the business itself is an application.
Suppose you are a visitor to this building, looking for a particular business. You wander in, and
get directed to the appropriate office. You enter the office, and speak with the receptionist, who
then relays your message to the business itself. If there is nobody in the office, you leave. To
rephrase the above in sockets terminology: A packet is transmitted to a host. It eventually gets to
the correct port, at which point the socket conveys the packet's data to the application. If there is
no socket at the destination port, the packet is discarded.