Module 3
Network Layer
Chapter 18 & 20
18.1 NETWORK-LAYER SERVICES
• We discuss network layer services expected from a network layer protocol.
• Figure 18.1 shows the communication between Alice and Bob at the network
layer.
• Internet is an internetwork, a combination of LANs and WANs.
• The network layer is involved at the source host, destination host, and all routers
in the path (R2, R4, R5, and R7) as shown in figure.
• At the source host (Alice), the network layer accepts a packet from a transport
layer, encapsulates the packet in a datagram, and delivers the packet to the data-
link layer.
• At the destination host (Bob), the datagram is decapsulated, and the packet is
extracted and delivered to the corresponding transport layer.
• Although the source and destination
hosts are involved in all five layers of
the TCP/IP suite, the routers use
three layers if they are routing
packets only.
• A router in the path is normally
shown with two data-link layers and
two physical layers, because it
receives a packet from one network
and delivers it to another network.
1. Packetizing
• Packetizing mean encapsulating the payload (data received from
upper layer) in a network-layer packet at the source and
decapsulating the payload from the network-layer packet at the
destination.
• The source host receives the payload from an upper-layer protocol,
adds a header that contains the source and destination addresses and
some other information that is required by the network-layer
protocol and delivers the packet to the data-link layer.
• The source is not allowed to change the content of the payload unless
it is too large for delivery and needs to be fragmented.
1. Packetizing
• The destination host receives the network-layer packet from its data-
link layer, decapsulates the packet, and delivers the payload to the
corresponding upper-layer protocol.
• If the packet is fragmented at the source or at routers along the path,
the network layer is responsible for waiting until all fragments arrive,
reassembling them, and delivering them to the upper-layer protocol.
• The routers in the path are not allowed to decapsulate the packets
they received unless the packets need to be fragmented.
1. Packetizing
• The routers are not allowed to change source and destination
addresses either. They just inspect the addresses for the purpose of
forwarding the packet to the next network on the path.
• However, if a packet is fragmented, the header needs to be copied to
all fragments and some changes are needed.
2.1 Routing
• The network layer is responsible for routing the packet from its
source to the destination.
• A physical network is a combination of networks (LANs and WANs)
and routers that connect them. This means that there is more than
one route from the source to the destination.
• The network layer is responsible for finding the best one among
these possible routes. The network layer needs to have some specific
strategies for defining the best route.
• This is done by running some routing protocols to help the routers
coordinate their knowledge about the neighborhood and to come up
with consistent tables to be used when a packet arrives.
2.2 Forwarding
• forwarding can be defined as the action applied by each router when
a packet arrives at one of its interfaces.
• The decision-making table a router normally uses for applying this
action is sometimes called the forwarding table and sometimes the
routing table.
• When a router receives a packet from one of its attached networks, it
needs to forward the packet to another attached network (in unicast
routing) or to some attached networks (in multicast routing).
• To make this decision, the router uses a piece of information in the
packet header, which can be the destination address or a label, to
find the corresponding output interface number in the forwarding
table.
Other Services – 1. ERROR CONTROL
• The designers of the network layer have added a checksum field to
the datagram to control any corruption in the header, but not in the
whole datagram. This checksum may prevent any changes or
corruptions in the header of the datagram.
• Internet uses an auxiliary protocol, ICMP, that provides some kind of
error control if the datagram is discarded or has some unknown
information in the header.
Other Services – 2. FLOW CONTROL
The network layer in the Internet does not directly provide any flow
control. The datagrams are sent by the sender when they are ready,
without any attention to the readiness of the receiver.
Other Services – 3. CONGESTION CONTROL
• Congestion may occur if the number of datagrams sent by source
computers is beyond the capacity of the network or routers. In this
situation, some routers may drop some of the datagrams.
Other Services – 4. Quality of Service
• As the Internet has allowed new applications such as multimedia
communication (in particular real-time communication of audio and
video), the quality of service (QoS) of the communication has become
more and more important.
• However, to keep the network layer untouched, these provisions are
mostly implemented in the upper layer.
Other Services – 5. SECURITY
• To provide security for a connectionless network layer, we need to
have another virtual level that changes the connectionless service to
a connection-oriented service.
• This virtual layer is called IPSec.
PACKET SWITCHING
• Packet switching is used at the network layer because the unit of data
at this layer is a packet. Circuit switching is mostly used at the
physical layer.
• At the network layer, a message from the upper layer is divided into
manageable packets and each packet is sent through the network.
• The source of the message sends the packets one by one;
the destination of the message receives the packets one by one.
• The destination waits for all packets belonging to the same message
to arrive before delivering the message to the upper layer.
• A packet-switched network can use two different approaches to route
the packets: the datagram approach and the virtual circuit approach.
Datagram Approach: Connectionless Service
• In this approach, the packets in a message may or may not travel the
same path to their destination. Figure 18.3 shows the idea.
Datagram Approach: Connectionless Service
• When the network layer provides a connectionless service, each
packet traveling in the Internet is an independent entity; there is no
relationship between packets belonging to the same message.
• The switches in this type of network are called routers.
• A packet belonging to a message may be followed by a packet
belonging to the same message or to a different message.
• A packet may be followed by a packet coming from the same or from
a different source.
Datagram Approach: Connectionless Service
• Each packet is routed based on the information contained in its
header: source and destination addresses. The destination address
defines where it should go; the source address defines where it
comes from.
• The source address may be used to send an error message to the
source if the packet is discarded.
• Figure 18.4 shows the forwarding process in a router. We have used
symbolic addresses such as A and B.
Datagram Approach: Connectionless Service
In the datagram approach, the forwarding decision is based
on the destination address of the packet.
Virtual-Circuit Approach: Connection-Oriented Service
• In a connection-oriented service (also called virtual-circuit approach),
there is a relationship between all packets belonging to a message.
• A virtual connection should be set up to define the path for the
datagrams. After connection setup, the datagrams can all follow the
same path.
• A virtual circuit identifier (a flow label) that defines the virtual path
the packet should follow.
• A part of the packet path may still be using the connectionless
service, hence source and destination addresses are needed during
the data transfer phase.
Virtual-Circuit Approach: Connection-Oriented Service
• Figure 18.5 shows the concept of connection-oriented service.
Virtual-Circuit Approach: Connection-Oriented Service
In the virtual-circuit approach, the forwarding decision is based on
the label of the packet.
Virtual-Circuit Approach: Connection-Oriented Service
• To create a connection-oriented service, a three-phase process is
used: setup, data transfer, and teardown.
• In the setup phase, the source and destination addresses of the
sender and receiver are used to make table entries for the
connection-oriented service.
• In the teardown phase, the source and destination inform the router
to delete the corresponding entries.
• Data transfer occurs between these two phases.
Virtual-Circuit Approach: Connection-Oriented Service
I. Setup Phase
• In the setup phase, a router creates an entry for a virtual circuit.
• Suppose source A needs to create a virtual circuit to destination B.
Two auxiliary packets need to be exchanged between the sender and
the receiver: the request packet and the acknowledgment packet.
Request packet
• A request packet is sent from the source to the destination.
• This auxiliary packet carries the source and destination addresses.
• Figure 18.7 shows the process.
Virtual-Circuit Approach: Connection-Oriented Service
Virtual-Circuit Approach: Connection-Oriented Service
Acknowledgment Packet
• A special packet, called the acknowledgment packet, completes the
entries in the switching tables. Figure 18.8 shows the process.
II. Data-Transfer Phase
• The second phase is called the data-transfer phase. After all routers
have created their forwarding table for a specific virtual circuit, then
the network-layer packets belonging to one message can be sent
one after another.
• Figure 18.9 shows the flow of a single packet, but the process is the
same for 1, 2, or 100 packets.
Virtual-Circuit Approach: Connection-Oriented Service
Virtual-Circuit Approach: Connection-Oriented Service
Virtual-Circuit Approach: Connection-Oriented Service
III. Teardown Phase
• In the teardown phase, source A, after sending all packets to B,
sends a special packet called a teardown packet.
• Destination B responds with a confirmation packet.
• All routers delete the corresponding entries from their tables.