0% found this document useful (0 votes)
48 views92 pages

Chapter4 Network Layer

Chapter 4 of 'Computer Networks (8th Edition)' discusses the network layer, detailing the OSI and TCP/IP protocol architectures. It covers essential concepts such as Internet Protocol (IP), packet forwarding, and the differences between virtual circuit and datagram services. Additionally, it explains IP addressing, including classful and classless addressing (CIDR), and the importance of unique IP addresses for communication across interconnected networks.

Uploaded by

official.casety
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views92 pages

Chapter4 Network Layer

Chapter 4 of 'Computer Networks (8th Edition)' discusses the network layer, detailing the OSI and TCP/IP protocol architectures. It covers essential concepts such as Internet Protocol (IP), packet forwarding, and the differences between virtual circuit and datagram services. Additionally, it explains IP addressing, including classful and classless addressing (CIDR), and the importance of unique IP addresses for communication across interconnected networks.

Uploaded by

official.casety
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Chapter 4

Network layer
Computer Networks
(8th Edition)
Computer Network Architecture

OSI seven-layer protocol architecture TCP/IP 's four-layer protocol architecture The architecture of the five-layer protocol

7 Application Layer
4 Application Layer
6 5
Application Layer
Presentation Layer ( Various application layer protocols, such as
5 DNS, HTTP, SMTP, etc. )
Session Layer 4
4

3 3
Transport layer 3 Transport layer (TCP or UDP) Transport layer
2 2
Network Layer 2 Internet Layer IP Network Layer
1 1

Data Link Layer Data Link Layer


1 Network Interface Layer

Physical Layer (This layer does not have specific content) Physical Layer

(a) (b) (c)


4.1 Several important concepts of the network layer

4.2 Internet Protocol (IP)

4.3 The process of forwarding packets at the IP layer

4.4 Internet Control Message Protocol ICMP

4.5 IPv6

4.6 Internet Routing Protocols

4.7 IP Multicast

4.8 Virtual Private Network (VPN) and Network Address Translation (NAT)

4.9 Multi-Protocol Label Switching (MPLS)

4.10 Introduction to Software Defined Network (SDN)


4.1​ 4.1.1 Two services provided by the network layer
Several
important 4.1.2 Two levels of the network layer
concepts of the
network layer
4.1.1 Two services provided by the network layer
debate:

l What kind of service should the network layer provide to the transport layer?

Connection-oriented or connectionless?

l In computer communications, who is responsible for reliable delivery ? The network

or the end system?

2 views:

l Connection-oriented reliable delivery.

l A connectionless , best-effort datagram service with no quality of service

commitments.
One view: Let the network be responsible for reliable delivery
l Computer networks mimic telecommunications networks and use

connection-oriented communication.

l Before communication, a virtual circuit (VC) is established. (Virtual Circuit)

( i.e. connection ) to ensure all network resources required for

communication between the two parties.

l reliable transmission network protocol is used , the sent packets can arrive

at the destination error-free and in order without loss or duplication.


Virtual Circuit Service

Application Layer H 1 H2​


Application Layer
Transport layer
Transport layer
Network Layer
Network Layer
Data Link Layer
Data Link Layer
Physical Layer Virtual Circuit
Physical Layer

H 1 Send to H 2 All packets are transmitted along the same virtual circuit

A virtual circuit is just a logical connection. Packets are transmitted along this logical connection in a

store-and-forward manner, and a physical connection is not actually established .


Another view: Networks provide datagram services

The design ideas adopted by the Internet:

l The network layer should be designed to be as simple as possible, providing only simple, flexible , connectionless,

best-effort datagram services to its upper layer.

u The network does not need to establish a connection before sending packets.

u Each packet (i.e. IP datagram) is sent independently and has nothing to do with the packets before and after it

(no numbering).

u The network layer does not provide a commitment to quality of service, that is, the transmitted packets may be

erroneous, lost, duplicated, or out of order (not arriving at the destination in order), and the time limit for packet

transmission is not guaranteed.

l The transport layer in the host is responsible for reliable communication.


Datagram Service

Application Layer H IP Datagram H2​


1 Application Layer
Transport layer
Transport layer
Network Layer
Network Layer
Data Link Layer
Data Link Layer
Physical Layer
Lost Physical Layer

H 1 Send to H 2 Packets may be transmitted along different paths


Comparison between virtual circuit service and datagram service

Aspects of comparison Virtual Circuit Service Datagram Service

Reliable communication should be Reliable communication should be


Ideas
guaranteed by the network guaranteed by the user host
Connection
Must have unnecessary
establishment
Only used during the connection
Each packet has the complete address of the
Destination address establishment phase, each packet uses a
destination
short virtual circuit number
Packets belonging to the same virtual
Each packet independently selects a route for
Packet forwarding circuit are forwarded according to the same
forwarding
route
All virtual circuits passing through the failed Failed nodes may lose packets and some
When a node fails
node are inoperable. routes may change
Always arrive at the destination in the order Arriving at the destination is not necessarily
Order of groups
sent in the order in which it was sent.

End-to-end error Can be the responsibility of the network or


The user host is responsible for
handling and flow control the user host
4.1.2 Two levels of the network layer
l different networks requires packets to be forwarded by
several routers.
l two types of information transmitted between routers :
1. data.
2. Routing information (for data transmission).
4.2.1 Virtual Interconnection Network
4.2
Internet
4.2.2 IP address
Protocol
(IP)
4.2.3 IP address and MAC address

4.2.4 Address Resolution Protocol ARP

4.2.5 IP Datagram Format


4.2 Internet Protocol (IP)
three protocols supporting the Various application layer protocols

Internet Protocol IPv4 :


Application Layer
(HTTP, FTP, SMTP, etc. )

1. Address Resolution Protocol Transport layer TCP, UDP

ARP (Address Resolution ICMP IGMP


Network Layer

Protocol)
(Internet Layer)
IP

2. Internet Control Message ARP

Protocol ICMP (Internet


Interface with various networks
Network interface layer

Control Message Protocol) Physical Hardware

3. IGMP (Internet Group


Management Protocol )
4.2.1 Virtual Interconnection Network
There are many issues that need to be addressed when achieving network interconnection and intercommunication, such
as the following differences:

Maximum Network
Addressing Timeout
packet access
scheme control
length mechanism

Error Status
Routing User access
recovery reporting
Technology control
method method

Serve
Management and
Control method

How to connect different networks ?


Which method is better for interconnecting different networks?

A. Both use the same network?

• Cannot meet the needs of different users. No single


network can meet the needs of all users.
• Not adapting to technological development

B. Use an intermediate device?

• Can meet different needs


• practical
Interconnection using middleware

layer Middleware
Transport layer and
Gateway (gateway)
above

Network Layer router (router)

Bridge or bridge (bridge) ,


Data Link Layer
Switch​

Physical Layer Forwarder (repeater)


H 1
Packet transmission in the Internet
5
R 3
4
R 1 R 2
3 3 3 3

2 twenty two twenty two twenty two

1 11 11 11

Host R 3
R 1 R 2
H1
Indirect delivery
Indirect delivery Indirect delivery

e ry
eliv
ct d
ire
In d
R 5 R 4

Indirect delivery
R 5 R 4
ry
live
t de
The Internet can be Dir
ec
3 3

twenty two twenty two


H2​
composed of multiple 11
Host 5 11

H2​
4
interconnected 3

heterogeneous networks. 1
4.2.2 IP Address
l In the TCP/IP system, IP address is the most basic
concept.
l Without an IP address, you cannot communicate with
other devices on the Internet.
l This section focuses on:
1. IP address and its representation
2. Classified IP addresses
3. Classless Addressing (CIDR)
4. Characteristics of IP addresses
1. IP address and its representation

IP address: 32 -bit binary 10000000000010110000001100011111


code
Divided into groups of 8 bits 10000000 00001011 00000011 00011111

Every 8 bits of 128 11 3 31


binary number
Convert to decimal

Use dotted decimal 128.11.3.31


notation

Each interface of each host (or router) on the Internet is assigned an


IP address that is unique throughout the world .
Assigned by ICANN (Internet Corporation for Assigned Names and
Numbers ).
Example of dotted decimal notation

Equivalent
32 -bit binary number Dotted decimal number

10000001 00110100 00000110 00000000 129.52.6.0

11000000 00000101 00110000 00000011 192.5.48.3

00001010 00000010 00000000 00100101 10.2.0.37

10000000 00001010 00000010 00000011 128.10.2.3

10000000 10000000 11111111 00000000 128.128.255.0


IP address uses a 2- level structure

2 structure
IP address ::= { < network number >, < host number >}

2 fields: network number and host number

IP addresses are unique across the entire Internet .

IP address identifies a host connected to a network.

32 -bit

The number of digits in the network number n Network Number Host Number
(net-id) (host-id)
How much is it?

n Bit ( 32-n) bits


2. Classified IP addresses

A Address 0

net-id host-id
8 -bit 24 -bit Uni Category D
Category E

cas
B Address 1 0 t
Ad
net-id host-id dre
16 -bit 16 -bit ss
Category C
12.5%
Category A
50%
Class C Address 110
Category B
net-id host-id 25%

24 -bit 8 -bit

Class D Address 1110 Multicast Address

E Address 1111 Reserved for future use


The assigned range of each type of IP address

network Maximum assignable The first assignable The last assignable In each network
category Number of networks network number network number Maximum number of hosts

A 126 (2 7 – 2) 1 126 16777214 ( 2 24 - 2)

B 16383 (2 14 – 1) 128.1 191.255 65534 ( 2 16 - 2)

C 2097151 (2 21 – 1) 192.0.1 223.255.255 254 ( 2 8 - 2 )

Notice:

l A network address, network numbers 0 and 127 are reserved addresses and are not assigned. 0 means "this network" and 127 is reserved as a local loopback

test address.

l B network addresses, network number 128.0 is reserved by IANA and is not assigned. It can be assigned when using classless addressing ( CIDR ).

l C network addresses, network number 192.0.0 is reserved by IANA and is not assigned. It can be assigned when using classless addressing ( CIDR ).

l When assigning a host number, all 0s and all 1s are excluded . All 0s and all 1s have special meanings and uses.
Please point out the network address, host address and address type of the
following IP addresses.
(1)138.69.35.38
(2)210.32.128.6
(3)66.80.58.18

(1)138=128+8+2=10001010 (2) 210=128+64+16+2=11010010


Class B Class C
network address:138.69 network address: 210.32.128
host address:35.38 host address: 6
(3) 66 = 64+2=01000010
Class A
network address: 66
host address : 80.58.18
Advantages and disadvantages of classified IP addresses

Simple management; Unreasonable design:

Easy to use; Large address blocks

Forwarding packets waste address resources;

quickly; Even if subnetting is used,

Divide subnets and use the problem of IP address

them flexibly. exhaustion cannot be


solved .
3. Classless Addressing CIDR
l CIDR (Classless Inter-Domain Routing) : Classless inter-domain routing.

l Eliminating the traditional Class A , Class B , and Class C addresses and the

concept of subnetting can more efficiently allocate IPv4 address space, but

it cannot solve the problem of IP address exhaustion.

l Key points:

(1) Network prefix

(2) Address block

(3) Address mask


(1) Network prefix

2 structure
IP address ::= { < network prefix >, < host number >}

2 fields: network prefix and host number

32 -bit

The number of bits in the network prefix n Network Prefix Host Number
(network-prefix ) (host-id)
How much is it?

n Bit ( 32-n) bits


The biggest difference:

The number of digits in the prefix n Not fixed,


CIDR notation: slash notation (slash notation)
can be between 0 ~ Select any value between 32 .
abcd /n : The first n bits of the binary IP address are the network prefix.

For example: 128.14.35.7 /20 : The first 20 bits are the network prefix.
For example: 128.14.35.7 /20 : The first 20 bits are the network prefix.
128.14.35.7 = 10000000 00001110 00100011 00000111
network prefix: 10000000 00001110 0010
host address : 2-20=12 bit
total number of computer you can assigned : 2^12 -2
first computer ip : 10000000 00001110 00100000 00000001
128 . 14 . 32 . 1
first computer subnet mask : 11111111 11111111 11110000 00000000
255 . 255 . 240 . 0
second computer ip: 10000000 00001110 00100000 0000010
128. 14 . 32 . 2
second computer subnet mask : 11111111 11111111 11110000 00000000
255 . 255 . 240 . 0

last computer ip: 10000000 00001110 00101111 11111110


128. 14 . 47 . 254
(2) Address block

l CIDR groups all consecutive IP addresses with the same network prefix into a CIDR address block.

l IP addresses contained in a CIDR address block depends on the number of bits in the network prefix.
The address block consisting of 128.14.32.0/20 (a total of 2 12 addresses)

Minimum address
128.14.32.0 10000000 00001110 0010 00 00 00000000
10000000 00001110 0010 00 00 00000001
10000000 00001110 0010 00 00 00000010
10000000 00001110 0010 00 00 00000011
20- bit prefix for 10000000 00001110 0010 00 00 00000100 The number of
all addresses
All the same
10000000 00001110 0010 00 00 00000101
addresses that
  can be assigned

10000000 00001110 0010 11 11 11111011 is 2 12 – 2


10000000 00001110 0010 11 11 11111100
10000000 00001110 0010 11 11 11111101
Maximum address
10000000 00001110 0010 11 11 11111110
128.14.47.255 10000000 00001110 0010 11 11 11111111
Binary code representation: 10000000 00001110 0010*
For example: 135.20.36.3 /22 : The first 22 bits are the network prefix.
write down the CIDR address block. write down the subnet mask for every
computer.

135=128+4+2+1
20=16+4
36=32+4
3=2+1
135.20.36.3 = 10000111 00010100 00100100 00000011
TOTAL COMPUTER NUMBER : 2^10 - 2
FIRST COMPUTER IP : 10000111 00010100 00100100 00000001
135 . 20 . 36 . 1
first computer subnet mask : 11111111 11111111 11111100 000000
255 . 255 . 252 . 0
LAST COMPUTER IP: 10000111 00010100 00100111. 11111110
135. 20 . 39 . 254
the rest computer subnet mask : 255 . 255 . 252 . 0
the computer ip : 192 . 168.94.57
the subnet mask : 255.255.255.0
we can get the network prefix from ip AND subnet mask : 192.168.94.0
(2) Address block

Notice:

It is an IP address and also indicates that the network


prefix is 20 bits.
128.14.35.7 /20
This address is an address in the 128.14.32.0/20 address
block.

It is an address block that contains multiple IP addresses,


128.14.32.0 /20 and it is also an IP address in this address block with a
host number of all 0s .

It is an IP address, but the network prefix length is not


128.14.35.7
specified, so its network address is unknown.

It is not possible to specify a network address because


128.14.32.0
there is no way to know what the network prefix is.
(3) Address mask
l Also known as subnet mask .
l Number of bits: 32 bits.
l Purpose: Allow the machine to quickly calculate the network address
from the IP address .
l of a series of 1s followed by a series of 0s , and the number of 1s is
the length of the network prefix.

/20 address block: 11111111 11111111 11110000 00000000


Dotted decimal notation: 255.255.240.0
CIDR notation: 255.255.240.0/20 .
Default address mask

A Network Number Host Number


kind
land
Default address mask
site 11111111 000000000000000000000000
255.0.0.0

B Network Number Host Number


kind
land
site Default address mask 11111111111111110000000000000000
255.255.0.0

C Network Number Host Number


kind
land
site Default address mask
11111111111111111111111100000000
255.255.255.0
Network Address = ( Binary IP Address ) AND ( Address Mask )

IP address Network Prefix Host Number

Perform bitwise AND operation

Address Mask 1111111111111111 0000000000000000

Network Address Network Prefix 0000000000000000


Network Address = ( Binary IP Address ) AND ( Address Mask )
[ Example ] The known IP address is 128.14.35.7/20 . Find the network address.

(a) Dotted decimal IP address 128 . 14 . 35. 7

(b) Binary IP address 10000000000011100010001100000111

(c) The address mask is 255.255.224.0 11111111111111111111000000000000

Bitwise AND of IP address and address mask 10000000000011100010000000000000

(e) Network address (dotted decimal) 128 . 14 . 32 . 0


Route aggregation
192.24.0
Before aggregation 192.24.1
192.24.2
192.24.3 192.24.0.0/20
16 Class C addresses ,
192.24.4
Address mask = 255.255.255.0 , 192.24.5
After
192.24.6 polymerization
16 routing entries are required in
192.24.7
the routing table . 192.24.8 Aggregated into 1 address,
192.24.9
192.24.10 Address mask = 255.255.240.0 ,
192.24.11 1 route entry is required in the
192.24.12
192.24.13 routing table .
192.24.14
192.24.15
CIDR address block division
ISP UniversityX​
206.0.64.0/18
internet 206.0.68.0/22
Route aggregation
Route aggregation
206.0.68.0/23 206.0.70.0/24 206.0.71.0/25 206.0.71.128/25

206.0.68.0/25 206.0.70.0/26 206.0.71.0/26 206.0.71.128/26


206.0.68.128/25 206.0.70.64/26 206.0.71.64/26 206.0.71.192/26
206.0.69.0/25 206.0.70.128/26
206.0.69.128/25 206.0.70.192/26 Three series Four series
A series Second Series

单位 地址块 二进制表示的地址块 相当于 C 类网络数


ISP 206.0.64.0/18 11001110.00000000.01* 64
大学 206.0.68.0/22 11001110.00000000.010001* 4
一系 206.0.68.0/23 11001110.00000000.0100010* 2
二系 206.0.70.0/24 11001110.00000000.01000110.* 1
三系 206.0.71.0/25 11001110.00000000.01000111.0* 1/2
四系 206.0.71.128/25 11001110.00000000.01000111.1* 1/2

It can be seen that the shorter the network prefix is,


the more addresses the address block contains.
4. Characteristics of IP addresses

(1) Each IP address consists of two parts: the


IP address is a hierarchical address structure.

network prefix and the host number.


l It facilitates the allocation and management of IP addresses.

Implementing route aggregation reduces the storage space occupied by


(2) An IP address identifies the interface l

the forwarding table and the time required to search the forwarding table.
between a host (or router) and a link.

(3) Several LANs connected by repeaters or


switches are still one network

(4) In IP addresses, all networks assigned to a


network prefix are equal.
4. Characteristics of IP addresses

(1) Each IP address consists of two parts: the


l When a host is connected to two networks at the
network prefix and the host number.
same time, it must have two corresponding IP

addresses at the same time, and their network


(2) An IP address identifies the interface
numbers must be different . This kind of host is
between a host (or router) and a link.
called a multihomed host .
(3) Several LANs connected by repeaters or l A router should be connected to at least two
switches are still one network networks, so a router should have at least two

different IP addresses .
(4) In IP addresses, all networks assigned to a
network prefix are equal.
4. Characteristics of IP addresses

(1) Each IP address consists of two parts: the


l From the Internet's perspective, a network (or
network prefix and the host number.
subnet) is a collection of hosts with the same

network prefix .
(2) An IP address identifies the interface
l Several LANs connected by repeaters or switches all
between a host (or router) and a link.
have the same network number and are still one
(3) Several LANs connected by repeaters or network.
switches are still one network l with different network numbers must be

interconnected using routers.


(4) In IP addresses, all networks assigned to a
network prefix are equal.
4. Characteristics of IP addresses

(1) Each IP address consists of two parts: the


network prefix and the host number.

(2) An IP address identifies the interface


between a host (or router) and a link.

(3) Several LANs connected by repeaters or


switches are still one network l The Internet treats every IP address equally, whether

it is a small local area network or a wide area


(4) In IP addresses, all networks assigned to a
network that may cover a large geographical area.
network prefix are equal.
Notice:
LAN 1
1.1.1.0/29 Network Address
1.1.1.2
1.1.1.3 IP address
LAN 3 1.1.1.1
1.1.1.16/29 LAN 2
On the same LAN 1.1.1.4
R1 1.1.1.8/29
Host or router 1.1.1.26 1.1.1.24
Network number in IP N 21.1.1.26/31 1.1.1.9
1.1.1.17 N 11.1.1.24/31
address
1.1.1.27
Must be the same. 1.1.1.25 1.1.1.10
R3 R2
1.1.1.18
1.1.1.19 1.1.1.28 1.1.1.29 1.1.1.13
N 31.1.1.28/31 1.1.1.11 1.1.1.12

router
Ethernet Switch
Notice:
LAN 1
1.1.1.0/29 Network Address
1.1.1.2
1.1.1.3 IP address
LAN 3 1.1.1.1
1.1.1.16/29
Each interface of the 1.1.1.4 LAN 2
R1 1.1.1.8/29
router has an IP
1.1.1.26 1.1.1.24
address with a 1.1.1.9
1.1.1.17 N 21.1.1.26/31 N 11.1.1.24/31
different network
number . 1.1.1.27
1.1.1.25 1.1.1.10
R3 R2
1.1.1.18
1.1.1.19 1.1.1.28 1.1.1.29 1.1.1.13
N 31.1.1.28/31 1.1.1.11 1.1.1.12

router
Ethernet Switch
4.2.3 IP address and MAC address

IP address MAC Address

• Virtual address, • the ROM on the


software address, network card .
logical address. • Hardware address,
• Used by the network physical address.
layer and above. • Used by the data link
• Placed in the header of layer.
the IP datagram. • Placed in the header of
the MAC frame.
IP address and MAC address

Head Application layer data

IP address TCP Message


Network layer and above
Using IP Address
Head
MAC Address
IP Datagram

Head Tail
Data Link Layer
MAC frame Using Hardware Address

IP address is placed in the header of the IP


datagram.
MAC address is placed in the header of
the MAC frame .
IP address
Host H 1 Finding the routing table Finding the routing table Host H2​

IP 1 MAC Address Router R1​ Router R2​ IP 2

MAC 1 MAC 3 MAC 4 MAC 5 MAC 6 MAC 2

local area network local area network local area network

Communication path:
H 1 → forwarded by R 1 → forwarded by R 2 → H 2
Host H 1 IP addresses and MAC addresses from the perspective of the protocol stack Host H2​

IP 1 Router R1​ Router R2​ IP 2

MAC 1 local areaMAC


network
3 MAC 4 local areaMAC
network
5 MAC 6 MAC 2
local area network

Host H 1 Host H2​


IP Datagram

Router R1​ Router R2​


IP 1 IP 2 IP 1 IP 2 IP 1 IP 2
IP 1 IP 2
IP 3 IP 4 IP 5 IP 6

Virtual Internet on IP Layer

MAC 1 MAC 3 MAC 4 MAC 5 MAC 6 MAC 2

MAC 1 MAC 3 MAC 4 MAC 5 MAC 6 MAC 2

MAC frame MAC frame MAC frame


Host H 1 IP datagrams can be seen on the Internet abstracted by the IP layer . Host H2​

IP 1 Router R1​ Router R2​ IP 2

MAC 1 local areaMAC


network
3 MAC 4 local areaMAC
network
5 MAC 6 MAC 2
local area network

Host H 1 The router only forwards Host H2​


IP Datagram based on the IP address of
the destination station .
Router R1​ Router R2​
IP 1 IP 2 IP 1 IP 2 IP 1 IP 2
IP 1 IP 2
IP 3 IP 4 IP 5 IP 6

Virtual Internet on IP Layer

MAC 1 MAC 3 MAC 4 MAC 5 MAC 6 MAC 2

MAC 1 MAC 3 MAC 4 MAC 5 MAC 6 MAC 2

MAC frame MAC frame MAC frame

IP address in the datagram change?


Host H 1 At the link layer of the LAN, only MAC frames can be seen. Host H2​

IP 1 Router R1​ Router R2​ IP 2

MAC 1 local areaMAC


network
3 MAC 4 local areaMAC
network
5 MAC 6 MAC 2
local area network

Host H 1 Host H2​


IP Datagram

Router R1​ Router R2​


IP 1 IP 2 IP 1 IP 2 IP 1 IP 2
IP 1 IP 2
IP 3 IP 4 IP 5 IP 6

Virtual Internet on IP Layer

MAC 1 MAC 3 MAC 4 MAC 5 MAC 6 MAC 2

MAC 1 MAC 3 MAC 4 MAC 5 MAC 6 MAC 2

MAC frame MAC frame MAC frame

Note: Does the MAC address in the frame change?


Source and destination addresses used at different levels and in different intervals

At the network layer At the data link layer


Write The address in the IP datagram header Write MAC frame header address

Source Address Destination Address Source Address Destination Address

from H 1 to R 1 IP 1 IP 2 MAC 1 MAC 3

from R 1 to R 2 IP 1 IP 2 MAC 4 MAC 5

from R 2 to H2​ IP 1 IP 2 MAC 6 MAC 2


4.2.4 Address Resolution Protocol ARP

l Two addresses are used to implement IP communication:


1. IP address (network layer address)
2. MAC address (data link layer address)

220.168.10.10 IP
address
00-15-C5-C6-CC-07

220.168.10.16 220.168.10.20 MAC address

LAN

00-15-C5-C6-C8-11 00-15-C5-C8-C4-95
The role of Address Resolution Protocol ARP

l Question: Now that I know the IP address of a machine (host or router), how do I find
out its corresponding MAC address?

ICMP IGMP ARP (Address Resolution


Protocol) function:
IP address Resolve the MAC address
ARP
IP from the IP address .
Network Layer

ARP request or reply packet ARP

send
Ethernet data FCS MAC Address
Header
ARP packets are encapsulated in Ethernet frames
Point 1 : ARP cache​

l ARP cache : Command: ARP -A

u Stores the mapping table from IP addresses to MAC addresses.

u The mapping table is dynamically updated (added or deleted due to timeout).


Mapping Table < IP address ; MAC address ; lifetime (Age) ; type, etc. >

IP address MAC Address Age​ type other

10.4.9.2 0030.7131.abfc 00:08:55 Dynamic

10.4.9.1 0000.0c07.ac24 00:02:55 Dynamic

10.4.9.99 0007.ebea.44d0 00:06:12 Dynamic

have exceeded their time to live are removed from the cache to accommodate network adapter changes.
Point 2 : ARP works

l When host A wants to send an IP datagram to host B on the local area network :
In its ARP cache
Find the IP address of host B

no Automatically run ARP to find out the


turn up? MAC address of host B.
Update ARP cache
yes

Retrieve MAC address

the MAC address into the destination


address of the MAC frame

Send the MAC frame


Host A Broadcasting on this LAN My IP address is 209.0.0.5 , and the hardware address is 00-00-C0-
15-AD-18
ARP request packet
I want to know the hardware address of the host 209.0.0.6 .

ARP Request ARP Request ARP Request ARP Request

209.0.0.5 209.0.0.6
X Y Z
A B

00-00-C0-15-AD-18
Update ARP cache

Host B sends a unicast message to A. I am 209.0.0.6 ,


ARP response packet The hardware address is 08-00-2B-00-EE-0A .

ARP
Response

209.0.0.6
209.0.0.5
X Y Z
A B

00-00-C0-15-AD-18 08-00-2B-00-EE-0A

Update ARP cache


two hosts are not on the same LAN?

l ARP is used to solve the mapping problem between IP address and MAC

address of hosts or routers on the same LAN .


Router R1​

209.0.0.5 209.0.0.1 219.1.0.1 219.1.0.6

A B

Communication path: A → forwarded through R1 → B.


Therefore host A must know router R1 The IP address of the router is parsed to
find out its MAC address. Then the IP datagram is sent to the router R1 .
two hosts are not on the same LAN?

My IP address is 209.0.0.5 , and the hardware address is 00-


00-C0-15-AD-18
I want to know the hardware address of router 209.0.0.1 .

ARP Request Router R1​

209.0.0.5 209.0.0.1 219.1.0.1 219.1.0.6

A B

Communication path: A → forwarded through R1 → B.


Therefore host A must know router R1 The IP address of the router is parsed to
find out its MAC address. Then the IP datagram is sent to the router R1 .
two hosts are not on the same LAN?

I am 209.0.0.1 ,
The hardware address is 0C-05-20-01-
2F-0D .

ARP Router R1​


Response

209.0.0.5 209.0.0.1 219.1.0.1 219.1.0.6

A B

Communication path: A → forwarded through R1 → B.


Therefore host A must know router R1 The IP address of the router is parsed to
find out its MAC address. Then the IP datagram is sent to the router R1 .
two hosts are not on the same LAN?

My IP address is 219.1.0.1 , and the hardware address is 00-00-C0-


15-AD-18
I would like to know the hardware address of router 219.1.0.6 .

Router R1​ ARP Request

209.0.0.5 209.0.0.1 219.1.0.1 219.1.0.6

A B

Communication path: A → forwarded through R1 → B.


Therefore host A must know router R1 The IP address of the router is parsed to find out its
MAC address. Then the IP datagram is sent to the router R1 .
two hosts are not on the same LAN?

I am 219.1.0.6 ,
The hardware address is 08-00-2B-00-
EE-0A .

Router R1​ ARP


Response

209.0.0.5 209.0.0.1 219.1.0.1 219.1.0.6

A B

Communication path: A → forwarded through R1 → B.


Therefore host A must know router R1 The IP address of the router is parsed to
find out its MAC address. Then the IP datagram is sent to the router R1 .
Four typical scenarios for using ARP

H3​ H 4
H 1 R1 R2

Net 1 Web 2 Net 3

H2​

1. The sender is a host that wants to send an IP datagram


to another host on the same network . At this time, ARP
is used to find the hardware address of the destination
host.
Four typical scenarios for using ARP

H3​ H 4
H 1 R1 R2

Net 1 Web 2 Net 3

H2​

2. The sender is a host that wants to send an IP datagram


to a host on another network. At this time, ARP is used
to find the hardware address of a router on the local
network . The rest of the work is done by this router.
Four typical scenarios for using ARP

H3​ H 4
H 1 R1 R2

Net 1 Web 2 Net 3

H2​

3. The sender is a router, which wants to forward the IP


datagram to a host on the local network. At this time,
ARP is used to find the hardware address of the
destination host.
Four typical scenarios for using ARP

H3​ H 4
H 1 R1 R2

Net 1 Web 2 Net 3

H2​

4. The sender is a router, and it wants to forward the IP


datagram to a host on another network. At this time, it
uses ARP to find the hardware address of another
router on the network . The rest of the work is done by
this router.
4.2.5 IP Datagram Format

P439 (Andrew S. Tanenbaum - Computer Networks)


4.3.1 Forwarding based on endpoint

l forwarded hop by hop in the Internet .

l transmission and forwarding based on the destination address in the packet

header .
Jump Jump Jump Jump Jump Jump

IP Datagram IP Datagram IP Datagram IP Datagram IP Datagram IP Datagram


Source Host router router router router router Destination Host
H1 R1 R2 R3 R4 R5 H2​

Lookup the forwarding table Lookup the forwarding table Lookup the forwarding table Lookup the forwarding table Lookup the forwarding table
In order to compress the size of the forwarding table,
The most important route in the forwarding table is ( destination network address , next hop address),
Instead of (destination address, next hop address).
The process of searching the forwarding table is to find a prefix match line by line.

15.0.0.4 20.0.0.7 20.0.0.9 30.0.0.2 30.0.0.1 40.0.0.4


R1 R2 R3
Net 1 Web 2 Net 3 Web 4
15.0.0.0 20.0.0.0 0
z 1 30.0.0.0 40.0.0.0

Router R2​ Forwarding table

The network where the destination host is located


Next hop address

20.0.0.0 Direct delivery, interface 0


30.0.0.0 Direct delivery, interface 1

15.0.0.0 20.0.0.7
40.0.0.0 30.0.0.1
N Source host H 1 R 1 Partial forwarding table
1 128.1.2.193
Subnet prefix
Prefix matching Next hop
128.1.2.192/26
128.1.3.64/26 R2 , Interface 0
128.1.2.128/25 Direct, interface 1
128.1.2.192/26 Direct, interface 0
0 R 1

128.1.2.194
N 2
128.1.2.130 1
N 3 Subnet prefix
128.1.2.128/25
Subnet prefix
128.1.3.64/26
Destination host H 2
1 0
128.1.2.131
128.1.2.132
128.1.3.66 R 2

128.1.3.65
H3​

Host H 1 How are packets sent with a destination address of 128.1.2.132 forwarded?
H 1 First check 128.1.2.132 Is it connected to this network?
If so, it is delivered directly; otherwise, it is sent to router R1 .

N 1 The network address is 128.1.2.192

N 1 The network mask is /26 = 255.255.255.192

Destination address and 128. 1 . 2.132

network mask 255.255.255.192


Bit-by-bit AND 128. 1 . 2.128  H 1 Network address

128.1.2.132 is not on the local network.

Source host H 1 The packet must be sent to router R1 .


Router R1​ After receiving the packet, search the forwarding table. Check row 1 first .

N Source host H 1 R 1 Partial forwarding table


1 128.1.2.193
Subnet prefix
Prefix matching Next hop
128.1.2.192/26
128.1.3.64/26 R2 , Interface 0
128.1.2.128/25 Direct, interface 1
128.1.2.192/26 Direct, interface 0
0 R 1

128.1.2.194
N 2
128.1.2.130 1
N 3 Subnet prefix
128.1.2.128/25
Subnet prefix
128.1.3.64/26
Destination host H 2
1 0
128.1.2.131
128.1.2.132
128.1.3.66 R 2

128.1.3.65
H3​

128.1.2.132 AND 255.255.255.192 = 128.1.2.128 does not match !


Router R1​ After receiving the packet, it searches the forwarding table. Then it checks line 2 .

N Source host H 1 R Partial forwarding table


1 128.1.2.193 1

Subnet prefix Prefix matching Next hop


128.1.2.192/26
128.1.3.64/26 R2 , Interface 0
128.1.2.128/25 Direct, interface 1
128.1.2.192/26 Direct, interface 0
0 R 1

128.1.2.194
N 2
128.1.2.130 1
N 3 Subnet prefix
128.1.2.128/25
Subnet prefix
128.1.3.64/26
Destination host H
1 0 2
128.1.2.131
128.1.2.132
128.1.3.66 R 2

128.1.3.65
H3​

128.1.2.132 AND 255.255.255.128 = 128.1.2.128 matches !

( via router R1 interface 1 ).


4.3.2 Longest Prefix Match
l using CIDR , it is possible to get more than one match
when looking up the forwarding table .
l Longest-prefix matching principle : select the one with the
longest prefix as the matching prefix.
l The longer the network prefix, the smaller its address
block, and thus the more specific the routing.
l The one with the longest prefix can be placed in the first
row of the forwarding table .
N 1 128.1.2.193 R 1 Partial forwarding table
Subnet prefix Prefix matching Next hop
128.1.2.192/26
128.1.3.64/26 R2 , Interface 0
128.1.2.128/25 Direct, interface 1
Destination
128.1.2.192/26 Direct, interface 0
Host 0 R 1
128.1.2.196
128.1.2.194
N 2
128.1.2.130 1
N 3 Subnet prefix
128.1.2.128/25
Subnet prefix
128.1.3.64/26
1 0
128.1.2.131
128.1.2.132
128.1.3.66 R 2

128.1.3.65
H3​

Router R1​ How to forward the destination address is 128.1.2.196 Grouping?


Router R1​ After receiving the packet, search the forwarding table. Check row 1 first .

N 1 128.1.2.193 R 1 Partial forwarding table

Subnet prefix
Prefix matching Next hop
128.1.2.192/26
128.1.3.64/26 R2 , Interface 0
128.1.2.128/25 Direct, interface 1
Destination 128.1.2.192/26 Direct, interface 0
Host 0 R 1
128.1.2.196
128.1.2.194
N 2
128.1.2.130 1
N 3 Subnet prefix
128.1.2.128/25
Subnet prefix
128.1.3.64/26

1 0
128.1.2.131
128.1.2.132
128.1.3.68 R 2

128.1.3.65
H3​

128.1.2.196 AND 255.255.255.192 = 128.1.2.192 does not match !


Router R1​ After receiving the packet, it searches the forwarding table. Then it checks line 2 .

N1 128.1.2.193 R 1 Partial forwarding table

Subnet prefix
Prefix matching Next hop
128.1.2.192/26

128.1.3.64/26 R2 , Interface 0
128.1.2.128/25 Direct, interface 1
Destination 128.1.2.192/26 Direct, interface 0
Host 0 R1
128.1.2.196
128.1.2.194

N2
128.1.2.130 1
N3 Subnet prefix
128.1.2.128/25
Subnet prefix
128.1.3.64/26

1 0
128.1.2.131
128.1.2.132
128.1.3.66 R2

128.1.3.65
H3​

128.1.2.196 AND 255.255.255.128 = 128.1.2.128 matches !


Router R1​ After receiving the packet, it searches the forwarding table. Then it checks line 3 .

N 1 128.1.2.193 R 1 Partial forwarding table

Subnet prefix
Prefix matching Next hop
128.1.2.192/26
128.1.3.64/26 R2 , Interface 0
128.1.2.128/25 Direct, interface 1
Destination 128.1.2.192/26 Direct, interface 0
Host 0 R 1
128.1.2.196
128.1.2.194
N 2
128.1.2.130 1
N 3 Subnet prefix
128.1.2.128/25
Subnet prefix
128.1.3.64/26

1 0
128.1.2.131
128.1.2.132
128.1.3.66 R 2

128.1.3.65
H3​

128.1.2.196 AND 255.255.255.192 = 128.1.2.192 matches !


4.3.2 Longest Prefix Match

l Question: R 1 From which interface do packets get forwarded?

A. Interface 0 ? The longest matching prefix

B. Interface 1 ?

Longest prefix match:


Select the one with the longest prefix as the matching
prefix
Assume a router has established the following routing table (these three columns
represent the destination network, subnet mask, and the next-hop router respectively;
if directly delivered, the last column indicates which interface to forward through):
128.96.39.0 255.255.255.128 Interface 0
128.96.39.128 255.255.255.128 Interface 1
128.96.40.0 255.255.255.128 R2
192.4.153.0 255.255.255.192 R3
(default) R4
Now, five packets have been received with their destination IP addresses as follows:
(1) 128.96.39.10
(2) 128.96.40.12
(3) 128.96.40.151
(4) 192.4.153.17
(5) 192.4.153.90
Calculate their respective next hops and explain the reasoning.
4.4.1 Types of ICMP Messages
4.4
Internet
4.4.2 ICMP application examples
Control
Message
protocol
ICMP
4.4 Internet Control Message Protocol ICMP

l ICMP (Internet Control Message Various application layer protocols


Application Layer
(HTTP, FTP, SMTP, etc. )
Protocol) allows hosts or routers
Transport layer TCP, UDP
to report errors and provide
ICMP IGMP
reports on abnormal situations. Network
Layer
(Internet
IP
l ICMP is a standard protocol of Layer)
ARP

the Internet. Network interface layer Interface with various networks

l But ICMP is not a high-level Physical Hardware

protocol, but a protocol at the IP

layer.
4.4.2 ICMP application examples
PING (Packet InterNet Groper)
l the connectivity between two hosts .
l ICMP echo request and echo reply messages are used .
l This is an example of the application layer using the
network layer ICMP directly , without going through the
transport layer TCP or UDP .
Application Examples of PING

Use PING to test the connectivity of the mail server


mail.sina.com.cn
4.4.2 ICMP application examples
Traceroute
l This is the name in UNIX operating systems. In Windows
operating systems, this command is tracert .
l Used to track the path of a packet from source to
destination .
l It uses the TTL field in the IP datagram , ICMP time
exceeded error report message and ICMP destination
unreachable error report message to track the path from
the source to the destination.
4.4.2 ICMP application examples

Using tracert The command obtains the routing information to


Sina.com's mail server mail.sina.com.cn
4.5.1 Basic IPv6 Header
4. 5
IPv6
4.5.2 IPv6 Address

4.5.3 Transition from IPv4 to IPv6

4.5.4 ICMPv6
4.5 IPv6
l IP is the core protocol of the Internet.
l IPv4 address exhaustion problem:
u As of February 2011 , the IANA IPv4 32 - bit addresses
have been exhausted .
u Internet address allocation agencies in various regions
have also announced the exhaustion of addresses.
u China also gradually stopped allocating IPv4 addresses
to new users and applications in 2014-2015 .
l Fundamental solution: adopt a new version of IP with a
larger address space , namely IPv6 .
4.5.1 Basic IPv6 Header
l IPv6 still supports connectionless transmission .

l The protocol data unit PDU is called a packet .

l Major changes ( 1/2 ):

1. Larger address space. The address was increased from 32 bits in IPv4 to

128 bits.

2. Extended address hierarchy. Can be divided into more levels.

3. Flexible header format. Many optional extension headers are defined.

4. Improved options. Allows datagrams to contain control information

with options placed in the payload .


4.5.1 Basic IPv6 Header
l Major changes ( 2/2 ):
5. Allows the protocol to continue to expand and better adapt to
new applications.
6. Supports plug and play (i.e. automatic configuration). No need
to use DHCP .
7. Supports resource pre-allocation and real-time video and other
applications that require a certain bandwidth and latency.
8. The IPv6 header is changed to 8- byte alignment. The header
length must be an integer multiple of 8 bytes.
Bit 0 4 12 16 twenty four 31
Version Traffic Class Flow Label
Payload length Next Head Hop Limit

Source Address
IPv6​ ( 128 bits)
Basic header
( 40 B )

Destination Address
( 128 bits)

IPv6​ Payload (extension header / data)


Payload
(up to 64 KB )

40 -byte IPv6 basic header

P458 (Andrew S. Tanenbaum - Computer Networks)


Colon hexadecimal notation

l In IPv6 , each address occupies 128 bits, and the address space is larger than 3.4  10 38 .

l Use colon hexadecimal notation ( colon hex) : 16 -bit values are represented by hexadecimal values, and each value is separated by

a colon.

Dotted decimal notation : 104.230.140.100.255.255.255.255.0.0.17.128.150.10.255.255

Colon hexadecimal notation : 68E6:8C64:FFFF:FFFF:0000:1180:960A:FFFF

Colon hexadecimal notation : 68E6:8C64:FFFF:FFFF:0:1180:960A:FFFF

Two techniques: zero compression, and suffixes in dotted decimal notation.


Zero compression

l Zero compression : A string of consecutive zeros can be replaced by a pair of colons .

FF05:0:0:0:0:0:0:B3
Can be compressed to:
FF05::B3
0:0:0:0:0:0:128.10.2.1 ::128.10.2.1

1080:0:0:0:8:800:200C:417A 1080::8:800:200C:417A

FF01:0:0:0:0:0:0:101 (multicast address) FF01::101

0:0:0:0:0:0:0:0:1 (loopback address) ::1

0:0:0:0:0:0:0:0:0 (unspecified address) ::

Note: Zero compression can be used only once in any one address.

You might also like