Chapter4 Network Layer
Chapter4 Network Layer
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
Physical Layer (This layer does not have specific content) Physical Layer
4.5 IPv6
4.7 IP Multicast
4.8 Virtual Private Network (VPN) and Network Address Translation (NAT)
l What kind of service should the network layer provide to the transport layer?
Connection-oriented or connectionless?
2 views:
commitments.
One view: Let the network be responsible for reliable delivery
l Computer networks mimic telecommunications networks and use
connection-oriented communication.
l reliable transmission network protocol is used , the sent packets can arrive
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
l The network layer should be designed to be as simple as possible, providing only simple, flexible , connectionless,
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
Protocol)
(Internet Layer)
IP
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
…
layer Middleware
Transport layer and
Gateway (gateway)
above
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
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
Equivalent
32 -bit binary number Dotted decimal number
2 structure
IP address ::= { < network number >, < host number >}
32 -bit
The number of digits in the network number n Network Number Host Number
(net-id) (host-id)
How much is it?
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
network Maximum assignable The first assignable The last assignable In each network
category Number of networks network number network number Maximum number of hosts
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
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
l Key points:
2 structure
IP address ::= { < network prefix >, < 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?
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
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
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:
the forwarding table and the time required to search the forwarding table.
between a host (or router) and a link.
different IP addresses .
(4) In IP addresses, all networks assigned to a
network prefix are equal.
4. Characteristics of IP addresses
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
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
Head Tail
Data Link Layer
MAC frame Using Hardware Address
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
220.168.10.10 IP
address
00-15-C5-C6-CC-07
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?
send
Ethernet data FCS MAC Address
Header
ARP packets are encapsulated in Ethernet frames
Point 1 : ARP cache
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
209.0.0.5 209.0.0.6
X Y Z
A B
00-00-C0-15-AD-18
Update ARP cache
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
l ARP is used to solve the mapping problem between IP address and MAC
A B
A B
I am 209.0.0.1 ,
The hardware address is 0C-05-20-01-
2F-0D .
A B
A B
I am 219.1.0.6 ,
The hardware address is 08-00-2B-00-
EE-0A .
A B
H3 H 4
H 1 R1 R2
H2
H3 H 4
H 1 R1 R2
H2
H3 H 4
H 1 R1 R2
H2
H3 H 4
H 1 R1 R2
H2
header .
Jump Jump Jump Jump Jump Jump
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.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 .
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.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.3.65
H3
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
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
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
B. Interface 1 ?
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
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 .
1. Larger address space. The address was increased from 32 bits in IPv4 to
128 bits.
Source Address
IPv6 ( 128 bits)
Basic header
( 40 B )
Destination Address
( 128 bits)
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.
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
Note: Zero compression can be used only once in any one address.