Network Layer

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 78

Network layer

Addressing the Network IP


Routing

1
2
Network layer
TCP UDP Transport

 This layer deals with Layer

Packets (Data Bundles)


Network
IP
Responsible for logical
ICMP IGMP
 Layer

addressing and routing


 Devices ARP
Network
Access Data Link Layer

 Routers, Layer 3 Switches,


Firewalls.. Etc. Media
 IP – Internet Protocol (Provide packet
 Network Layer Protocols delivery)
 ICMP, IGMP, ARP, IP, RIP,  ARP – Address Resolution Protocol
IGRP.. Etc. (Defined the procedure of network address /
mac address translation)
 ICMP – Internet Control Message Protocol
(Defined the procedure of error message
transfer)
3
Network layer
 Routes the information in the network
 E.g. IP is a network layer implementation which defines
addresses in such a way that route selection can be
determined.
 Single address space for the entire internetwork
 adds an additional layer of addressing, e.g. IP address, which is
different from MAC address.

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
32 bits
version header Type of Service/TOS Total Length (in bytes)
(4 bits) length (8 bits) (16 bits)
flags
Identification (16 bits) Fragment Offset (13 bits)
(3 bits)
TTL Time-to-Live Protocol
Header Checksum (16 bits)
(8 bits) (8 bits)

Source IP address (32 bits)

Destination IP address (32 bits)

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
Number of blocks and block size in classful IPv4 addressing

In classful addressing, a large part of the available addresses were wasted.

13
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

A 10. 17. 53. 60


network part host part

B 172. 16. 38. 201


network part host part

C 192. 168. 21. 17


network part host part

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

192. 168. 21. 17


11000000 10101000 00010101 00010001

octet octet octet octet

network part host part


Prefix /24 Subnet mask:
255. 255. 255. 0
11111111 11111111 11111111 00000000

17
Find the network address

192. 168. 21. 17


11000000 10101000 00010101 00010001

In a network address, all the host bits are 0.


192. 168. 21. 0
11000000 10101000 00010101 00000000

The router needs to do this for every packet.

18
Logical AND

192. 168. 21. 17


11000000 10101000 00010101 00010001

255. 255. 255. 0


11111111 11111111 11111111 00000000

192. 168. 21. 0


11000000 10101000 00010101 00000000

Do a logical AND at each position


19
Find the broadcast address

192. 168. 21. 17


11000000 10101000 00010101 00010001

In a broadcast address, all the host bits are 1.


192. 168. 21. 255
11000000 10101000 00010101 11111111

The broadcast is the last address in the network.

20
Classless addressing
 Any suitable prefix can be used
 We (and devices) need to know what the prefix is.
 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

 Hosts 172.16.0.1 to 172.16.0.254


 254 host addresses

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/28 mask 255.255.255.240


 Broadcast address 172.16.0.15

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

Last octet Last octet Full


binary decimal
Host
Subnet mask
Network
Broadcast
First host
Last host
29
192.168.1.70/24

Last octet Last octet Full


binary decimal
Host 01000110 70 192.168.1.70
Subnet mask 00000000 0 255.255.255.0
Network 00000000 0 192.168.1.0
Broadcast 11111111 255 192.168.1.255
First host 00000001 1 192.168.1.1
Last host 11111110 254 192.168.1.254
30
Calculating addresses
 A host has IP address 192.168.1.70/26
 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?

31
192.168.1.70/26 fill in the table

Last octet Last octet Full


binary decimal
Host
Subnet mask
Network
Broadcast
First host
Last host
32
192.168.1.70/26

Last octet Last octet Full


binary decimal
Host 01000110 70 192.168.1.70
Subnet mask 11000000 192 255.255.255.192
Network 01000000 64 192.168.1.64
Broadcast 01 111111 127 192.168.1.127
First host 01000001 65 192.168.1.65
Last host 01 111110 126 192.168.1.126
33
Calculating addresses
 A host has IP address 192.168.1.70/28
 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?

34
192.168.1.70/28 fill in the table

Last octet Last octet Full


binary decimal
Host
Subnet mask
Network
Broadcast
First host
Last host
35
192.168.1.70/28

Last octet Last octet Full


binary decimal
Host 01000110 70 192.168.1.70
Subnet mask 11110000 240 255.255.255.240
Network 01000000 64 192.168.1.64
Broadcast 01001111 79 192.168.1.79
First host 01000001 65 192.168.1.65
Last host 01001110 78 192.168.1.78
36
Unicast, Multicast, Broadcast

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 for the

long-term growth of the Internet

 The global internet routing table is huge and continues to grow

go beyond the capacity of routers

 What if you want to break your big network into many

smaller networks?

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)

a campus network consisting of LANs for various


departments
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

network prefix subnet number host number

 Then: extended network prefix


 Subnets can be freely assigned within the organization
 Internally, subnets are treated as separate networks
 Subnet structure is not visible outside the organization

48
Subnetting
router

Subnet 1 Subnet 2 Subnet 3


128.213.1.x 128.213.2.x 128.213.3.x

49
Subneting
 Networks divided into subnets thus:
 saving IP address spaces

 reduce broadcasting

 use the network address more efficient

 Done by reserving bits from host address

 Any number of bits can be borrowed as long as two bits


remain.

50
Subnet Masking

Some of the benefits of subnetting include:


• Reduced network traffic
• Optimized network performance
• Simplified management
51
Subnetting
 Subnets can simplify routing.

 IP subnet broadcasts have a hostID of all 1s.

 It is possible to have a single wire network with multiple


subnets.

52
How to Create a Subnet

 To create subnetworks, you take bits from the host

portion of the IP address and reserve them to define


the subnet address.

 This means fewer bits for hosts, so the more


subnets, the fewer bits available for defining hosts.

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

 all 0’s= network address, all 1’s broadcast address

 Minimum of 2 bits borrowed from host portion

 Minimum of 2 bits left for host portion

56
The Fast Way
 Before starting, you need to do is answer five simple
questions:

1. How many subnets does the chosen subnet

mask produce?

2. How many valid hosts per subnet are available?

3. What are the valid subnets?

4. What’s the broadcast address of each subnet?

5. What are the valid hosts in each subnet?

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 23 = 8.
2. How many hosts?
 25 – 2 = 30.
3. What are the valid subnets?
 256 – 224 = 32. We just start at zero and count to the subnet mask
value in blocks (increments) of 32: 0, 32, 64, 96, 128, 160, 192, 224.
4. What’s the broadcast address for each subnet?
 always the number right before the next subnet

5. What are the valid hosts?

 the numbers between the subnet number and the broadcast address
62
To answer questions 4 and 5, first just write out the subnets,
then write out the broadcast addresses— the number right
before the next subnet. Lastly, fill in the host addresses.
 So now we have
 192.168.10.1/27 – 192.168.10.30/27 ntk 1
 192.168.10.33/27 - 192.168.10.62/27 ntk 2
upto …
 192.168.10.225/27 - 192.168.10.254/27 ntk 8

63
Example 2
Subnetting 192.168.1.0/24

Last octet binary


Address 192.168.1.0 00000000

Subnet mask 255.255.255.0 00000000

Borrow 1 bit from host part, give it to network part, /25

Addresses 192.168.1.0 00000000


192.168.1.128 10000000
Subnet mask 255.255.255.128 10000000

64
Subnetting 192.168.1.0/24

Borrow 2 bits from host part, give to network part, /26


Addresses 192.168.1.0 00000000
192.168.1.64 01000000
192.168.1.128 10000000
192.168.1.192 11000000
Subnet mask 255.255.255.192 11000000

65
Subnetting 192.168.1.0/24

Borrow 3 bits from host part, give to network part, /27


Addresses 192.168.1.0 00000000
192.168.1.32 00100000
192.168.1.64 01000000
192.168.1.96 01100000
192.168.1.128 10000000
192.168.1.160 10100000
192.168.1.192 11000000
192.168.1.224 11100000
Subnet mask 255.255.255.224 11100000

66
Subnetting 192.168.1.0/24

Borrow 4 bits from host part, give to network part, /28


192.168.1.0 192.168.1.128 00000000 10000000
192.168.1.16 192.168.1.144 00010000 10010000
192.168.1.32 192.168.1.160 00100000 10100000
192.168.1.48 192.168.1.176 00110000 10110000
192.168.1.64 192.168.1.192 01000000 11000000
192.168.1.80 192.168.1.208 01010000 11010000
192.168.1.96 192.168.1.224 01100000 11100000
192.168.1.112 192.168.1.240 01110000 11110000

Subnet mask 255.255.255.240 11110000


And so on…
67
Subnetting 192.168.1.0/24

Bits borrowed 1 2 3 4 5 6

No of networks 2 4 8 16 32 64

Prefix /25 /26 /27 /28 /29 /30

Bit value/ 128 64 32 16 8 4


network size
No of hosts 126 62 30 14 6 2

Subnet mask 128 192 224 240 248 252

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

You might also like