TCP Connection Establishment: Lecture No.5

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Lecture No.5 Computer Networks Asst.Lec.

Tareq Imad Ali


TCP Connection Establishment
In some cultures, when two persons meet, they often greet each other by shaking
hands. The act of shaking hands is understood by both parties as a signal for a
friendly greeting. Connections on the network are similar. In TCP connections,
the host client establishes the connection with the server. A TCP connection is
established in three steps:
Step 1 - The initiating client requests a client-to-server communication session
with the server.
Step 2 - The server acknowledges the client-to-server communication session and
requests a server-to-client communication session.
Step 3 - The initiating client acknowledges the server-to-client communication
session.
In the figure (21), show the TCP connection establishment which called TCP
Three-way Handshake

Fig.21. TCP Three-way Handshake Connection Establishment


TCP Session Termination
To close a connection, the Finish (FIN) control flag must be set in the segment
header. To end each one-way TCP session, a two-way handshake, consisting of a
FIN segment and an Acknowledgment (ACK) segment, is used. Therefore, to
terminate a single conversation supported by TCP, four exchanges are needed to
end both sessions. A TCP session termination in four steps:
Step 1 - When the client has no more data to send in the stream, it sends a segment
with the FIN flag set.
Step 2 - The server sends an ACK to acknowledge the receipt of the FIN to
terminate the session from client to server.
Step 3 - The server sends a FIN to the client to terminate the server-to-client
session.
Lecture No.5 Computer Networks Asst.Lec. Tareq Imad Ali
Step 4 - The client responds with an ACK to acknowledge the FIN from the
server.
Then, when all segments have been acknowledged, the session is closed. In the
figure (22), show the TCP connection termination.

Fig.22. TCP Session Termination

Network Layer - OSI Model


Network applications and services on one end device can communicate with
applications and services running on another end device. How is this data
communicated across the network in an efficient way?
The protocols of the OSI model network layer specify addressing and processes
that enable transport layer data to be packaged and transported. The network layer
encapsulation enables data to be passed to a destination within a network (or on
another network) with minimum overhead. During the upcoming weekend, you
decide to visit a schoolmate who is currently at home sick. You know his street
address, but you have never been to his town before. Instead of looking up the
address on the map, you decide to ask town residents for directions after you
arrive by train. The citizens you ask for directions are very helpful. However,
they all have an interesting habit. Instead of explaining the entire route to your
destination, they all tell you, “Take this road and as soon as you arrive at the
nearest crossroad, ask somebody there again.” Figure (23) show how the
packet or message can take a many paths to arrive destination.
Lecture No.5 Computer Networks Asst.Lec. Tareq Imad Ali

Fig.23. Packet Routing


The network layer, or OSI Layer 3, provides services to allow end devices to
exchange data across the network. To accomplish this end-to-end transport, the
network layer uses four basic processes:
- Addressing end devices - End devices must be configured with a unique
IP address for identification on the network.
- Encapsulation - The network layer encapsulates the protocol data unit
(PDU) from the transport layer into a packet. The encapsulation process
adds IP header information, such as the IP address of the source (sending)
and destination (receiving) hosts.
- Routing - The network layer provides services to direct packets to a
destination host on another network. To travel to other networks, the packet
must be processed by a router. The role of the router is to select the best
path and direct packets toward the destination host in a process known as
routing. A packet may cross many intermediary devices before reaching
the destination host. Each router a packet crosses to reach the destination
host is called a hop.
- De-encapsulation - When the packet arrives at the network layer of the
destination host, the host checks the IP header of the packet. If the
destination IP address within the header matches its own IP address, the IP
header is removed from the packet. After the packet is de-encapsulated by
the network layer, the resulting Layer 4 PDU is passed up to the appropriate
service at the transport layer. Figure (24-a to 24-j) illustrate the
encapsulation process.
Lecture No.5 Computer Networks Asst.Lec. Tareq Imad Ali

(a) (b)

(c) (d)

(e) (f)
Lecture No.5 Computer Networks Asst.Lec. Tareq Imad Ali

(g) (h)

(i) (j)
Fig.24. Encapsulation Process
Unlike the transport layer (OSI Layer 4), which manages the data transport
between the processes running on each host, network layer protocols specify the
packet structure and processing used to carry the data from one host to another
host. Operating without regard to the data carried in each packet allows the
network layer to carry packets for multiple types of communications between
multiple hosts. Figure (25-a to 25-i) illustrate the De-encapsulation process.
Lecture No.5 Computer Networks Asst.Lec. Tareq Imad Ali

(a) (b)

(c ) (d)

(e) (f)
Lecture No.5 Computer Networks Asst.Lec. Tareq Imad Ali

(g) (h)

(i)
Fig.25. De-Encapsulation Process
Encapsulating IP
IP encapsulates the transport layer segment or other data by adding an IP header.
This header is used to deliver the packet to the destination host. The IP header
remains the same from the time the packet leaves the source host until it arrives
at the destination host. Figure (26) illustrates how the transport layer PDU is then
encapsulated by the network layer PDU to create an IP packet. The process of
encapsulating data layer by layer enables the services at the different layers
to develop and scale without affecting the other layers. This means the
transport layer segments can be readily packaged by IPv4 or IPv6 or by any new
protocol that might be developed in the future. Routers can implement these
different network layer protocols to operate concurrently over a network. The
routing performed by these intermediate devices only considers the contents of
the network layer packet header. In all cases, the data portion of the packet, that
Lecture No.5 Computer Networks Asst.Lec. Tareq Imad Ali
is, the encapsulated transport layer PDU, remains unchanged during the network
layer processes.

Fig.26. Network Layer PDU

IP is connectionless, meaning that no dedicated end-to-end connection is created


before data is sent. As shown in Figure (27), connectionless communication is
conceptually similar to sending a letter to someone without notifying the recipient
in advance.

Fig.27. Connectionless Communication


Lecture No.5 Computer Networks Asst.Lec. Tareq Imad Ali

Connectionless data communications work on the same principle. As shown in


Figure (28), IP requires no initial exchange of control information to establish an
end-to-end connection before packets are forwarded. IP also does not require
additional fields in the header to maintain an established connection. This process
greatly reduces the overhead of IP. However, with no pre-established end-to-end
connection, senders are unaware whether destination devices are present and
functional when sending packets, nor are they aware if the destination receives
the packet, or if they are able to access and read the packet.

Fig.28. Connectionless Communication

The IP also is a best-effort delivery characteristic of the IP protocol. The IP


protocol does not guarantee that all packets that are delivered are, in fact,
received as shown in the figure (29).

Fig.29. IP best-effort delivery


Lecture No.5 Computer Networks Asst.Lec. Tareq Imad Ali

Unreliable means that IP does not have the capability to manage and recover
from undelivered or corrupt packets. This is because while IP packets are sent
with information about the location of delivery, they contain no information that
can be processed to inform the sender whether delivery was successful. Packets
may arrive at the destination corrupted, out of sequence, or not at all. IP provides
no capability for packet retransmissions if errors occur. If out-of-order packets
are delivered, or packets are missing, then applications using the data, or
upper layer services, must resolve these issues. This allows IP to function very
efficiently. In the TCP/IP protocol suite, reliability is the role of the transport
layer.
IP operates independently of the media that carry the data at lower layers of the
protocol stack. As shown in the figure (30), IP packets can be communicated as
electronic signals over copper cable, as optical signals over fiber, or wirelessly as
radio signals.

Fig.30. IP operates independently of the media

It is the responsibility of the OSI data link layer to take an IP packet and prepare
it for transmission over the communications medium. This means that the
transport of IP packets is not limited to any particular medium. There is, however,
one major characteristic of the media that the network layer considers: the
maximum size of the PDU that each medium can transport. This characteristic
is referred to as the maximum transmission unit (MTU). Part of the control
Lecture No.5 Computer Networks Asst.Lec. Tareq Imad Ali

Communication between the data link layer and the network layer is the
establishment of a maximum size for the packet. The data link layer passes the MTU
value up to the network layer. The network layer then determines how large packets
can be. The default MTU 1500. In some cases, an intermediate device, usually a
router, must split up a packet when forwarding it from one medium to another
medium with a smaller MTU. This process is called fragmenting the packet or
fragmentation.

You might also like