Professional Documents
Culture Documents
Chapter 4. Network Layer
Chapter 4. Network Layer
1
From last class
Data link layer:
node-to-node delivery
Network layer:
host-to-host delivery
Transport layer:
process-to-process delivery
Function:
Route packets end-to-end on a network,
Application through multiple hops
Presentation Key challenge:
How to represent addresses
Session How to route packets
Transport Scalability
Network Convergence
Data Link
Physical
3
Routers, Revisited
4
5
Network layer TCP UDP Transport
Layer
Devices
Routers, Layer 3 Switches, Media
7
Network layer
Unreliable (best effort)
If packet gets lost, network layer doesn’t care for higher layers can resend lost
packets
Forwards packets hop by hop
Encapsulates network layer packet inside data link layer frame
Different framing on different underlying network types
Receive from one link, forward to another link
There can be many hops from source to destination
Makes routing decisions
How can the packet be sent closer to its destination?
Forwarding and routing tables embody “knowledge” of network topology
Routers can talk to each other to exchange information about network topology
8
Addressing the Network IPv4
9
IP Address
What is an IP address?
An IP address is a unique global address for a network interface
E.g. IPv4, IPv6
10
IP Addresses
11
IP Addressing
32 bits
Dotted
Decimal Network Host
Binary 11111111111111111111111111111111
128
8
4
2
1
64
32
16
128
8
4
2
1
64
32
16
128
8
4
2
1
128
8
4
2
1
64
32
64
32
16
16
IP Addressing
32 bits
Dotted
Decimal Network Host
Binary 11111111111111111111111111111111
128
8
4
2
1
64
32
16
128
8
4
2
1
64
32
16
128
8
4
2
1
64
32
128
8
4
2
1
64
32
16
16
Example
Decimal 172 16 122 204
Example10101100000100000111101011001100
Binary
IP Address Classes
Bits: 1 8 9 16 17 24 25 32
0NNNNNNN Host Host Host
Class A:
Range (1-126)
Bits: 1 8 9 16 17 24 25 32
10NNNNNN Network Host Host
Class B:
Range (128-191)
1 8 9 16 17 2425 32
Bits:
110NNNNN Network Network Host
Class C:
Range (192-223)
1 8 9 16 17 2425 32
Bits:
1110MMMMMulticast GroupMulticast GroupMulticast Group
Class D:
Range (224-239)
Host Addresses
172.16.2.1 10.1.1.1
10.6.24.2
E1
172.16.3.10 E0 10.250.8.11
172.16.2.1
172.16.12.12 10.180.30.118
Routing Table
172.16 . 12 . 12 Network Interfac
e
Network Host 172.16.0. E0
0
E1
10.0.0.0
Determining Available Host Addresses
Network Host
172 16 0 0
N
8
7
6
5
4
3
2
1
9
16
15
14
13
10
12
11
101011000001000000000000
00000000 1
0000000000000001 2
0000000000000011 3
...
...
...
111111111111110165534
111111111111111065535
111111111111111165536
- 2
2N-2 = 216-2 = 6553465534
Addressing without Subnets
172.16.0.1172.16.0.2172.16.0.3 172.16.255.253
172.16.255.254
…...
172.16.0.0
Network 172.16.0.0
Addressing with Subnets
172.16.3.0
172.16.4.0
172.16.1.0 172.16.2.0
Network 172.16.0.0
Subnet Addressing
172.16.2.200 172.16.3.5
172.16.3.1
E1
172.16.2.2 E0 172.16.3.100
172.16.2.1
172.16.2.160 172.16.3.150
New Routing
172.16 . 2 . 160 Table Interfac
Network
e
Network Host 172.16.0. E0
0
E1
172.16.0.
Subnet Addressing
172.16.2.200 172.16.3.5
172.16.3.1
E1
172.16.2.2 E0 172.16.3.100
172.16.2.1
172.16.2.160 172.16.3.150
New Routing
172.16 . 2 . 160 Table Interfac
Network
e
Network Subnet Host 172.16.2. E0
0
E1
172.16.3.
Subnet Mask
Network Host
IP
Address
172 16 0 0
Network Host
Default
Subnet
Mask
255 255 0 0
11111111 11111111 00000000 00000000
Also written as “/16” where 16 represents the number of 1s in the
mask.
Network Subnet Host
8-bit
Subnet 255 255 255 0
Mask
Also written as “/24” where 24 represents the number of 1s in the
mask.
Decimal Equivalents of Bit Patterns
128 64 32 16 8 4 2 1
1 0 0 0 0 0 0 0 = 128
1 1 0 0 0 0 0 0 = 192
1 1 1 0 0 0 0 0 = 224
1 1 1 1 0 0 0 0 = 240
1 1 1 1 1 0 0 0 = 248
1 1 1 1 1 1 0 0 = 252
1 1 1 1 1 1 1 0 = 254
1 1 1 1 1 1 1 1 = 255
Subnet Mask without Subnets
Network Host
Network 172 16 0 0
Number
26
Unicast, Multicast, Broadcast
Unicast – a message addressed to one host
Broadcast – a message addressed to all hosts on a
network. Uses network’s broadcast address or
255.255.255.255 locally
Multicast – a message addressed to a group of hosts. Uses
an address starting 224 - 239
27
Private IP addresses
Unrestricted use on private networks. Not routed across
the Internet.
10.0.0.0 – 10.255.255.255 (10.0.0.0/8)
172.16.0.0 – 172.31.255.255 (172.16.0.0/20)
192.168.0.0 – 192.168.255.255 (192.168.0.0/24)
28
Public IP addresses
Routed over the Internet
Master holder is IANA
Assigned to regional registries and then to ISPs
ISPs allocate them to organisations and individual users
Use is strictly controlled as duplicate addresses are not
allowed.
29
Special addresses
0.0.0.0 “all addresses” in default route. Hosts cannot be given
addresses starting 0.
127.0.0.1 is loopback. Hosts cannot be given addresses starting
127.
240.0.0.0 and higher – reserved for experimental purposes.
169.254.0.0 - 169.254.255.255 local only
192.0.2.0 to 192.0.2.255 for teaching
30
Network address translation
A large number of hosts on a network use private addresses to
communicate with each other.
The ISP allocates one or a few public addresses.
NAT allows the hosts to share the public addresses when they
want to use the Internet
31
Addressing hosts
Static addressing
Address is configured by an administrator.
Servers, printers, routers, switches need static addresses.
Dynamic addressing
Address is allocated automatically by DHCP by leasing
addresses from a pool.
Dynamic addressing is best for workstations.
32
Subnetting
33
Problems
IPv4 address scheme is limited by its 32 bits problems for the
smaller networks?
34
Solutions
Subnet masking
Variable-length subnet masks
Route summarization
Classless interdomain routing
Network address translation
Address allocation for private internet
35
solution 1: get netids for all groups; impossible
Solution 2: allow a network to be split into several parts for internal
use but still act like a single network to the outside world (three levels
of hierarchy: site, subnet, host)
36
Subnetting
Split the host number portion of an IP address into a
subnet number and a (smaller) host number.
Result is a 3-layer hierarchy
37
Subnetting
router
38
Subdividing IP Classes
The act of taking bits fromthe host portion of the address and
reserving them to define the subnet address instead.
Steps to create subnet:
41
Subnet Masking
43
How to Create a Subnet
44
Steps Followed
Determine the number of required network IDs:
One for each subnet
One for each wide area network connection
Determine the number of required host IDs per subnet:
One for each TCP/IP host
One for each router interface
Based on the above requirements, create the following:
One subnet mask for your entire network
A unique subnet ID for each physical segment
A range of host IDs for each subnet
45
Subnet Masks
subnet mask is 32-bit value that allows the recipient of IP
packets to distinguish the network ID portion of the IP
address from the host ID portion of the IP address.
When assigning addresses you set both the IP address and
subnet mask.
Not all networks need subnets, meaning they use the default
subnet mask.
Default subnet mask is found by setting all network address
to
46
1 for each class.
Restrictions on borrowed bits
Reserved addresses
47
Example
Subnetting 192.168.1.0/24
48
Subnetting 192.168.1.0/24
49
Subnetting 192.168.1.0/24
50
Subnetting 192.168.1.0/24
Bits borrowed 1 2 3 4 5 6
No of networks 2 4 8 16 32 64
52
Subnetting 192.168.1.0/24
Every time you borrow another bit you:
Double the number of subnets
Halve the size of the subnets
Each subnet has a network address, a broadcast address,
and everything in between is a host address.
53
An organization is granted a block of addresses with the
beginning address 14.24.74.0/24. The organization needs to
have 3 subblocks of addresses to use in its three subnets as
shown below:
❑ One subblock of 120 addresses.
❑ One subblock of 60 addresses.
❑ One subblock of 10 addresses.
Solution
There are 232 − 24 = 256 addresses in this block. The first
address is 14.24.74.0/24; the last address is 14.24.74.255/24.
a.The number of addresses in the first subblock is not a power
of 2.
We allocate 128 addresses. The subnet mask is 25. The first
address is 14.24.74.0/25; the last address is 14.24.74.127/25.
54
b. The number of addresses in the second subblock is not a
power of 2 either. We allocate 64 addresses. The subnet mask
is 26. The first address in this block is 14.24.74.128/26; the
last address is
14.24.74.191/26.
c. The number of addresses in the third subblock is not a power
of 2 either. We allocate 16 addresses. The subnet mask is 28.
The first address in this block is 14.24.74.192/28; the last
address is 14.24.74.207/28.
d. If we add all addresses in the previous subblocks, the result
is 208 addresses, which means 48 addresses are left in reserve.
The first address in this range is 14.24.74.209. The last
address is 14.24.74.255.
e. Figure shows the configuration of blocks. We have shown
the55first address in each block.
56
57
Exercise
An ISP is granted a block of addresses starting with
190.100.0.0/16 (65,536 addresses). The ISP needs to distribute
these addresses to three groups of customers as follows:
❑ The first group has 64 customers; each needs approximately
256 addresses.
❑ The second group has 128 customers; each needs
approximately 128 addresses.
❑ The third group has 128 customers; each needs
approximately 64 addresses.
We design the subblocks and find out how many addresses are
still available after these allocations.
58
Activity
59
Assume a company has three offices: Central, East, and
West. The Central office is connected to the East and West
offices via private, WAN lines. The company is granted a
block of 64 addresses with the beginning address
70.12.100.128/26. The management has decided to allocate
32 addresses for the Central office and divides the rest of
addresses between the two other offices.
60
61
62
Exercises
Do full subnetting for the following addresses.
1. 192.168.10.0/28
2. 192.0.10.0/30
3. 192.1.1.0/25
63
Communication Between Subnets
A router is necessary for devices on different networks and
subnets to communicate.
Each router interface must have an IPv4 host address that belongs
to the network or subnet that the router interface is connected to.
Devices on a network and subnet use the router interface