Chapter 3 and 4
Chapter 3 and 4
Transport Layer
o Transport layer is used to provide the communication services directly to the application
processes running on different hosts. The transport layer provides a logical communication
between application processes running on different hosts. The transport layer protocols
are implemented in the end systems but not in the network routers. TCP and UDP are two
transport layer protocols that provide a different set of services to the network layer. All
layered model, the transport layer interacts with the functions of the session layer. Many
protocols combine session, presentation, and application layer protocols into a single
layer known as the application layer. In these cases, delivery to the session layer means
the delivery to the application layer. Data generated by an application on one machine
The services provided by the transport layer protocols can be divided into five
categories:
1. End-to-end delivery
2. Addressing
3. Reliable delivery
4. Flow control
5. Multiplexing
End-to-end Delivery:
• The transport layer transmits the entire message to the destination. To ensures the
• The transport layer provides reliability services by retransmitting the lost and
damaged packets.
Error Control
The data link layer also provides the error handling mechanism, but it ensures only node-
tonode error-free delivery. However, node-to-node reliability does not ensure the end-to-
end reliability. The data link layer checks for the error between each network. If an error is
introduced inside one of the routers, then this error will not be caught by the data link layer.
Data link layer only detects those errors that have been introduced between the beginning
and end of the link. Therefore, the transport layer performs the checking for the errors end-
Sequence control
On the sending end, the transport layer is responsible for ensuring that the packets received
from the upper layers can be used by the lower layers. On the receiving end, it ensures that
Loss control
The transport layer ensures that all the fragments of a transmission arrive at the destination,
not some of them. On the sending end, all the fragments of transmission are given sequence
numbers by a transport layer. The sequence numbers allow to identify the missing segment.
Duplication control
The transport layer guarantees that no duplicate data arrive at the destination. Sequence
numbers are used to identify the lost packets; similarly, it allows the receiver to identify and
Flow control
Flow control is used to prevent the sender from overwhelming the receiver.
If the receiver is overloaded with too much data, then the receiver discards the packets and asking
for the retransmission of packets. This increases network congestion and thus, reducing the system
performance. The transport layer is responsible for flow control. It uses the sliding window
protocol that makes the data transmission more efficient as well as it controls the flow of data so
that the receiver does not become overwhelmed. Sliding window protocol is byte oriented rather
Addressing
Whenever we need to deliver something to one specific destination among many, we need
an address. At the data link layer, we need a MAC address to choose one node among several
nodes if the connection is not point-to-point. A frame in the data link layer needs a
destination MAC address for delivery and a source address for the next node's reply. At the
network layer, we need an IP address to choose one host among millions. A datagram in the
network layer needs a destination IP address for delivery and a source IP address for the
destination's reply. At the transport layer, we need a transport layer address, called a port
number, to choose among multiple processes running on the destination host. A port
number is a 16-bit number, ranging from 0 to 65536, assigned to an application process for
identification on the Internet. Some port numbers are reserved for popular Internet
application. For example, port 80 is reserved for the Web Server. Whenever a new Internet
application is developed, a port number must be assigned to it. The destination port number
is needed for delivery; the source port number is needed for the replay. Ports are the essential
ways to address multiple entities in the same location. Using port addressing it is possible to
Well-known ports - These are permanent port numbers. They range between 0 to [Link]
Registered ports - The ports ranging from 1024 to 49,151 are not assigned or controlled.
Ephemeral ports (Dynamic Ports) – These are temporary port numbers. They range between
The transport layer protocols need to know which upper-layer protocols are communicating.
The addressing mechanism allows multiplexing and demultiplexing by the transport layer.
Multiplexing:
Whenever an entity accepts items from more than one source, this is referred to as
multiplexing (many to one). At the sender side, there may be several processes that need to
send packets. However, there is only one transport layer protocol at any time. This is a many-
to-one relationship and requires multiplexing. The protocol accepts messages from different
processes, differentiated by their assigned port numbers. After adding the header, the
Demultiplexing:
Whenever an entity delivers items to more than one source, this is referred to as
demultiplexing (one to many).At the receiver site, the relationship is one-to-many and
requires demultiplexing. The transport layer receives datagrams from the network layer.
After error checking and dropping of the header, the transport layer delivers each message
Data communication is a telecommunication network to send and receive data between two
or more computers over the same or different network. There are two ways to establish a
1. Connection-oriented
2. connectionless service
Connection-oriented service
after the telephone system. A connection-oriented service is used to create an end to end
connection between the sender and the receiver before transmitting the data over the
receiver in the same order as the sender has sent them. It uses a handshake method that
creates a connection between the receiver and sender for transmitting the data over the
2. Information is sent.
Step 2: the server receives the SYN packet from the client node
Step 3: client node receives the SYN/ACK from the server and responds with an ACK
packet
1. No response : if the system receiving the handshake is not available or does not
support the protocol the initiating system uses, it may not respond to the request.
3. Connection accepted : the system receiving the handshake is available, receives the
Congestions( a situation in which a place is too blocked or crowded) are less frequent.
Sequencing of data packets is guaranteed. Problems related to duplicate data packets are
network resources. In the case of router failures or network congestions, there are no
alternative ways to continue communication. The lesser speed of connection due to the
time is taken for establishing and relinquishing the connection. This allocation of
Connectionless Service
Connectionless service is used in the network system to transfer data from one end to
another end without creating any connection. It is not a reliable network service because
it does not guarantee the transfer of data packets to the receiver, and data packets can be
received in any order to the receiver. Therefore we can say that the data packet does not
Reliable
End stations running reliable protocols will work together to verify the transmission
of data to ensure accuracy and integrity of the data. A reliable system will set up a
connection and verify that all data transmitted is controlled in an orderly fashion, is
received in the correct order. TCP guarantees accurate and complete delivery of data
Unreliable
Unreliable protocols make no effort to set up a connection, they don't check to see if
the data was received and usually don't make any provisions for recovering from
protocol.
Transport Layer protocols
UDP Protocol
prior to data transfer. UDP enables the process to process communication, whereas
the TCP provides host to host communication. Since UDP sends the messages in the
UDP provides no acknowledgment mechanism: which means that the receiver does not
send the acknowledgment for the received packet, and the sender also does not wait for
Connectionless: The UDP is a connectionless protocol as it does not create a virtual path
to transfer the data. It does not use the virtual path, so packets are sent in different paths
between the sender and the receiver, which leads to the loss of packets or received out of
order.
No virtual path is required to transfer the data. But there is a chance that the individual
Stateless : It is a stateless protocol that means that the sender does not get the
Source port number: it is 16-bit information that identifies which port is going to send
the packet.
Destination port number: it identifies which port is going to accept the information.
destination machine.
Length: it is 16-bit field that specifies the entire length of the UDP packet that includes
Checksum: it is a 16-bits field, and it is an optional field. This checksum field checks
4. UDP is used for some routing update protocols like RIP (routing information
protocol).
5. Used for simple request response communication when size of data is less.
TCP
TCP stands for transmission control protocol. It provides full transport layer services
between both the ends of the transmission. The main functionality of the TCP is to
take the data from the application/session layer. Then it divides the data into a several
packets, provides numbering to these packets, and finally transmits these packets to
communication should be good and reliable. For example, we want to view a web
page, then we expect that nothing should be missing on the page, or we want to
download a file, then we require a complete file, i.e., Nothing should be missing either
it could be a text or an image. This can only be possible due to the TCP.
Transport layer protocol: TCP is a transport layer protocol as it is used in transmitting the
of bytes. TCP group the bytes in the form of TCP segments and then passed it to the IP
Data delivery: TCP protocol ensures that the data is received correctly, no data is missing
and in order. If TCP protocol is not used, then the incorrect data can be received or out
of order.
occurs only after the connection establishment. When the data transfer is completed, then
handshake. In a three-way handshake, the first sender sends the syn message to the
receiver then the receiver sends back the syn ack message to confirm that the message has
been received. After receiving the syn ack message, the sender sends the
intended receiver in the same order in which it is sent. It orders and numbers each
segment so that the TCP layer on the destination side can reassemble them based on
their ordering.
Reliability: TCP assigns a sequence number to each byte transmitted and expects a
positive acknowledgement from the receiving TCP. If ack is not received within a
timeout interval, then the data is retransmitted to the destination. The receiving TCP
uses the sequence number to reassemble the segments if they arrive out of order or to
Flow control
When receiving TCP sends an acknowledgement back to the sender indicating the
number the bytes it can receive without overflowing its internal buffer. The number of
bytes is sent in ack in the form of the highest sequence number that it can receive without
Where,
Source port address: it is used to define the address of the application program in a
Sequence number: a stream of data is divided into two or more tcp segments. The
32-bit sequence number field represents the position of the data in an original data
stream.
data from other communicating devices. If ack field is set to 1, then it specifies the
Header length (hlen): it specifies the size of the tcp header in 32-bit words. The
minimum size of the header is 5 words, and the maximum size of the header is 15
words. Therefore, the maximum size of the tcp header is 60 bytes, and the minimum
Urg: the urg field indicates that the data in a segment is urgent.
Ack: when ack field is set, then it validates the acknowledgement number.
psh: the psh field is used to inform the sender that higher throughput is needed so
Rst: the reset bit is used to reset the TCP connection when there is any confusion
Syn: the syn field is used to synchronize the sequence numbers in three types of
segments: connection request, connection confirmation (with the ack bit set), and
confirmation acknowledgement.
Fin: the fin field is used to inform the receiving TCP module that the sender has
termination confirmation.
Window size: the window is a 16-bit field that defines the size of the window.
Urgent pointer: if urg flag is set to 1, then this 16-bit field is an offset from the
Options and padding: it defines the optional fields that convey the additional
The Network Layer is the OSI model’s third layer. It responds to service requests from
the transport layer and sends them to the data link layer. It decides the path from the
source to the destination and manages issues such as switching, routing, and data packet
congestion. The network layer’s primary function is to transport packets from the sending
The services which are offered by the network layer protocol are: Packetizing,
What is a packet?
communication with each other. In the case of communication, large number of data is
present on medium all the time. In order to transmit this data accurately and in a way
that medium do not get rash, it is divided into small packets (chunks of data). This process
is called Packetizing. Example of Packets: Suppose you are sending an image to another
computer/friend using internet. Your image will be divided in chunks of packets and will
Packetizing
Packetizing is a process of dividing long messages into smaller ones. The process of
encapsulating the data received from upper layers of the network (also called as payload) in
a network layer packet at the source and decapsulating the payload from the network layer
In a network, there are a number of routes available from the source to the destination. The
network layer specifies has some strategies which find out the best possible route. This
process is referred to as routing. Forwarding is simply defined as the action applied by each
router when a packet arrives at one of its interfaces. When a router receives a packet from
one of its attached networks, it needs to forward the packet to another attached network
Fragmentation:
Fragmentation occurs at the network layer (Layer 3) of the OSI model. It is the process of
breaking down large IP packets into smaller fragments to fit within the maximum
transmission unit (MTU) size of the network. The aim of fragmentation is that prevent
dropping of packets when travelling through networks that has different MTUs.
Fragmentation is necessary when a packet is too large to traverse a network without being
fragmented by intermediate devices, such as routers, that have smaller MTU sizes on their
packet and includes a fragment offset field to indicate its position within the original packet.
Network Addressing/ Logical Addressing:
A network address is any logical address that uniquely distinguishes a network node or
implemented by the data connection layer, while the logical addressing is implemented by
the network layer. Logical addressing is also utilized to distinguish between a system’s
source and destination. The network layer appends a header to the packet that contains the
that is assigned to any device that seeks access to or is part of a network. A router is different
from host in that it has two or more links that connect to it. The boundary between the router
and link is known as an interface, and the router can have multiple interfaces, one for each
of its links. Each interface is capable of sending and receiving the IP packets, so IP requires
IP Addressing
networks also use addresses. Addresses in computer networks are known as IP addresses.
An IP address consists of two components: the network address and the host address. The
network address is used to find the subnet in which the computer or the device is located.
The host address is used to find the computer or the device in the subnet. If a large
computer network is divided into smaller groups, each group is known as a subnet.
In the above figure, a router has three interfaces labeled as 1, 2 & 3 and each router
interface contains its own IP address. Each host contains its own interface and IP address.
All the interfaces attached to the LAN 1, LAN2, and LAN3 is having an IP address in the
two parts. The first part (first three bytes in IP address) specifies the network and second
part (last byte of an IP address) specifies the host in the network. IP addresses can be
are also written in dotted-decimal and hexadecimal notations. If IP addresses are written
1. IPv4
2. IPv6.
The length of IP addresses is different in both versions. Both versions also use different
An IPv4 address is 32 bits long. The IPv4 addresses are unique and universal.
address:
Binary Notation
In binary notation, the IPv4 address is displayed as 32 bits. Each octet is often
referred to as a byte.
Dotted-Decimal Notation
To make the IPv4 address more compact and easier to read, Internet addresses are
usually written in decimal form with a decimal point (dot) separating the bytes.
Find the error, if any, in the following IPv4 addresses:
a. [Link]
b. [Link].20
c. [Link]
d. 11100010.23.14.67
Solution
Change the following IPv4 addresses from binary notation to dotted-decimal notation.
Solution
notation. a. [Link]
b. [Link]
routing efficiency, enhances the security of the network and reduces the size of the
broadcast domain.
• There are two parts in an IP Address. One for them is Network part and the Host part.
With IP Subnetting, we are adding one more part. This is “Subnet Part”. From the
Host part, we borrow some bits and we will use this part for Subnet
Classful Addressing
Classless Addressing
Classful Addressing
Classful addressing is an IPv4 addressing architecture that divides addresses into five
groups.
classes: A, B, C, D, and E.
c. [Link]
d. [Link]
Solution
b. The first 2 bits are 1; the third bit is 0. This is a class C address.
d. The first byte is 252 (between 240 and 255); the class is E.
hostid. These parts are of varying lengths, depending on the class of the address.
In class A, 1byte defines the netid and 3 bytes define the hostid.
In class B, 2 bytes define the netid and 2 bytes define the hostid.
In class C, 3 bytes define the netid and 1 byte defines the hostid.
Class Binary Dotted decimal CIDR
Subnet Mask
A mask (also called the default mask) is a 32-bit number made of contiguous 1’s
The mask can help us to find the netid and the hostid.
The last column of table shows the mask in the form /n where n can be 8, 16, or 24 in
classful addressing.
The fast growth of the Internet led to the near running down of the available addresses
in classful addressing scheme. Yet the number of devices on the Internet is much less
than the 2 the power of 32 address space. We have run out of class A and B addresses,
and a class C block is too small for most midsize organizations. One solution that has
eased the problem is the idea of classless addressing. Classful addressing, which is
• The address and the /n notation completely define the whole block (the first address,
3. The first address must be evenly divisible by the number of addresses. Example
Figure shows a block of addresses, in both binary and dotted-decimal notation, granted
The number of addresses is a power of 2 (16 = 2 the power of 4 ), and the first address is
divisible by 16.
The first address, when converted to a decimal number, is 3,440,387,360, which when
First Address: The first address in the block can be found by setting the 32 - n
the addresses is [Link]/28. What is the first and last address in the block?
Solution
00100111
0010000 or [Link].
• The first address in a block is normally not assigned to any device. It is used as the
network address that represents the organization to the rest of the world.
A block in class A address is too large for almost any organization. This means most
A block in class B is also very large, probably too large for many of the organizations
Class D addresses were designed for multicasting. Each address in this class is used
to define one group of hosts on the Internet. The Internet authorities wrongly
predicted a need for 268,435,456 groups. This never happened and many addresses
And lastly, the class E addresses were reserved for future use; only a few were used,
Total number of usable ip address =2n-2 , where n is the number of host bit
Example
[Link] [Link]
[Link] [Link]
[Link] [Link]
[Link] [Link]
Example
[Link]
Example
How many hosts can be located on a network, where the IPv4 netmask is 27 bits?
Number of host=2n-2=32-2=30
Example
What are two ways to represent a network mask that would allow 14 hosts?
/28 or [Link]
Example
You have sub-netted your class C network [Link] with a subnet mask of
[Link]. Please list the following: number of networks, number of hosts per
network, the full range of the first three networks, and the usable address range from
Number of networks/subnet = 16
Number of hosts = 14
[Link]-[Link]
[Link]-[Link]
[Link]- [Link]
[Link]-[Link]
[Link]-[Link]
[Link]-[Link]
Example
You currently use the default mask for your IP network [Link]. You need to subnet
your network so that you have 30 additional networks, and 4 hosts per network. Is this
Example
You still are using the default mask for your IP network [Link]. You need to subnet
your network so that you have 5 additional networks, and 60 hosts per network. Is this
No, it is not possible. Because since the given ip address falls into class C , the default
subnet mask is /24 which means we have only 8 bits for the host and if we use 6 bits for
our host(26=64-2=62, we can create enough hosts but the rest 2 bits can only create 4
You have sub-netted your class C network [Link] with a subnet mask of
[Link]. Please list the following: number of networks, number of hosts per
network, the full range of the first three networks, and the usable address range from
those first three networks. Additionally, identify the broadcast addresses for each
network.
Number of networks = 64
Number of hosts = 2
[Link]-[Link]
[Link] -[Link]
[Link] - [Link]
[Link] - [Link]
[Link]-[Link]
[Link]
[Link]
[Link]
Example
Find the bits will be borrowed from the host to create 14 subnets and 14 hosts using the
ip address [Link].
Solution
From the given IP address we can understand that it belongs to class C address, this
implies that in class C address 24 bits are used for Network id and the rest 8 bits are used
In subnetting the concept is dividing the host bit into subnet bit and host bit. So, based on
the given information we are going to create 14 hosts. To create 14 hosts to the minimum
we need 4 bits.
these bits are used as a subnet bit and by using this bits we can create 16
NAT enables a user to have a large set of addresses internally and one address, or a
small set of addresses, externally. The traffic inside can use the large set; the traffic
outside, the small set. To separate the addresses used inside the home or business and
the ones used for the Internet, the Internet authorities have reserved 3 sets of
Everyone knows that these reserved addresses are for private networks.
They are unique inside the organization, but they are not unique globally.
No router will forward a packet that has one of these addresses as the destination
address.
The site must have only one single connection to the global Internet through a router
NAT implementation
Address Translation
All the outgoing packets go through the NAT router, which replaces the source
All incoming packets also pass through the NAT router, which replaces the
destination address in the packet (the NAT router global address) with the
network.
• PAT is informally called router; gateway is more appropriate.
• In PAT, Private IP addresses are translated into the public IP address via Port
address of the device and determining the physical address by knowing the logical
address of the device. Address mapping is required when a packet is routed from source
ICMP stands for Internet Control Message Protocol. It is a network layer protocol. It is
used for error handling in the network layer, and it is primarily used on network
devices such as routers. As different types of errors can exist in the network layer, so
ICMP can be used to report these errors and to debug those errors.
1. Error-reporting messages
The error-reporting message means that the router encounters a problem when it
2. Query messages
The query messages are those messages that help the host to get the specific
information of another host. For example, suppose there are a client and a server, and
the client wants to know whether the server is live or not, then it sends the ICMP
The message format has two things; one is a category that tells us which type of
message it is. If the message is of error type, the error message contains the type and
the code. The type defines the type of message while the code defines the subtype of
the message.
• Type: It is an 8-bit field. It defines the ICMP message type. The values range from 0 to
127 are defined for ICMPv6, and the values from 128 to 255 are the informational
messages.
• Code: It is an 8-bit field that defines the subtype of the ICMP message
• Checksum: It is a 16-bit field to detect whether the error exists in the message or not.
ICMPv6
• Another protocol that has been modified in version 6 of the TCPI/IP protocol suite is
ICMP (ICMPv6).
• This new version follows the same strategy and purposes of version 4. ICMPv4 has
• In addition, some protocols that were independent in version 4 are now part of
protocol is dropped from the suite because it was rarely used and BOOTP has the
same functionality.
configuration server.
• BOOTP is implemented using the User Datagram Protocol (UDP) for transport
protocol, port number 67 is used by the (DHCP) server for receiving client-requests
and port number 68 is used by the client for receiving (DHCP) server responses.
• Just as in ICMPv4, we divide the ICMP messages into two categories. However, each
IGMP
one-to-many communication.
• The IGMP protocol is used by the hosts and router to identify the hosts in a LAN that
IGMP message
IGMP is a part of the IP layer, and IGMP has a fixed-size message. The IGMP message is
• Type: It determines the type of IGMP message. There are three types of IGMP
• Maximum Response Time: This field is used only by the Membership Query message.
It determines the maximum time the host can send the Membership Report message
message is encapsulated.
Group Address: The behavior of this field depends on the type of the message sent.
• For Membership Query, the group address is set to zero for General Query and set to
group address.
This message is sent by a router to all hosts on a local area network to determine the set
of all the multicast groups that have been joined by the host.
The host responds to the membership query message with a membership report message.
The membership Query message sent by a router also includes a "Maximum Response
time”.
Leave Report: When the host does not send the "Membership Report message", it means
IGMP operates locally. A multicast router connected to a network has a list of multicast
addresses of the groups with at least one loyal member in that network,
A host or multicast router can have membership in a group. When a host has
membership, it means that one of its processes (an application program) receives
multicast packets from some group. When a router has membership, it means that a
network connection to one of its other interfaces receives these multicast packets. There
are two other multicast routers (R1 and R2) that, depending on the group list maintained
by router R, could be the recipients of router R in this network. Routers RI and R2 may
be distributors for some of these groups in other networks but not on this network.
Joining a Group
A host or a router can join a group. A host maintains a list of processes that have
membership in a group. When a process wants to join a new group, it sends its request
to the host
Leaving a Group
When a host sees that no process is interested in a specific group, it sends a leave report.
Similarly, when a router sees that none of the networks connected to its interfaces is
Encapsulation in networking is the process of adding headers and trailers around some
data. This is a fundamental concept used in the communication between different devices
over a network. During this process, each layer of the OSI (Open Systems
wraps the data with its own header and trailer to provide relevant information for that
encapsulated in a frame.
Netstat Utility
The netstat utility can be used to find the multicast addresses supported by an interface.
The netstat command generates displays that show network status and protocol statistics.
You can display the status of TCP and UDP endpoints in table format, routing table
information, and interface information. We use netstat with three options: -n, -r, and -a.
The -n option gives the numeric versions of IP addresses, the -r option gives the routing
table, and the -a option gives all addresses (unicast and multicast).
Routing algorithm
➢ In order to transfer the packets from source to the destination, the network layer must
determine the best route through which packets can be transmitted. The routing protocol
is a routing algorithm that provides the best path from the source to the destination. The
best path is the path that has the "least-cost path" from source to the destination. Routing
is the process of forwarding the packets from source to the destination but the best route
algorithm makes the routing decisions based on the topology and network traffic. The
main parameters related to this algorithm are hop count, distance and estimated transit
time.
least-cost path between source and destination by using complete and global knowledge
Isolation algorithm: It is an algorithm that obtains the routing information by using local
least-cost path between source and destination in an iterative and distributed manner.
transferring data packets from source to destination. They construct a static routing table
Flooding: In case of flooding, every incoming packet is sent to all the outgoing links
except the one from it has been reached. The disadvantage of flooding is that node may
Random walks: In case of random walks, a packet sent by the node to one of its neighbors
randomly. An advantage of using random walks is that it uses the alternative routes very
efficiently.
IPv6
What is IPv6?
• Internet Protocol Version 6 (IPv6) is the latest version of the Internet Protocol after
IPv4.
• Previous versions of IPv4 used a 32-bit addressing scheme to support 4.3 billion
devices.
• IPv6 uses 8 sets of four hexadecimal digits (separated by colons) instead of four sets