module 3
module 3
NETWORK-LAYER SERVICES
Figure 18.1 shows the communication between Alice and Bob at the network layer.
The figure shows that the Internet is made of many networks (or links) connected through the
connecting devices. In other words, the Internet is an internetwork, a combination of LANs and
WANs. To better understand the role of the network layer (or the internetwork layer), we need
to think about the connecting devices (routers or switches) that connect the LANs and WANs.
As the figure shows, the network layer is involved at the source host, destination host, and all
routers in the path (R2, R4, R5, and R7). At the source host (Alice), the network layer accepts
a packet from a transport layer, encapsulates the packet in a data- gram, 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 correspond- ing 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; however, they may need the transport and application
layers for control purposes. 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.
Packetizing
The **network layer** has the primary responsibility of **packetizing**:
- At the **source**: Encapsulates data from the upper layer into a network-layer packet. It
adds a header with source/destination addresses and other necessary info, then passes the
packet to the data-link layer. If the payload is too large, it may need to be **fragmented**.-
At the **destination**: Decapsulates the packet, reassembles any fragments, and delivers the
payload to the appropriate upper-layer protocol.The network layer acts like a postal service,
delivering data without altering its content.
Routing and Forwarding
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.
Forwarding
If routing is applying strategies and running some routing protocols to create the decision-
making tables for each router, 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.
Other Services
Error Control
The designers of the network layer, however, 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.
Flow Control
Flow control regulates the amount of data a source can send without overwhelming the
receiver. If the upper layer at the source computer produces data faster than the upper layer
at the destination computer can consume it, the receiver will be overwhelmed with data. To
control the flow of data, the receiver needs to send some feedback to the sender to inform
the latter that it is overwhelmed with data.
Congestion Control
Another issue in a network-layer protocol is congestion control. Congestion in the network
layer is a situation in which too many datagrams are present in an area of the Internet.
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. However, as more datagrams are dropped, the situation may become worse
because, due to the error control mechanism at the upper layers, the sender may send
duplicates of the lost packets. If the congestion continues, sometimes a situation may reach
a point where the system collapses and no datagrams are delivered
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. The Internet has thrived by providing
better quality of service to support these applications. However, to keep the network layer
untouched, these provisions are mostly implemented in the upper layer.We discuss this issue
in Chapter 30 after we have discussed multimedia.
Security
Another issue related to communication at the network layer is security. Security was not a
concern when the Internet was originally designed because it was used by a small number
of users at universities for research activities; other people had no access to the Internet.
The network layer was designed with no security provision. Today, however, security is a
big concern. 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.
PACKET SWITCHING
Although in data communication switching techniques are divided into two broad
categories, circuit switching and packet switching, only 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; the electrical switch mentioned earlier is a kind of circuit switch.
We discussed circuit switching in Chapter 8; we discuss packet switching in this chapter.
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. The connecting devices in a packet-switched network still need to decide
how to route the packets to the final destination. Today, a packet-switched network can use
two different approaches to route the packets: the datagram approach and the virtual circuit
approach. We discuss both approaches in the next section.
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.
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 router in this case routes the packet based only on the destination
address. 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 in this case. We have used
symbolic addresses such as A and B.
setup, the datagrams can all follow the same path. In this type of service, not only must the
packet contain the source and destination addresses, it must also contain a flow label, a virtual
circuit identifier that defines the virtual path the packet should follow.
Each packet is forwarded based on the label in the packet. To follow the idea of connection-
oriented design to be used in the Internet, we assume that the packet has a label when it reaches
the router. Figure 18.6 shows the idea. In this case, the forwarding decision is based on the
value of the label, or virtual circuit identifier, as it is sometimes called. 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 address 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.
Setup Phase
In the setup phase, a router creates an entry for a virtual circuit. For example, 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.
4. Router R3 receives the setup request packet. The same events happen here as at router
R1; three columns of the table are completed: in this case, incoming port (1), incoming
label (66), and outgoing port (3).
5. Router R4 receives the setup request packet. Again, three columns are completed:
incoming port (1), incoming label (22), and outgoing port (4).
6. Destination B receives the setup packet, and if it is ready to receive packets from A, it
assigns a label to the incoming packets that come from A, in this case 77, as shown in
Figure 18.8. This label lets the destination know that the packets come from A, and not
from other sources.
Acknowledgment Packet
A special packet, called the acknowledgment packet, completes the entries in the
switching tables. Figure 18.8 shows the process.
7. The acknowledgment carries the global source and destination addresses so the router
knows which entry in the table is to be completed. The packet also carries label 77, chosen
by the destination as the incoming label for packets from A. Router R4 uses this label to
complete the outgoing label column for this entry. Note that 77 is the incoming label for
destination B, but the outgoing label for router R4.
8. Router R4 sends an acknowledgment to router R3 that contains its incoming label in the
table, chosen in the setup phase. Router R3 uses this as the outgoing label in the table.
9. Router R3 sends an acknowledgment to router R1 that contains its incoming label in the
table, chosen in the setup phase. Router R1 uses this as the outgoing label in the table.
Finally, router R1 sends an acknowledgment to source A that contains its incoming label in
the table, chosen in the setup phase. The source uses this as the outgoing label for the
Department of ISE, CEC, Sudheendra Nagar Benjanapadavu, Mangalore 7
BCS502 MODULE 3 NETWORK LAYER
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. In Figure 18.9, we show the flow of a single
packet, but the process is the same for 1, 2, or 100 packets. The source computer uses the
label 14, which it has received from router R1 in the setup. Router R1 forwards the packet
to router R3, but changes the label to 66. Router R3 forwards the packet to router R4, but
changes the label to 22. Finally, router R4 delivers the packet to its final destination with the
label 77. All the packets in the message follow the same sequence of labels, and the packets
arrive in order at the destination.
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.
IPV4 ADDRESSES
The identifier used in the IP layer of the TCP/IP protocol suite to identify the connection of
each device to the Internet is called the Internet address or IP address. An IPv4 address is a 32-
bit address that uniquely and universally defines the connection of a host or a router to the
Internet
A protocol like IPv4 that defines addresses has an address space. An address space is the total
number of addresses used by the protocol. If a protocol uses b bits to define an address, the
address space is 2b because each bit can have two different values (0 or 1). IPv4 uses 32-bit
addresses, which means that the address space is 232 or 4,294,967,296 (more than four billion).
If there were no restrictions, more than 4 billion devices could be connected to the Internet
Notation
There are three common notations to show an IPv4 address: binary notation (base 2),dotted-
decimal notation (base 256), and hexadecimal notation (base 16). In binary notation, an IPv4
address is displayed as 32 bits. To make the address more readable, one or more spaces are
usually inserted between each octet (8 bits). Each octet is often referred to as a byte. To make
the IPv4 address more compact and easier to read, it is usually written in decimal form with a
decimal point (dot) separating the bytes. This format is referred to as dotted-decimal notation.
A 32-bit IPv4 address is also hierarchical, but divided only into two parts. The first part of the
address, called the prefix, defines the network; the second part of the address, called the suffix,
defines the node (connection of a device to the Internet). Figure 18.17 shows the prefix and
suffix of a 32-bit IPv4 address. The prefix length is
n bits and the suffix length is (32 − n) bits.
Classful Addressing
When the Internet started, an IPv4 address was designed with a fixed-length prefix, but to
accommodate both small and large networks, three fixed-length prefixes were designed instead
of one (n = 8, n = 16, and n = 24). The whole address space was divided into five classes (class
A, B, C, D, and E), as shown in Figure 18.18. This scheme is referred to as classful addressing.
The information you've provided about IPv4 address classes is accurate. Here's a summary of
the key points:
Class A:
• Network length: 8 bits
• Network identifier: 7 bits
• Total networks: 2^7 = 128
Class B:
• Network length: 16 bits
• Network identifier: 14 bits
• Total networks: 2^14 = 16,384
Class C:
• Network length: 24 bits
• Network identifier: 21 bits
• Total networks: 2^21 = 2,097,152
These address classes were originally designed to allocate IP addresses based on the expected
size of networks. Class A was intended for large networks, Class B for medium-sized networks,
Department of ISE, CEC, Sudheendra Nagar Benjanapadavu, Mangalore 11
BCS502 MODULE 3 NETWORK LAYER
and Class C for small networks. However, as the internet grew and the demand for IP addresses
increased, this hierarchical structure became inefficient and was eventually replaced by the
Classless Inter-Domain Routing (CIDR) system.
Classless Addressing
Subnetting and supernetting in classful addressing did not really solve the address depletion
problem. With the growth of the Internet, it was clear that a larger address space was needed
as a long-term solution. The larger address space, however, requires that the length of IP
addresses also be increased, which means the format of the IP packets needs to be changed.
Although the long-range solution has already been devised and is called IPv6 (discussed later),
a short-term solution was also devised to use the same address space but to change the
distribution of addresses to provide a fair share to each organization. The short-term solution
still uses IPv4 addresses, but it is called classless addressing. In other words, the class privilege
was removed from the distribution to compensate for the address depletion.
In classless addressing, the whole address space is divided into variable length blocks. The
prefix in an address defines the block (network); the suffix defines the node (device).
Theoretically, we can have a block of 20, 21, 22, . . . , 232 addresses. One of the restrictions,
Unlike classful addressing, the prefix length in classless addressing is variable. We can have a
prefix length that ranges from 0 to 32. The size of the network is inversely proportional to the
length of the prefix. A small prefix means a larger network; a large prefix means a smaller
network.
Example 18.1
A classless address is given as 167.199.170.82/27. We can find the above three
pieces of information as follows. The number of addresses in the network is 232
− n = 25 = 32 addresses.
Example 18.4
An ISP has requested a block of 1000 addresses. Since 1000 is not a power of 2, 1024 addresses
are granted. The prefix length is calculated as n = 32 − log21024 = 22. An available block,
18.14.12.0/22, is granted to the ISP. It can be seen that the first address in decimal is
302,910,464, which is divisible by 1024.
Address Aggregation
One of the advantages of the CIDR strategy is address aggregation (sometimes called address
summarization or route summarization). When blocks of addresses are combined to create a
larger block, routing can be done based on the prefix of the larger block. ICANN assigns a
large block of addresses to an ISP. Each ISP in turn divides its assigned block into smaller
subblocks and grants the subblocks to its customers.
Example 18.6
Figure 18.24 shows how four small blocks of addresses are assigned to four organizations by
an ISP. The ISP combines these four blocks into one single block and advertises the larger
block to the rest of the world. Any packet destined for this larger block should be sent to this
ISP. It is the responsibility of the ISP to forward the packet to the appropriate organization
Special Addresses
- **This-host Address (0.0.0.0/32)**: Used when a host doesn't know its own IP address and
needs to send a datagram.
- **Limited-broadcast Address (255.255.255.255/32)**: Used to send a datagram to all devices
in a network. Routers block these packets from leaving the network.
- **Loopback Address (127.0.0.0/8)**: Used for testing on the host itself. Packets with this
address never leave the host, allowing local software testing.
- **Private Addresses**: Reserved for internal use in private networks:
- **10.0.0.0/8**
- **172.16.0.0/12**
- **192.168.0.0/16**
- **169.254.0.0/16**
These addresses are for specific purposes within networks.
3. **DHCPREQUEST**: The host picks the best offer and replies with a
**DHCPREQUEST** message to that server, setting known fields. This message is sent using
the host’s new IP but still broadcast to notify other servers that their offers were not chosen.
Address Translation
**Address Translation**: Outgoing packets pass through the **NAT router**, which replaces
the private source address with the global NAT address. For incoming packets, the NAT router
replaces the global destination address with the appropriate private address.
**Translation Table**: The NAT router uses a **translation table** to map global addresses
to private ones, allowing it to determine which private IP corresponds to the destination address
for incoming packets. This solves the challenge of managing multiple private IPs behind a
single global IP.
In **IPv4**, the **network layer** consists of one main protocol and three auxiliary ones:
1. **IPv4**: The main protocol responsible for packetizing, forwarding, and delivering
packets.
2. **ICMPv4**: Assists IPv4 by handling network-layer error messages.
3. **IGMP**: Helps with multicasting in IPv4.
4. **ARP**: Maps network-layer addresses (IP) to link-layer addresses (MAC), connecting
the network and data-link layers.
**Figure 19.1** shows how these protocols fit within the **TCP/IP protocol suite**.
Datagram Format
IPv4 provides the service of **packetizing**, defining the format for encapsulating data from
upper layers into **datagrams**. A datagram is a variable-length packet with two parts:
1. **Header**: 20 to 60 bytes, containing key routing and delivery information.
2. **Payload (data)**: The actual data being transmitted.
In TCP/IP, the header is typically shown in 4-byte sections. **Figure 19.2** illustrates the IPv4 datagram
format.
- **Version Number (VER)**: 4 bits, identifies the IPv4 protocol (value is 4).
- **Header Length (HLEN)**: 4 bits, defines the total header length in 4-byte words. Multiply
the value by 4 to get the total header length.
- **Service Type**: Originally called Type of Service (TOS), now used for **Differentiated
Services (DiffServ)**.
- **Total Length**: 16 bits, gives the total datagram length (header + data) in bytes. To find
the data length, subtract the header length from the total length.
- **Identification, Flags, Fragmentation Offset**: Used for fragmenting large datagrams.
Discussed in more detail during fragmentation.
- **Time-to-Live (TTL)**: Controls how long a datagram can circulate. Routers decrement
this value at each hop, and if it reaches zero, the packet is discarded.
- **Protocol**: Identifies the protocol carried in the payload (e.g., TCP, UDP, or other
protocols).
IPv6 ADDRESSING
An IPv6 address is 128 bits or 16 bytes (octets) long, four times the address length in IPv4.
Representation
Abbreviation
Although an IPv6 address, even in hexadecimal format, is very long, many of the digits are
zeros. In this case, we can abbreviate the address. The leading zeros of a section can be
omitted. Using this form of abbreviation, 0074 can be written as 74, 000F as F, and 0000 as
0. Note that 3210 cannot be abbreviated. Further abbreviation, often called zero compression,
IPv6 offers a significantly larger address space than IPv4, effectively eliminating the risk of
address depletion. This vast space allows for the assignment of numerous addresses to each
person on Earth, even with a rapidly growing population.
Address Space and Allocation
• Address Space: IPv6 has 2^128 addresses, which is 296 times larger than IPv4.
• Allocation: Assuming only 1/64 of the addresses are assigned to individuals, each
person could have 2^88 addresses.
• Depletion: With this allocation, address depletion is virtually impossible.
Address Types
• Simplified Header: Options are separated from the base header, streamlining routing
and reducing processing time.
• New Options: Expanded functionality with additional options.
• Extensibility: Designed for future growth and adaptation to new technologies.
• Traffic Prioritization: Traffic class and flow label fields allow for differentiated
treatment of packets, supporting real-time applications.
• Enhanced Security: Encryption and authentication options provide confidentiality
and integrity.
These changes make IPv6 more efficient, flexible, and secure than its predecessor.
Packet Format
The IPv6 packet is shown in Figure 22.6. Each packet is composed of a base header fol- lowed
by the payload. The base header occupies 40 bytes, whereas payload can be up to 65,535
bytes of information. The description of fields follows.
IPv6 has a simplified header structure compared to IPv4, with several key fields:
• Version: Indicates the IP version (6 for IPv6).
• Traffic Class: Differentiates payloads based on delivery requirements.
These fields enable IPv6 to efficiently route and deliver packets while offering enhanced
features and flexibility.
IPv6 introduced the flow label field to support connection-oriented services and improve
packet handling. A flow label identifies a sequence of packets with similar characteristics, such
as the same path, resources, security requirements, and so on.
Benefits of Flow Labels:
• Faster Routing: Routers can use flow label tables to quickly determine the next hop
for packets, reducing processing time.
• Real-time Support: Flow labels can be used to prioritize real-time audio and video
traffic, ensuring timely delivery.
• Resource Reservation: Protocols like RTP and RSVP can be used in conjunction
with flow labels to reserve resources for specific flows, guaranteeing quality of service.
In essence, flow labels provide a mechanism for managing and prioritizing network
traffic, making IPv6 more suitable for various applications, including real-time
communications.
IPv6 Extension Headers
IPv6 allows for the addition of extension headers to the base header, providing more
functionality and flexibility. These headers are optional and can be used to implement various
features.
Types of Extension Headers:
• Hop-by-Hop Option: Provides options that are processed by each router along the
path.
• Source Routing: Specifies the route a packet should take.
• Fragmentation: Handles fragmentation of packets that are too large for the
underlying network.
• Authentication: Verifies the authenticity of the sender.
• Encrypted Security Payload: Encrypts the packet's payload for confidentiality.
• Destination Option: Provides options that are processed by the destination host.
These extension headers offer additional capabilities beyond the basic functionality of the
IPv6 base header.
• Hop-by-Hop Options: Used for information passed to all routers along the path, such
as management or debugging data.
• Destination Options: Used for information passed only to the destination, not
intermediate routers.
• Source Routing: Allows the source to specify the route a packet should take.
• Fragmentation: Handles fragmentation of large packets, with the source responsible
for fragmentation based on Path MTU Discovery.
• Authentication: Verifies the sender and ensures data integrity.
• Encrypted Security Payload (ESP): Provides confidentiality and protection against
eavesdropping.
These extension headers enhance IPv6's capabilities and flexibility, enabling various
network functions and security measures.
IPv6 introduced new options and reorganized existing ones compared to IPv4:
• No-Operation and End-of-Option: Replaced by Pad1 and PadN in IPv6 for
alignment purposes.
• Record Route and Timestamp: Not implemented in IPv6 due to limited usage.
• Source Route: Retained as a source routing extension header in IPv6.
• Fragmentation: Moved from the base header to a fragmentation extension header in
IPv6.
• Authentication and Encrypted Security Payload: New options introduced in IPv6
for enhanced security.
These changes reflect the evolving needs of network communication and the desire for
improved security and flexibility in IPv6.