Professional Documents
Culture Documents
Aim
To acquaint students with the fundamentals of network layers that deliver packets
from a source to the destination across multiple networks.
Instructional Objectives
After completing this chapter, you should be able to:
Learning Outcomes
At the end of this chapter, you are expected to:
• Distinguish between datagrams and virtual circuits for routing the packets
amongst network nodes
• List the various services of IPV4 that are required to work with any TCP/IP-
based protocols
Introduction
The network layer is the third layer in the OSI model. It manages operations pertaining to
host and network addressing, sub-networks and internetworking. A network layer is
responsible for routing packets from the source to the destination within or outside a subnet.
Two different subnets can have different addressing schemes or non-compatible addressing
types. At some point of time you must have heard about threats that war sent over a public
electronic communication network. Generally, in such cases, it is difficult to trace the name of
that sender; but how will the administrator move forward? The first step is, to trace the
Internet protocol (IP) address of that device. The IP address is a unique address that identifies
each computer using an Internet protocol to communicate over a network. Any participating
network device including routers, computers, time-servers, printers, Internet fax machines
and some telephones can have their own unique address.
This chapter briefly covers the two major services of a network layer, difference between
a datagram and virtual circuits, Internet Protocol (IP) format and standards. You will also
learn about the reason behind the IPv4 address exhaustion and also learn how the IPv6
resolves this issue.
• The services provided by the network layer should be independent of the router
technology.
• The transport layer should be insulated from the topology of the routers.
• The network addresses used in the transport layer should be uniform across LANs
and WANs.
The main goal of the network layer is to connect end systems of different networks to
exchange data through intermediate systems called a router and the unit of data is called
packet.
• A connection-oriented service
Generally, the network layer provides two classes of services to users. Two different
organisations might be using different types of services offered by a network layer. If the
connectionless service is offered, then packets are injected into the subnet and routed
independently. No initial setup is required before routing the packets. Such packets are called
datagrams and the subnet is called a datagram subnet. On the other side, if the connection-
oriented service is offered, a path from the source router to the destination router must be
established before any packets are transmitted. This kind of setup is called as virtual circuit
(VC) and the subnet is called as virtual circuit subnet.
Figure 2.2.1 discusses how a datagram subnet works. The process p1 has a long message to
deliver to process p2. It hands over the message to the transport layer with an instruction
specifying to deliver it to process p2 on host H2. The transport layer program runs on the
host H1, where it prepends a header to the front of the message and hands it over to the
network layer. Let us assume that the message is 4 times longer than the packet size and thus
the network layer is supposed to break the long message into 4 packets, namely, 1, 2, 3 and 4
respectively and transmit each of them in turn to router A using point-to-point protocol.
Every router has an internal routing table indicating where to deliver packets for each
possible destination. The router table consists of a destination and a currently used
transmission line to use for that destination. Only directly connected lines need to be used.
Figure 2.2.1 shows that router A has only two outgoing connected lines to router B and C.
Hence, every incoming packet must be sent to any one of these routers. Router A’s routing
table is as shown in the figure under the label “initially”. When the packets 1, 2 and 3 arrive at
router A, it is stored and forwarded to C as per A’s table. Packet 1 is then forwarded to E and
later to F. When the packet 1 reaches to F, it is encapsulated in a data link layer frame and
sent to the host H2 over the LAN and packets 2 and 3 follows the same route. The algorithm
that manages the routing table is called routing algorithm. The different routing algorithms
will be discussed in the successive chapters.
In a connection-oriented service, a virtual circuit (VC) subnet must be used. The main
objective of a VC is to avoid having to choose a new route for every packet sent as shown in
figure 2.2.2. Instead of establishing a connection and routing from a source to the destination.
That particular route is used for all traffic flowing over a connection that is similar to a
telephone system. When the connection is released, the VC is also terminated. From the
above figure, the host H1 has established connection 1 with host H2. The first line of the
router A’s table depicts that if a packet bearing connection identifier 1 comes from H1, then it
must be sent to router C and given the connection identifier 1. Similarly, the entry in C routes
the packet to E, also with the connection identifier 1. Suppose H3 also wants to establish a
connection with H2 and then it chooses connection identifier 1 since it is initiating the
connection and it is the only connection and informs the subnet to establish a VC, which
leads to the second rows in the tables. An important thing to observe here is that there is a
conflict because although A can easily distinguish connection 1 packets from H1 from
connection 1 packets from H3, C cannot do this. To solve this conflict, A assigns a different
connection identifier to the outgoing traffic for the second connection.
Self-assessment Questions
1) Which layer facilitates the applications to exchange data efficiently and reliably?
a) Network layer b) Data-link layer
c) Transport layer d) Application layer
2) If a network layer offers a connectionless service, then the packets are injected into
the subnet and routed independently.
a) True b) False
When the end system sends a packet in a datagram network, it stamps the packet with the
address of the destination and then pops the packet into the network every time. Figure 2.2.3
shows the data transmission between sender and the receiver without any VC setup. In
datagram networks, routers do not maintain any state information of VC’s since it does not
use VC’s. When the packets is transmitted from source to destination, it passes through
various routers and these routers use the packets destination address to forward the packet.
Each router has a routing table that maps destination addresses to link interfaces. When the
packet arrives at the router, the router uses the packet’s destination address to find the
appropriate output link interface in the router table. The router then forwards the packet to
the output link interface.
1. A path, which is a series of links and routers between a source and a destination.
A packet which belongs to a virtual circuit carries a VC number and its header since a virtual
circuit may have a different VC number on each link.
• VC Setup: In the VC setup phase, the sender uses a transport layer to contact a network
layer and specifies the receiver’s address and waits for the network layer to setup the VC.
The network layer estimates the path between source and the destination which includes a
series of routers and links through which packets of the VC will travel. The VC also
estimates the VC number for each link along the path. Finally, the network layer includes
an entry in the routing table in each router along the path.
• Data Transfer: Once the VC is established, packets start to flow along the VC as shown in
figure 2.2.4.
• VC Teardown: The VC teardown is initiated when the sender or receiver informs the
network layer to terminate the VC. The network layer, then informs the sender or receiver
to terminate and update the routing table in each of the packet router tables to indicate
that the VC no longer exists.
Table 2.2.1 presents some of the differences between datagrams and virtual circuits:
Table 2.2.1: Difference between Datagram Networks and Virtual Circuit Networks
Self-assessment Questions
4) A circuit setup is required for datagram networks.
a) True b) False
5) The ________________ is initiated when the sender or receiver informs the network
layer to terminate VC.
a) VC setup b) Data transfer
c) VC teardown d) VC terminate
When we send or receive information through an e-mail or using a web page, the message
gets divided into little chunks, called packets. An IP specifies the format of these packets
called as datagrams. Each datagram contains the address information along with other
information that directs the packets over a network.
The IP does not provide any error-control and flow-control mechanism. It uses only an error
detection mechanism that helps to discard corrupted packets. An IP does its best to deliver
the packets to the intended recipient, but with no assurances. An IP must be combined with
Transport Control Protocol (TCP) at the transport layer to get better reliability.
An appropriate place to start our study of the network layer is with the different versions of
an IP. There are two versions of an IP, namely, Internet protocol version 4 (IPv4) and
Internet protocol version 6 (IPv6). The first version of the IP was defined in RFC 791 and it is
named as IP version 4 (IPv4). The IP specifies the fields of datagram that consists of a header
part and a body or payload part. Later, with additions and changes with respect to addresses,
a new version of the IP was introduced and termed as Internet protocol version 6 (IPv6). IPv6
is the most recent version of the Internet protocol. It is also sometimes referred to as IP next
generation or IPng. Each version defines an IP address differently.
• IPV4 Addressing
As we know, at the LAN level, all the communicating computers use Ethernet and this
creates a hurdle for WAN-wide communication. To send a frame from one computer to
another, the sending computer must know the Medium Access Control (MAC) address of the
destination computer. The MAC is the physical address and hardware address of a computer,
which is uniquely formatted in a hexadecimal format. The sending computer simply
broadcasts a frame with the MAC address. Here, the IP address comes into the picture. The
Internet protocol address is a network layer address and has no dependencies on the data link
layer. A unique IP address is required for each host and network component that is involved
in communication using TCP/IP.
Like a street address identifies a home in a city, an IP address uniquely identifies a device’s
location on the network. This IP address must be globally unique to the Internetwork and
must have a uniform format.
An IP address consists of two components: A network ID and a host ID. A network ID is also
termed as a network address. This address is used to recognise the device positioned on the
same physical network, which is bound to the IP router. Devices located on the same physical
network must have the same network address and it must be unique to the Internetwork.
A host ID is also termed as a host address, which must be unique to the network address. A
host address recognises a router, workstation or other TCP/IP host located on a network. The
figure below shows the IPv4 address structure.
IPv4 addresses are 32 bits in length as shown in figure 2.2.5. This address is divided into four
8-bit octets. Each octet has a binary value from 00000000 to 11111111 or a decimal value from
0 to 255. The IPv4 address is generally represented in dotted decimal notation. An IP address
becomes more readable when it is converted from binary notation to dotted notation.
In the network layer, packets are called datagrams. A datagram includes two parts: Header
and data. The header is 20 to 60 bytes in length. It contains the information that is essential to
route packets. Figure 2.2.6 shows the structure of an IP datagram.
Figure 2.2.6: IP Packet Format or Internet Protocol Version 4 (IPv4) Datagram Format
• Version: This field defines the version of IP currently being used. The IPv4 (version
4) is the first major version of Internet protocol. Its successor is the IPv6.
• IP Header Length (IHL): This field specifies the length of the header in 32-bit word.
• Type-of-service: This field specifies the class of datagrams that provide the quality of
service features.
• Total Length: This field specifies the total length (header and data) of the IP datagram
in bytes. That is, total length = header length + length of data.
• Identification: This field consists of an integer that identifies the current datagram.
This field combines various datagram fragments together.
• Flags: This field consists of 3 bits. The first bit is reserved. The second bit is termed as
a “do not fragment” bit. If its value is 1, the device cannot fragment the datagram, if it
is 0 then the datagram can be fragmented, if necessary. The third bit is termed as a
“more” fragment bit. If its value is 1, datagram is not the last fragment. If its value is 0,
this is the last and only fragment.
• Fragment Offset: This is a 13-bit field. This field specifies the relative position of the
datagram with respect to the whole datagram (original datagram).
• Time-to-live: This field is used as a counter that controls the maximum number of
routers visited by the datagram. Alternatively, it maintains a counter that gradually
decreases to zero, at which point the datagram is discarded.
• Protocol: This field specifies the higher-layer protocol that uses the service of IP layer
or receives the incoming packets as soon as the IP processing is completed.
• Options: This field is not required for every datagram. This field is used for network
testing and debugging.
• Padding: If one or more options are included and the number of bits used for them is
not a multiple of 32, enough zero bits are added to “pad out” the header.
• Data: This field includes the data to be transmitted in the datagram. The data can
either be fragmented or be an entire higher-layer message.
• IPV6 Addressing
IPv4 is the protocol that is currently used in a network layer. IPv4 used to have a host-to-host
communication between systems in the Internet. Even though the IPv4 is well designed, data
communication has evolved since the inception of the IPv4 in the 1970s. IPv4 has some of the
following deficiencies that make it unsuitable for the Internet that keeps changing at such a
rapid pace:
• The major problem of IPv4 is address depletion on the Internet though solutions such
as sub netting and classless addressing which are available to overcome the address
deficiency of IPv4.
• IPv4 fails to provide a smooth flow of real-time audio and video transmission in the
Internet with minimum delay strategies.
The Internet protocol version 6 was proposed to overcome these drawbacks of IPv4. The data
length of IPv4 and IPv6 are changed along with their packet format.
32-bits
• Version: This field size is 4 bits. It is used to specify the IP version and is set to 6.
• Priority: This field specifies the priority of the packet with respect to its traffic
congestion. Its size is 4-bit.
• Flow Label: It is used to handle the flow of data. Its size is 3 bytes.
• Payload Length: This field specifies the length of the IPv6 payload (IPv6 datagram)
excluding the base header. Its size is 2 bytes.
• Next Header: This defines the header that follows the base header in the datagram or
protocol in the higher layer (TCP, UDP and ICMP). Its size is 1 byte.
• Hop Limit: It serves the same purpose as the TTL (Time to Live) field in IPv4. Its size
is 1 byte.
• This field is typically used by distance vector routing protocols, like routing
information protocol (RIP) to prevent layer 3 loops (routing loops).
• Source Address: It defines the source IP address of the packet. Its size is 16 bytes.
• Destination Address: It defines the destination IP address of the packet. Its size is 16
bytes.
Types of Services
IP Datagram Encapsulation
The protocols at various layers in a protocol stack interact with each other; important
concepts in an inter protocol operation is called encapsulation. Most datagrams originate
within the higher layers of the ISO/OSI model. A good analogy for encapsulation is how a
letter is enclosed in an envelope before mailing. Due to the prominence of TCP/IP, the IP is
one of the important places where data encapsulation takes place. Data is passed to an IP
from one of the transport layer protocols, that is, TCP or UDP. When the data is already in
the form of a TCP or UDP with TCP or UDP headers, then this is encapsulated into the body
of an IP message. Encapsulation and formatting an IP datagram is also called packaging.
Figure 2.2.8 depicts the IP datagram encapsulation with the use of a frame header and frame
data. If the message to be transmitted is very large, then it must be first fragmented and this
concept is analogous to splitting up a very large delivery into multiples of smaller envelopes.
In such a situation, each IP datagram carries only a part of the higher layer message and the
receiving device needs to reassemble the message later. Once the data is encapsulated into an
IP datagram, then it must be passed to the data link layer for transmission. The IP datagram
will not change until it reaches the destination.
The data forwarding in a network layer uses a router that interconnects several links and each
link runs a different link layer protocols with different MTUs. When an IP datagram is
received from one link, it checks the forwarding table to determine the next outgoing link and
this outgoing link has an MTU which is smaller than the length of an IP datagram. It becomes
difficult to squeeze the oversized IP datagram into the payload field of the link layer frame.
The only solution is to fragment these IP datagrams into smaller IP datagrams and
encapsulate each of them in a separate link layer frame and later send these frames over an
outgoing link. Each smaller datagram is called a fragment.
Fragments need to be reassembled before they reach the transport layer at the destination.
Moreover, either TCP or UDP expect to receive the complete, un-fragmented segments from
the network layer. The developers of IPv4 felt that reassembling datagram in the routers
would introduce complications into the protocol and obstruct the router’s performance. The
developers later decided to put the job of datagram reassembly in the end system, rather than
in network routers.
When a destination host receives a series of datagrams from the same source, it needs to
determine whether any of these datagrams are fragments of an original larger datagram.
If some datagrams are fragments, it must be determined as to when the last fragment was
received and how the fragments that were already received should be pieced back together to
form the original datagram. To allow the destination host to perform these reassembly tasks,
the developers of the IPv4 put in an identification flag and fragmentation offset fields in the IP
datagram header. When a datagram is created, the sending host stamps the datagram with an
identification number as well as a source and destination address. Typically, the sending host
increments the identification number for each datagram it sends. When a router needs to
fragment a datagram, each resulting datagram is stamped with the source address, destination
address and identification number of the original datagram. When the destination receives a
series of datagrams from the same sending host, it can examine the identification numbers of
the datagrams to determine which of the datagrams actually fragments of the same larger
datagram are.
Self-assessment Questions
6) Which of the following statements is incorrect with respect to IP?
a) IP is popular for best-effort delivery service
b) IP provides the division and reassembly of datagrams
c) IP provides error control and flow control mechanisms
d) IP is a connectionless-oriented datagram protocol
7) What is the name of the first version of the IP that was defined in RFC 791?
a) IPv1 b) IPv2
c) IPv4 d) IPv6
Summary
o The transport layer send segments to any destination without knowing the
underlying sub-network technologies
o The main goal of the network layer is to connect end systems of different
networks to exchange data through intermediate systems called a router; the unit
of data is called a packet.
o The Internet protocol (IP) is a network-layer protocol, which acts as a glue to hold
the Internet together.
o When we send or receive information through an e-mail or using a web page the
message gets divided into little chunks, called packets.
o The protocols at various layers in a protocol stack interact with each other;
important concepts in an inter protocol operation is called encapsulation.
Terminal Questions
1. Describe the two services offered by the network layer of an OSI model.
2. Compare datagrams and virtual circuit networks to justify which network is better
suited to route packets from a source to the destination.
Answer Keys
Self-assessment Questions
Question No. Answer
1 c
2 a
3 a
4 b
5 c
6 c
7 c
8 b
Activity
Description:
1. Divide the class into two groups and discuss about datagrams and virtual circuits in
networking.
Bibliography
e-References
External Resources
• CCNA Cisco Certified Network Associate: Study Guide. (2011). India: Wiley
publishing.
Video Links
Topic Link
Datagram and Virtual Circuit
https://www.youtube.com/watch?v=CoNUi80GVyk
Difference
IP Datagram Format https://www.youtube.com/watch?v=h_Bb5v-Hlbo
Notes: