220 likes | 227 Views
Learn about classful IP addressing, subnet masks, and how routers route packets based on IP addresses. Understand the need for subnetting and how to obtain sub-network addresses.
E N D
Networks and Protocols CE00997-3 Week 4a
IP ADDRESSING • These slides are for background reading only • They will not be used in the lecture, you will need to take notes from the white board
Subnet masks • Subnet masks are used to indicate which bits define the network and which bits define the host. • Class A • 11111111 00000000 00000000 00000000 • 255.0.0.0 • Class B • 11111111 11111111 00000000 00000000 • 255.255.0.0 • Class C • 11111111 11111111 11111111 00000000 • 255.255.255.0
IP Address Routing • Routers look at the IP address and logically “AND” it with the subnet mask to obtain the network address or ID (not the individual host). • Routers route packets based on their network address. • Routers do not know about individual hosts on remote networks.
IP Address Routing • Example an IP address of 146.87.114.32 means: • 10010010 01010111 01110010 00100000 • first two bits are 10 therefore Class B (16 bit NET ID) • obtain net id by bitwise AND with class B mask 10010010 01010111 01110010 00100000 11111111 11111111 00000000 00000000 AND 10010010 01010111 00000000 00000000 Thus the NET ID is = 146.87.0.0 • Note this means a host field of all 0’s cannot be used for a specific host as it refers to the network itself (or the wire)
Routing from Net 1 to Net 2 Net 1 Net 2 S0 S1 E0 S0 S1 S0 130.29.45.7 Router B 130.5.7.12 Router A Router C • Data from Host 130.29.45.7 is sent to 130.5.7.12 • Routers route the packets to network 130.5.0.0 • Router C is directly connect to this network and delivers the packets to the host.
Routing from Net 1 to Net 2 130.5.7.12 AND 255.255.0.0 = 130.5.0.0 130 . 5 . 0 . 0
The need for sub-netting • The destination network may be a corporate WAN • It may be international with several thousand computers • Each router would need to know the route to all devices. • It needs breaking down into smaller networks.
A Sub-Netted Network 130.29.3.0 130.29.2.0 130.29.4.0 130.29.5.0 130.29.1.0 130.29.0.0 130.29.6.0 130.29.7.0 IP packet DA=130.29.5.7
A Sub-Netted Network • In the Internet we route to 130.29.0.0 • Within the 130.29.0.0 network we route to 130.29.X.0 (X subnet) • How? • Use a subnet mask which extends the range of bits representing the network.
Obtaining the Sub-Network Address • Example an IP address of 130.29.5.7 in a subnetted network. Subnet mask = 255.255.255.0 • obtain subnet id by bitwise AND with the subnet mask • 10000010 00011101 00000101 00000111 • 11111111 11111111 11111111 00000000 AND • = 10000010 00011101 00000101 00000000 • Thus the SubNet ID is = 130.29.5.0
A Sub-Netted Network 130.29.3.0 130.29.2.0 130.29.4.0 130.29.5.0 130.29.1.0 Route to 130.29.5.0 IP packet DA=130.29.5.7 130.29.7.0 130.29.6.0
Obtaining the Sub-Network Address • First network is 130.29.1.0 • First host on 1st network is 130.29.1.1 • Last host on 1st subnet is 130.29.1.254 • Broadcast on 1st subnet is 130.29.1.255 • Second network is 130.29.2.0 • First host on 2nd network is 130.29.2.1 • Last host on 2nd subnet is 130.29.2.254 • Broadcast on 2nd subnet is 130.29.2.255
Obtaining the Sub-Network Address • Last network is 130.29.254.0 • First host on last network is 130.29. 254.1 • Last host on last subnet is 130.29. 254.254 • Broadcast on last subnet is 130.29. 254.255 • NOTE • The all 0’s and the all 1’s subnets are not used, as this can cause confusion with the class B address. • e.g • 130.29.0.0 (which network ?) • 130.29.255.255 (broadcast to which network?)
Sub-netting • With a class A address we have 24 host bits. • We can borrow between 2 an 22 bits for a sub-net-id • With a class B address we have 16 host bits. • We can borrow between 2 an 14 bits for a sub-net-id • With a class C address we have 8 host bits. • We can borrow between 2 an 6 bits for a sub-net-id
Choice of Subnet mask Consider a class C network 201.56.121.0 • Can borrow 2-6 bits for subnet • Subnet masks • 255.255.255.192 (11000000) – 2 bits • 255.255.255.224 (11100000) – 3 bits • 255.255.255.240 (11110000) – 4 bits • 255.255.255.248 (11111000) – 5 bits • 255.255.255.252 (11111100) – 6 bits
Choice of Subnet mask • Borrow 2 bits SN mask 255.255.255.192 • 2bits subnet – 2 subnets (01 –10) • 6 bits for host - 62 hosts per subnet • Borrow 3 bits SN mask 255.255.255.224 • 3 bits subnet – 6 subnets (001 – 110) • 5 bits for host - 30 hosts per subnet • Borrow 4 bits SN mask 255.255.255.240 • 4 bits subnet – 14 subnets (0001 – 1110) • 4 bits for host - 14 hosts per subnet
Choice of Subnet mask • Borrow 5 bits SN mask 255.255.255.248 • 5 bits subnet – 30 subnets (00001 – 11110) • 3 bits for host - 6 hosts per subnet • Borrow 6 bits SN mask 255.255.255.252 • 6 bits subnet – 62 subnets (000001 – 111110) • 2 bits for host - 2 hosts per subnet
Example mask • IP Address 201.56.121.0 (201=11001001) Class C 1 1 0 Net id Host id • SN Mask 255.255.255.224 (11100000) 1 1 0 Net id SN id Host id 24 bits 3 bits 5 bits
Example mask • IP Address 201.56.121.0 • SN Mask 255.255.255.224 (11100000) Subnets 201.56.121.32 (001 00000) – 1st subnet 201.56.121.64 (010 00000) – 2nd subnet 201.56.121.96 (011 00000) – 3rd subnet 201.56.121.128 (100 00000) – 4th subnet 201.56.121.160 (101 00000) – 5th subnet 201.56.121.192 (110 00000) – 6th subnet
Example mask • Look at the 3rd subnet • Sub net 201.56.121.96 (011 00000) 210.56.121.96 (011 00000) – the network 210.56.121.97 (011 00001) – 1st host 210.56.121.126 (011 11110) – last host 210.56.121.127 (011 11111) – broadcast