Chapter 4.1
Chapter 4.1
4
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
5
Addressing the Network IPv4
6
IP Address
What is an IP address?
An IP address is a unique global address for a
network interface
E.g. IPv4, IPv6
IPV6 provides a platform on new internet
functionality that will be needed in the immediate
future and provide flexibility for future growth
and expansion
An IPv4 address is 32 bits long
The IPv4 addresses are unique and universal.
7
IP Addresses
8
IP Address
The address space of IPv4 is 232 or
4,294,967,296.
9
Classful addressing
In classful addressing, the address space is
divided into five classes; A, B, C, D, and E .
Easy to work out but very wasteful.
Routers and hosts still assume class subnet
masks by default
Class A /8 255.0.0.0
Class B /16 255.255.0.0
Class C /24 255.255.255.0
10
Finding the classes in binary and dotted-decimal notation
11
Find the class of each address.
a. 00000001 00001011 00001011 11101111
b. 11000001 10000011 00011011 11111111
c. 14.23.120.8
d. 252.5.15.111
Solution
a. The first bit is 0. This is a class A address.
b. The first 2 bits are 1; the third bit is 0. This is a class C
address.
c. The first byte is 14; the class is A.
d. The first byte is 252; the class is E.
12
3 types of address
Every network has:
Network address – the first one
Broadcast address – the last one
Host addresses – everything in between
14
IP addressing
15
IP addressing
Classful addressing, which is almost obsolete,
is replaced with classless addressing.
In IPv4 addressing, a block of
addresses can be defined as:
x.y.z.t /n
in which x.y.z.t defines one of the addresses
and the /n defines the mask.
16
IPv4 address
17
Find the network address
18
Logical AND
20
Classless addressing
Any suitable prefix can be used
More flexible, less wasteful.
21
22
Classless addressing /16
172.16.0.0/16 mask 255.255.0.0
Broadcast address 172.16.255.255
172. 16. 0. 0
10101100 00010000 00000000 00000000
Hosts 172.16.0.1 to 172.16.255.254
65534 host addresses
23
Classless addressing /24
172.16.0.0/24
mask 255.255.255.0
Broadcast address 172.16.0.255
172. 16. 0. 0
10101100 00010000 00000000 00000000
24
Classless addressing /22
172.16.0.0/22
mask 255.255.252.0
172. 16. 0. 0
10101100 00010000 00000000 00000000
Broadcast address 172.16.3.255
Hosts 172.16.0.1 to 172.16.3.254
1022 host addresses
25
Classless addressing /26
172.16.0.0/26
mask 255.255.255.192
172. 16. 0. 0
10101100 00010000 00000000 00000000
Broadcast address 172.16.0.63
Hosts 172.16.0.1 to 172.16.0.62
62 host addresses
26
Classless addressing /28
172. 16. 0. 0
10101100 00010000 00000000 00000000
Hosts 172.16.0.1 to 172.16.0.14
14 host addresses
27
Calculating addresses
A host has IP address 192.168.1.70/24
What is the subnet mask?
What is the network address?
What is the broadcast address?
What is the range of host addresses in the
network?
28
192.168.1.70/24 – fill in the table
31
192.168.1.70/26 fill in the table
34
192.168.1.70/28 fill in the table
37
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
38
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)
39
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
40
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
41
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
42
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
43
Subnetting
44
Problems
IPv4 address scheme is limited by its 32 bits problems
to grow
45
Solutions
Subnet masking
Variable-length subnet masks
Route summarization
Classless interdomain routing
Network address translation
Address allocation for private internet
46
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)
47
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
network prefix host number
48
Subnetting
router
49
Subneting
Networks divided into subnets thus:
saving IP address spaces
reduce broadcasting
use the network address more efficient
50
Subnet Masking
52
How to Create a Subnet
53
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
54
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 1 for each class.
55
Restrictions on borrowed bits
Reserved addresses
56
The Fast Way
Before starting, you need to do is answer five simple
questions:
mask produce?
57
1. How many subnets?
2x = number of subnets. x is the number of masked bits,
or the 1s.
For example, given a class C subnet mask of
255.255.255.192, the number of ones gives us 22 = 4
subnets.
Note that we only count the number of ones that are found
in the host part of the subnet mask.
For class C address 255.255.255.0 is the default subnet,
192=11000000 in binary, so there are only 2 ones.
58
2. How many hosts per subnet?
2y – 2 = number of hosts per subnet. y is the number
of unmasked bits, or the 0s. For example, in 11000000,
the number of zeros gives us 26 – 2 = 62 hosts per subnet.
You need to subtract two for the subnet address and
the broadcast address, which are not valid hosts.
3. What are the valid subnets?
First calculate the block size.
256 – subnet mask = block size, or increment number.
An example would be 256 – 192 = 64. The block size of
a 192 mask is always 64.
Second, start counting at zero in blocks of 64 until you
reach the subnet mask value and these are your
subnets. 0, 64, 128, 192.
59
4. What’s the broadcast address for each subnet?
Since we counted our subnets in the last section as 0,
64, 128, and 192, the broadcast address is always the
number right before the next subnet.
For example, the 0 subnet has a broadcast address of 63
because the next subnet is 64. The 64 subnet has a
broadcast address of 127 because the next subnet is
128, etc.
And remember, the broadcast of the last subnet is
always 255 for Class C.
60
5. What are the valid hosts?
Valid hosts are the numbers between the
subnets, omitting all the 0s and all 1s.
For example, if 64 is the subnet number and 127
is the broadcast address, then 65–126 is the valid
host range—it’s always the numbers between the
subnet address and the broadcast address.
These are the addresses you assign to nodes.
61
Example 1
We’re going to subnet the network address 192.168.10.0 and
subnet mask 255.255.255.224.
1. How many subnets?
224 is 11100000, so our equation would be 2 3 = 8.
63
Example 2
Subnetting 192.168.1.0/24
64
Subnetting 192.168.1.0/24
65
Subnetting 192.168.1.0/24
66
Subnetting 192.168.1.0/24
Bits borrowed 1 2 3 4 5 6
No of networks 2 4 8 16 32 64
68
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.
69
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
70
An organization is granted the block
130.34.12.64/26. The organization needs
four subnetworks, each with an equal
number of hosts. Design the subnetworks
and find the information about each
network.
71
72
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.
73
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 the first address in each block.
74
75
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.
76
77
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.
78