Chapter IV Network Layer Couche Réseaux
Chapter IV Network Layer Couche Réseaux
• Explain the role of the Network Layer and end-to-end packet delivery across multiple
networks.
• Compare IPv4 and IPv6 (address format, header structure, key features).
1 Network Layer 4
1.1 IPv4 Addressing: Fundamentals . . . . . . . . . . . . . . . . . . . . . . . . 4
1.1.1 Types of IPv4 Traffic . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2 IPv4 Address Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2.1 Network Mask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2.2 Broadcast Address . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.3 IP Address Classes (Historical) . . . . . . . . . . . . . . . . . . . . . . . . 5
1.4 Dividing a Class into Subnets (Subnetting) . . . . . . . . . . . . . . . . . . 8
1.5 Classless Inter-Domain Routing (CIDR) . . . . . . . . . . . . . . . . . . . 10
1.5.1 Why CIDR was introduced . . . . . . . . . . . . . . . . . . . . . . . 10
1.5.2 From subnetting to supernetting (CIDR + VLSM) . . . . . . . . . 10
1.5.3 Route summarization example . . . . . . . . . . . . . . . . . . . . . 11
1.5.4 VLSM example (address planning) . . . . . . . . . . . . . . . . . . 11
1.5.5 CIDR notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.6 Practical Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.7 Private Networks and Address Translation (NAT) . . . . . . . . . . . . . . 15
1.7.1 NAT in home networks (“router/box” example) . . . . . . . . . . . 16
1.7.2 NAT on GNU/Linux: netfilter/iptables . . . . . . . . . . . . . . . . 16
1.7.3 SNAT and DNAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1.7.4 Two typical traffic directions . . . . . . . . . . . . . . . . . . . . . . 17
1.8 IP Protocol: IPv4 and IPv6 . . . . . . . . . . . . . . . . . . . . . . . . . . 17
1.8.1 IPv4 overview and header fields . . . . . . . . . . . . . . . . . . . . 17
1.8.2 IPv6 Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
1.9 Packet Fragmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
1.9.1 MTU and why fragmentation occurs . . . . . . . . . . . . . . . . . 35
1.10 Packet Switching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
1.10.1 Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
1.10.2 Packet switching vs circuit switching (idea) . . . . . . . . . . . . . . 41
1.11 Routing: Centralized and Distributed Techniques . . . . . . . . . . . . . . 41
1.11.1 Static Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
2
Computer Networks Chapter IV: Network Layer
3
Chapter 1 Network Layer
Unicast Communication between one unique source host and one unique destination
host.
Multicast Communication between one unique source host and a group of hosts that
have chosen to receive the stream. A common analogy is TV broadcasting: the
transmission is continuous, but only televisions tuned to that channel display it.
Broadcast A flow sent by one host to all other hosts within the same broadcast domain.
This exists only on broadcast networks such as Ethernet. For example, the ARP
protocol uses a broadcast frame to ask all hosts on the local network which MAC
address corresponds to a known IPv4 address.
4
Computer Networks Chapter IV: Network Layer
5
Computer Networks Chapter IV: Network Layer
Class A
The first octet is in the range 1 to 126, meaning the most significant bit is 0. The first
octet identifies the network number, and the remaining three octets identify the host
address.
Special reservation
Class B
The first octet is in the range 128 to 191, meaning the two most significant bits are
10. The first two octets identify the network number, and the remaining two octets
identify the host address.
Class C
The first octet is in the range 192 to 223, meaning the three most significant bits are
110. The first three octets identify the network number, and the last octet identifies
the host address.
Class D
The first octet is in the range 224 to 239. This range is dedicated to multicast services
for groups of hosts (host groups). (In classful terms, the high-order bits start with 1110.)
6
Computer Networks Chapter IV: Network Layer
Class E
The first octet is in the range 240 to 255. This range is reserved for experimental
purposes and must not be used to address hosts or groups of hosts. (High-order bits start
with 1111.)
• Class A: 50%
• Class B: 25%
• Class C: 12.5%
• Class D: 6.25%
• Class E: 6.25%
In addition to this poor distribution, many criticisms were made about how IPv4
classes were allocated during the early years of the Internet. Since classes were often
assigned on request without matching real needs, this resulted in significant waste of
address space.
Over time, several generations of solutions were introduced to compensate for these
distribution problems. The following sections present these solutions in chronological
order.
7
Computer Networks Chapter IV: Network Layer
• Many worms and/or viruses spread by discovering targets using broadcast mecha-
nisms. The Sasser worm is a classic example. By segmenting a network into multiple
broadcast domains, the spread of malicious code is naturally limited. Subnetting
therefore becomes part of the network security toolbox.
8
Computer Networks Chapter IV: Network Layer
• The subnet address [Link] could be interpreted as the network address for
two different networks:
• Similarly, the broadcast address [Link] could be the broadcast address for
two different networks: [Link]/24 and [Link]/27.
9
Computer Networks Chapter IV: Network Layer
The original CIDR specification was published in the early RFC 1518/1519/1520
series (1993). RFC 4632 is a later update that consolidates and replaces earlier
CIDR RFCs.
• the inefficiency of IPv4 address allocation (no more forced “full class” blocks),
10
Computer Networks Chapter IV: Network Layer
• the rapid growth of Internet routing tables (aggregation reduces the number of
routes).
CIDR reduced IPv4 allocation problems because the Internet Assigned Numbers Au-
thority (IANA) was no longer forced to allocate entire classful blocks. Instead of reserving
half of the IPv4 space for huge Class A networks, that space could be split into smaller
blocks that are easier to allocate.
CIDR, together with Network Address Translation (NAT), helped IPv4 remain
usable far beyond the limits predicted in the early 1990s.
[Link]/24 10101100.00010000.00001100.00000000
[Link]/24 10101100.00010000.00001101.00000000
[Link]/24 10101100.00010000.00001110.00000000
[Link]/24 10101100.00010000.00001111.00000000
In these four networks, the first 22 bits are identical. Therefore, a single summary
route can represent all four entries:
Address: [Link]
Netmask: [Link] (= /22)
/22 ⇒ 11111111.11111111.11111100.00000000
Figure 1.3:
11
Computer Networks Chapter IV: Network Layer
VLSM is not only useful for major Internet Service Providers (ISPs). Any administrator
managing multiple subnets can use VLSM to use an assigned address block more efficiently.
Suppose the ISP assigns the network [Link] with mask [Link], i.e.:
[Link]/25
Note that the maximum number of usable host addresses equals the subnet size minus
two:
12
Computer Networks Chapter IV: Network Layer
The notation /27 means 27 network bits set to 1, which corresponds to:
[Link]
CIDR and VLSM techniques have been used to optimize IPv4 addressing across the entire
Internet.
[Link]/21
Q2: How many bits were borrowed for private subnets relative to
the historical class definition?
Since the first octet value is between 128 and 191, the address belongs historically to
Class B. The default Class B mask is:
[Link] (= /16)
13
Computer Networks Chapter IV: Network Layer
21 − 16 = 5 bits
25 = 32
• Historical rule (RFC 950, classful routing): exclude the first (all-zeros) and
last (all-ones) subnet ⇒ 32 − 2 = 30 usable subnets.
• Modern rule (classless routing / CIDR): all subnets are usable ⇒ 32 usable
subnets.
32 − 21 = 11
19 = 000100112
For /21, the third octet uses 5 network bits, so the mask bits in that octet are:
111110002
Bitwise AND:
00010011 & 11111000 = 000100002 = 16
14
Computer Networks Chapter IV: Network Layer
The fourth octet is in the host part, so it becomes 0 for the network address. Thus the
subnet address is:
[Link]
Bitwise OR:
00010011 | 00000111 = 000101112 = 23
[Link]
• If the private network is never connected to the Internet, it may use any IPv4
addresses.
RFC 1918 defines the network prefixes reserved for private use. The three ranges
shown in Table 1.5 are not routed on the public Internet. In practice, if a public router
receives a packet whose source or destination IPv4 address belongs to one of these private
ranges, it is dropped.
In real deployments, the second case (private network connected to the Internet) is by
far the most common.
15
Computer Networks Chapter IV: Network Layer
Limitation of NAT
NAT is not perfect: hosts inside the private network are not directly reachable from
the public Internet. Additional mechanisms are required to manage transport-layer
port multiplexing (e.g., port forwarding, NAT traversal tools).
• sharing a single public Internet interface among all hosts in a private network,
• making a server inside the private network accessible from the Internet.
• Source NAT (SNAT): the source IPv4 addresses of packets sent by private
hosts are rewritten using a public IPv4 address.
16
Computer Networks Chapter IV: Network Layer
• Access from the Internet to the private network: requests to services (HTTP,
DNS, mail, etc.) are translated to the corresponding server address inside the private
network (often through port forwarding / DNAT).
• Data (payload)
17
Computer Networks Chapter IV: Network Layer
Sizes to remember
• Minimum IPv4 header = 20 bytes
IHL / HLEN (4 bits) Internet Header Length = header size expressed in 32-bit words
(multiples of 4 bytes).
Header bytes = IHL × 4
Total Length (16 bits) Total size of the IPv4 datagram in bytes:
Identification (16 bits) Used for fragmentation. All fragments of the same original
datagram share the same Identification value so the destination can reassemble
them.
Fragment Offset (13 bits) Indicates where this fragment belongs in the original data-
gram. It is measured in units of 8 bytes. Example: offset = 185 means fragment
data starts at 185 × 8 = 1480 bytes.
18
Computer Networks Chapter IV: Network Layer
TTL (Time To Live) (8 bits) Prevents infinite loops. Decremented by 1 at each router
hop. When TTL reaches 0, the packet is dropped (usually with an ICMP Time Ex-
ceeded message).
Header Checksum (16 bits) Checksum of the IPv4 header only (not the data). It
must be recomputed at each hop because fields like TTL change.
Options (0–40 bytes) + Padding Optional fields (rare in modern networks) used for
special functions (e.g., record route, timestamp). If options are present, padding is
added so the header length remains a multiple of 4 bytes (consistent with IHL).
Data (Payload)
The Data part contains the upper-layer segment (TCP/UDP/ICMP, etc.) and applica-
tion data. Its maximum size depends on the MTU of the path; large datagrams may
require fragmentation (IPv4) or should be avoided using Path MTU Discovery.
The TTL (Time To Live) field is decreased by 1 at each router. When it reaches
0, the packet is dropped, preventing infinite loops.
19
Computer Networks Chapter IV: Network Layer
Header structure:
• Version (4 bits): this represents the IP protocol version number (here 6). Same
field as in IPv4 (value 4).
• Traffic Class (8 bits): this field is used for Quality of Service to identify traffic
classes; it replaces the IPv4 ToS field (to be verified ).
• Flow Label (20 bits): it allows marking special flows for differentiated processing.
• Payload Length (16 bits): this represents, in bytes, the size of the packet payload
after the header. It allows packets larger than 64 KB. It replaces the Total Length
field in IPv4.
20
Computer Networks Chapter IV: Network Layer
• Next Header (8 bits): indicates the type of header that immediately follows the
IPv6 header. Same idea as the Protocol field in IPv4 and the same values are used
(TCP=6, UDP=17, ICMP=1). Other IPv6-specific values are added (Hop-by-Hop
Option=0, Source routing=43, Fragmentation=44, etc.). This field is what enables
encoding optional extension headers.
• Hop Limit (8 bits): same as TTL in IPv4; it is decremented at each hop. If its
value reaches 0, the packet is destroyed. It helps eliminate routing loops.
• Source Address (128 bits) and Destination Address (128 bits): represent
respectively the address of the sender of the packet and the address of a destination
that may be different from the final destination address if the Routing Header option
is present.
N.B.: it is important to note that the fields ID, Flag, Fragment Offset, Checksum,
Header Length present in IPv4 are removed in IPv6.
• 2: ICMP (payload)
• 6: TCP (payload)
21
Computer Networks Chapter IV: Network Layer
• Header Extension Length (8 bits): number of 8-byte units (excluding the first
8 bytes)
• Options (variable)
• C (1 bit): whether the option may change in transit (0: no, 1: yes)
• Length: size of the Data field (type and length not included)
22
Computer Networks Chapter IV: Network Layer
Routing Header
The Routing Header lets the source list intermediate nodes to visit on the way to the
destination. Key fields:
Fragment Header
Used by the source when a packet is larger than the path MTU. (Routers do not fragment
in IPv6.) Key fields:
23
Computer Networks Chapter IV: Network Layer
IV.1 Notation
The size of IP addresses has increased from 32 bits in IPv4 to 128 bits in IPv6; that is,
four times larger than IPv4.
With this size, it is possible to assign up to 5 × 1028 IP addresses per person, which is
currently impossible to exhaust.
Like IPv4 addresses, IPv6 addresses need an efficient notation for good presentation
and use by humans.
[Link].[Link].[Link].[Link]
This consists of dividing the 128 bits into 8 blocks of 2 bytes each. Each block is repre-
sented by 4 hexadecimal digits. The blocks are separated by colons “:”.
General format (X represents a 4-bit portion):
Example:
This type of representation can be abbreviated for better simplicity and readability.
24
Computer Networks Chapter IV: Network Layer
Rule 1: Omission of leading zeros (0) in a block. Zeros that begin a block can be
omitted.
Example:
Figure 1.8:
05F 0 : 00B5 : 89C2 : 00A1 : 0000 : 0800 : 200A : 0000 becomes 5F 0 : B5 : 89C2 : A1 : 0 : 800 : 200A :
• For 2031:0000:130F:0000:0000:09C0:876A:130B
– 2031:0:130F::9C0:876A:130B is correct;
– 2031::130F::9C0:876A:130B is not correct;
• For 05F0:00B5:89C2:00A1:0000:0800:200A:0000
– 5F0:B5:89C2:A1::800:200A:0 is correct;
– 5F0:B5:89C2:A1:0:800:200A:: is correct;
– 5F0:B5:89C2:A1::800:200A:: is not correct;
25
Computer Networks Chapter IV: Network Layer
This consists of using dotted-decimal notation for the last two blocks of an IPv6 address:
Example:
FEDC:14AB:2311:BBFE:AAAA:BBBB:[Link]
Figure 1.9:
• IPv4-mapped IPv6 address: This is the case of an IPv6 host that is able to
communicate with both an IPv4 host and an IPv6 host:
0::FFFF:[Link]/96
Prefix representation is done like CIDR notation in IPv4. In this notation, the prefix
length is written as /number.
Examples:
• In IPv4: [Link]/16.
• In IPv6: 2001:DB8::12/40.
26
Computer Networks Chapter IV: Network Layer
Figure 1.10:
• A network part (prefix) encoded on 64 bits: 48 public bits “Global Routing Prefix”
and 16 site bits defining the subnet.
• A host part (suffix) also encoded on 64 bits: it is often built from the MAC address
of the interface and makes it possible to identify a machine in a given network.
Figure 1.11:
We distinguish three types of Unicast address: Link-Local, Unique Local, and Global.
A Link-Local address has link-level scope (works only on a given link). It identifies only
machines that are in the same Layer 2 domain (same LAN).
27
Computer Networks Chapter IV: Network Layer
It is identified by the prefix FE80::/10 (the first 10 bits are fixed and equal in binary
to 1111111010).
Figure 1.12:
ULA addresses make it possible to identify all machines accessible within a site of the
same organization containing several local networks. They are intended for private use
and can be reused by other organizations without conflict. Their usage is similar to that
of private networks under IPv4, but without NAT. They are therefore not routable on the
Internet.
These addresses use the prefix FC00::/7 (binary value 11111100 or 11111101).
Figure 1.13:
A Global Unicast address makes it possible to identify all equipment accessible from the
Internet. It has global scope.
These types of addresses are the only unicast routable on the Internet.
They use the prefix 2000::/3 (binary value 0010).
28
Computer Networks Chapter IV: Network Layer
• Lifetime, encoded on 4 bits, following the prefix: one of its bits makes it possible to
distinguish permanent groups from temporary groups.
• Scope, on 4 bits: this field allows limited diffusion over an area (node, site, link,
organization, global).
Figure 1.14:
29
Computer Networks Chapter IV: Network Layer
Figure 1.15:
• Reserved addresses:
30
Computer Networks Chapter IV: Network Layer
Figure 1.16:
Figure 1.17:
Figure 1.18:
• The first block (1/256) is allocated for IPv4-compatible addresses and special ad-
dresses such as Loopback.
Figure 1.19:
31
Computer Networks Chapter IV: Network Layer
• Unspecified address:
It is an address whose 128 bits are all 0:
Figure 1.20:
It is widely used by a device that does not know its IP address and requests one.
It cannot be used as a destination address.
Notation: ::/128 or 0:0:0:0/128
• Loopback address:
This address provides network functionalities on a single device.
IPv6 allocates only one IP address, unlike IPv4 which allocates the whole network
[Link].
All the first 127 bits are 0 and the last bit is 1:
Figure 1.21:
• IPv4-compatible address:
With this type of address, within the last 120 bits, 96 are 0 and the remaining 32
bits are occupied by the IPv4 address:
Figure 1.22:
This address is used to allow two IPv6 machines to communicate across an IPv4
network.
Notation: ::[Link]/96
32
Computer Networks Chapter IV: Network Layer
Figure 1.23:
This type of address is used by an IPv6 device that wants to communicate with an
IPv4 device.
Notation: 0::FFFF:[Link]/96
This space is partially assigned and contains Unique Local Unicast, Link-Local, and Mul-
ticast addresses.
Figure 1.24:
Figure 1.25:
33
Computer Networks Chapter IV: Network Layer
Figure 1.26:
Figure 1.27:
• Allocation process:
The first 48 bits of the Global Unicast space, which represent the Global Routing
Prefix, follow a very specific allocation process.
In the block 2000::/3, the IANA (Internet Assigned Numbers Authority) assigns
each registry (AfriNIC, APNIC, LACNIC, ARIN and RIPE NCC) a /12 prefix.
The registry allocates a /32 prefix or more to each IPv6 Internet Service Provider
(ISP).
Now, the strategy recommends that ISPs assign a /48 prefix to each end user.
For the 16 bits of the Subnet ID part, this allows end customers to have up to
216 = 65536 subnets.
The Interface ID part, on 64 bits, allows up to 264 hosts on each subnet. This part
makes it possible to create a relationship between the IPv6 address and the MAC
address.
Indeed, it is possible to integrate the MAC address, which is 48 bits, into the
Interface ID part of the IPv6 address using a mapping.
34
Computer Networks Chapter IV: Network Layer
Figure 1.28:
35
Computer Networks Chapter IV: Network Layer
Figure 1.29:
• Identification: A 16-bit value that is the same for all fragments of a packet.
– Bit 0: Reserved.
– Bit 1: DF (Don’t Fragment) – when set, packet cannot be fragmented.
– Bit 2: MF (More Fragments) – when set, more fragments follow.
• Fragment Offset: Indicates where in the original packet this fragment belongs (in
8-byte units).
2. Fragmentation Process
Figure 1.30:
36
Computer Networks Chapter IV: Network Layer
FRAGMENTATION EXAMPLE
Original Packet: 4000 bytes + 20 byte IPv4 header = 4020B
MTU = 1500 bytes
Maximum payload per fragment = 1500 - 20 = 1480 bytes
Fragment 1:
– IP Header (20B) with MF=1, Offset=0
– Data: 1480 bytes (0–1479)
Fragment 2:
– IP Header (20B) with MF=1, Offset=185 (1480/8=185)
– Data: 1480 bytes (1480–2959)
Fragment 3:
– IP Header (20B) with MF=0, Offset=370 (2960/8=370)
– Data: 1040 bytes (2960–3999)
Problem. An IPv4 router with a Maximum Transmission Unit (MTU) of 200 bytes
receives an IPv4 packet of total size 520 bytes. The IPv4 header length is 20 bytes.
Determine the fragmentation and the values of the relevant IPv4 header fields for each
fragment.
Given
MTU = 200 bytes, Header length = 20 bytes, Original total length = 520 bytes
Each fragment must fit within the MTU including its own IPv4 header:
The Fragment Offset is measured in units of 8 bytes, so all fragments except the last
should carry a data size that is a multiple of 8.
Thus:
Data per full fragment = 176 bytes
37
Computer Networks Chapter IV: Network Layer
Offsets are in 8-byte units, counting from the start of the original payload:
The Identification field is the same for all fragments (router copies it). The DF flag is
0 (since fragmentation occurs). The MF flag is 1 for all but the last fragment.
The packet is fragmented into 3 fragments. The relevant header values are summa-
rized in the table above: total lengths (196, 196, 168) bytes, fragment offsets (0, 22, 44)
in 8-byte units, and MF set for the first two fragments only.
II-Challenges with Fragmentation
a. Performance Impact:
Fragmentation can impact network performance in several ways:
38
Computer Networks Chapter IV: Network Layer
Figure 1.31:
b. Fragmentation in IPv6:
IPv6 handles fragmentation differently from IPv4:
c. Fragmentation Attacks:
Fragmentation can be exploited for various attacks:
39
Computer Networks Chapter IV: Network Layer
Figure 1.32:
b. MSS Clamping
MSS (Maximum Segment Size) clamping adjusts the TCP MSS to prevent fragmen-
tation:
Figure 1.33:
1.10.1 Principle
Packet switching breaks messages into packets that are forwarded independently:
40
Computer Networks Chapter IV: Network Layer
• Packet switching: efficient resource sharing, but variable delay under congestion.
R1
Packet 1 Packet 1
Host A Host B
Packet 2 Packet 2
R2
Figure 1.35:
Routing is the process of forwarding packets from one network to another by choosing
the best path from the routing table.
A routing table contains only the best routes to each destination.
41
Computer Networks Chapter IV: Network Layer
Types of Routing
There are three ways a router can learn a route to a destination:
1. Static Routing
2. Dynamic Routing
3. Default Routing
• When there is no entry for the destination network in the routing table, the router
forwards the packet to its default router.
42
Computer Networks Chapter IV: Network Layer
Routing Algorithm
The main function of the network layer is to route packets from source to destination.
A routing algorithm is the part of the network-layer software responsible for deciding
which output line an incoming packet should be transmitted on.
Routing algorithms can be grouped into two major classes:
• Static (non-adaptive)
• Dynamic (adaptive)
• They do not base their routing decisions on measurements or estimates of the current
traffic and topology.
• They change their routing decisions to reflect changes in the topology and usually
the traffic as well.
Flooding
• Flooding is a simple local technique in which each router makes decisions based only
on local knowledge, not on the complete picture of the network.
• Every incoming packet is sent out on every outgoing line except the one on which
it arrived.
• It generates an infinite number of duplicate packets unless some measures are taken
to limit the process.
43
Computer Networks Chapter IV: Network Layer
• One such measure is to include a hop counter in the header of each packet. This
counter is decremented at each hop, and the packet is discarded when the counter
reaches zero.
• It finds the shortest path from a specified source to all other destinations in the
network.
• In the general case, the labels on the links can be computed as a function of distance,
bandwidth, average traffic, communication cost, measured delay, and other factors.
• The Bellman equation is used to find the least cost, or shortest distance, between
a source and a destination.
• In a distance vector routing algorithm, each router maintains a table, or vector, that
gives the best known distance to each destination.
• A distance vector router tells only its neighbors about all routes.
• RIP is based on distance vector routing. Each router shares, at regular intervals,
its knowledge about the entire Autonomous System with its neighbors.
• It is slow and does not take bandwidth into consideration when choosing the route.
44
Computer Networks Chapter IV: Network Layer
Note that a link-state router tells all other routers only about its own neighbors
and links.
Compared with distance vector routing, link state routing requires more memory and
more computation. Also, the computation time grows faster.
Nevertheless, in many practical situations, link state routing works well because it
does not suffer from slow convergence problems.
OSPF
OSPF (Open Shortest Path First) is a link-state routing protocol used within
an Autonomous System. It exchanges link-state information among routers, builds a
complete view of the network topology, and uses Dijkstra’s algorithm to calculate the
shortest path tree and determine the best route to each destination.
45
Computer Networks Chapter IV: Network Layer
[leftmargin=*,nosep] [leftmargin=*,nosep]
• Routers do not have end-to-end vis- • Routers have visibility of the entire
ibility of the entire network. network within that area only.
• Easy to configure.
• Not only is router memory consumed by ever-increasing tables, but more CPU time
is also needed to scan them, and more bandwidth is required to send status reports
about them.
• Each router knows all the details needed to route packets to destinations within its
own region, but it knows nothing about the internal structure of other regions.
46
Computer Networks Chapter IV: Network Layer
Figure 1.36:
• The source should send the packet to all the required destinations.
• One problem with this method is that the source has to maintain the complete list
of destinations.
Sending a message to a specific group is called multicasting, and the routing algo-
rithm used is called multicast routing.
• They also require a mechanism to identify which routers are members of a group.
• Routing metric: a method used by routing algorithms to determine that one route
is better than another.
47
Computer Networks Chapter IV: Network Layer
• They use less complicated metrics to simplify configuration and speed up decisions
about the best routing paths, which leads to faster convergence.
• Border Gateway Protocol (BGP) is the only widely used EGP on the Internet.
48
Computer Networks Chapter IV: Network Layer
Figure 1.37:
Figure 1.38:
• RIP is a routing protocol used for exchanging routing table information between
routers.
• RIP prevents routing loops by implementing a limit on the number of hops allowed
in a path from the source to a destination.
49
Computer Networks Chapter IV: Network Layer
• This hop limit also limits the size of networks that RIP can support.
Figure 1.39:
• There are three types of timers in RIP routing protocol, these are:
Figure 1.40:
50
Computer Networks Chapter IV: Network Layer
Drawbacks of RIP
• RIP has slow convergence and suffers from the count-to-infinity problem.
• The hop count cannot exceed 15; otherwise, the route is dropped.
Figure 1.41:
Figure 1.42:
Figure 1.43:
51
Computer Networks Chapter IV: Network Layer
Figure 1.44:
1. This protocol is open, which means that anyone can implement it without paying
license fees.
2. OSPF uses a link-state routing algorithm and belongs to the group of interior
routing protocols, operating within a single Autonomous System (AS). OSPF
is one of the most widely used Interior Gateway Protocols (IGPs) in large
enterprise networks.
6. The OSPF metric calculation is based on cost. Cost indicates the overhead required
to send packets across a certain interface.
Hierarchical OSPF
To minimize processing and memory requirements, OSPF can divide the routing topology
of an Autonomous System into a two-layer hierarchy called the local area (standard area)
and the backbone area (referred to as Area 0 or the Transit Area).
The main advantages of this division are:
52
Computer Networks Chapter IV: Network Layer
3. Each router within an area has a detailed view of the area’s topology and knows
only the direction (shortest path) to networks in other areas.
• Area Border Router (ABR): connects local areas to the backbone area. It
summarizes distances to networks in its own area and advertises them to other Area
Border Routers.
Figure 1.45:
53
Computer Networks Chapter IV: Network Layer
• Compared with RIP, OSPF has no hop limitation. In RIP, the maximum hop count
is 15, so any network requiring more than 15 hops cannot be reached using RIP.
• It uses triggered updates, which means it does not send periodic updates.
• EIGRP uses the minimum bandwidth along the path to the destination network
and calculates the route using the total delay metric.
• Network administrators can specify routing policies, which gives BGP a high
degree of flexibility.
• The main goal of BGP is to find any valid path, not necessarily the optimal one.
iBGP eBGP
Used to connect routers within the Used to connect routers in different
same Autonomous System (AS). Autonomous Systems (ASs).
Used inside the same company or or- Used between different companies or
ganization. service providers.
Propagates reachability information Obtains subnet reachability informa-
to all routers inside the AS. tion from neighboring ASs.
54
Computer Networks Chapter IV: Network Layer
Figure 1.46:
BGP Basics
1. BGP Session: Two BGP routers, called peers, exchange BGP messages.
Figure 1.47:
• Using an eBGP session between routers 3a and 1c, AS3 sends prefix reacha-
bility information to AS1.
• Router 1c can then use iBGP to distribute the new prefix information to all
routers inside AS1.
• Router 1b can then re-advertise the new reachability information to AS2 over
the 1b-to-2a eBGP session.
• When a router learns a new prefix, it creates an entry for that prefix in its
forwarding table.
55
Computer Networks Chapter IV: Network Layer
Figure 1.48:
A router may learn more than one route to the same destination Autonomous System
(AS). In such cases, BGP selects the best route based on the following criteria:
1. Local Preference Value: the route with the preferred local policy is selected first.
3. Closest NEXT-HOP Router: the route with the nearest next-hop router is
selected.
BGP Messages
BGP messages are exchanged between peers over a TCP connection. BGP has four
types of messages:
• KEEPALIVE: informs a peer that the sender is still active, even if it has no new
information to send.
• NOTIFICATION: indicates that an error has been detected and is also used to
close the connection.
56
Computer Networks Chapter IV: Network Layer
Figure 1.49:
– Router 1 = [Link]
– Router 2 = [Link]
– Router 1 = [Link]
– Router 3 = [Link]
– Router 2 = [Link]
– Router 3 = [Link]
– Router 3 = [Link]
57
Computer Networks Chapter IV: Network Layer
Explanation
58
Computer Networks Chapter IV: Network Layer
Figure 1.50:
– Router 1 = [Link]
– Router 2 = [Link]
– Router 1 = [Link]
– Router 3 = [Link]
– Router 2 = [Link]
– Router 3 = [Link]
– Router 2 = [Link]
– Host = [Link]
59
Computer Networks Chapter IV: Network Layer
– Router 3 = [Link]
– Host = [Link]
Important Note
The exact routing table depends on the dynamic routing protocol used (RIP, OSPF,
or EIGRP) and on the metric values. Also, the links connected to Router 4 are not
labeled in the figure, so its full routing table cannot be determined exactly from the image
alone.
Router 1
Router 2
Router 3
Explanation
In dynamic routing, routers learn remote networks automatically from neighboring routers.
60
Computer Networks Chapter IV: Network Layer
2. For the network [Link]/24, propose a subdivision into 8 subnets and provide:
4. An IPv4 datagram is 3000 bytes (20-byte header). MTU = 1000. Compute the
number of fragments and offsets.
6. Give one practical example for static routing and one for dynamic routing.
61
Computer Networks Chapter IV: Network Layer
References (optional)
• IPv4 fundamentals and fragmentation concepts.
62