4. Subnet Mask
Class
First
Octet
Range
Number
of Network
Bits
Number
of Host
Bits
Default
Subnet
Mask
Number
of
Networks
Number
of Hosts
per Network
A 0-127 8 24 255.0.0.0 128 16,777,216
B 128-191 16 16 255.255.0.0 16,384 65,536
C 192-223 24 8 255.255.255.0 2,097,152 256
Each class has a default or "natural" subnet mask based on the
default number of bits used for the network and host portion.
Netid Hostid Hostid Hostid
Netid Netid Hostid Hostid
Netid Netid Netid Hostid
Class A
Class B
Class C
First Byte Second Byte Third Byte Fourth Byte
5. Network Prefixes
How do you know the number of bits assigned to the network and the
number of bits assigned to the host?
Prefix Mask:
The address is followed by a number that represents the number of bits
(prefix length), beginning from the left, that apply to the network.
A slash (/) is used to separate the address and the prefix length.
192.168.10.2/24
Means that the first 24 bits are the network portion.
The last 8 bits are the host portion.
Class
Number of
Network Bits
Number of
Host Bits
Default
Prefix
Default
Subnet Mask
A 8 24 /8 255.0.0.0
B 16 16 /16 255.255.0.0
C 24 8 /24 255.255.255.0
6. Classful IPAddressing – Class C
We know from the Class C default subnet mask (255.255.255.0):
The first 24 bits are the network number and the
last 8 bits are the host numbers.
11111111
01001101
00010100
11010010
255
77.
20.
210.
• The last host address (all 1's) is reserved for the broadcast address.
00000000
01001101
00010100
11010010
0
77.
20.
210.
• The first host address (all 0's) is reserved for the network address.
The number of usable host addresses for the entire network is 28 – 2 = 254
11111110
01001101
00010100
11010010
254
77.
20.
210.
00000001
01001101
00010100
11010010
1
77.
20.
210.
The range of available
addresses is:
7. Example
For example: In Class C :
Address range: 192 - 223
Number of network bits: 24
Number of networks: 2^24 = 2,097,152
Number of host bits: 8
Number of hosts per network: 28 = 256
Number of Useable Hosts per network: 28 - 2 = 254
Default Subnet Mask: 255.255.255.0 or /24
12. 12
Subnetting
It divides the main network into several subnets Each one with its own
subnet address.
For example, if you want to take 5 bits from the Host field for subnetting and
leaves 3 bits for defining hosts as shown in figure below. Having 5 bits
available for defining subnets means that we can have up to 32 (2^5) different
subnets.
Let a class C network with 256 host addresses. One of these addresses is used
to identify the network address and another one is used to identify the
broadcast address on the network. Therefore, we are left with 254 addresses
available for addressing hosts.
13. 13
Subnetting
Suppose the IP address = 192.168.10.44
Default Mask = 255.255.255.0
How to calculate subnet using binary method?
1. Convert to binary
2. Calculate the Subnet Address
To calculate the IP Address Subnet you need to perform a bit-wise AND
operation (1 and 1 = 1, 1 and 0 or 0 and 1 = 0, 0 and 0 = 0) on the host
IP address and subnet mask. The result is the subnet address.
16. Subnetting
4. Calculate the Total Number of Subnets and Hosts Per Subnet
So number of subnets is = 2 ^# subnet bits
Number of hosts in each subnet is = 2^ # host bits
17. Example
211.215.9.115/29 : 29 (24+5) means we will take 5 bits from the host part for the
subnetting and leave 3 bits for the hosts in the subnet. So to find the first subnet
Suppose the following IP 211.215.9.115/29 find first subnet address, first host in
the subnet, Last host in the first subnet, broadcast address of the first subnet and
the address of the second subnet.
Answer
211.215.9. 115 = 01110011
subnetMask for the 5 bits is 11111000
Bit wise And operation 01110000 = 112
So, the first subnet is 211.215.9.112
First host in the subnet is 211.215.9.113
last host in the subnet is 211.215.9.118
Broadcast address is 211.215.9.119
Second subnet will start 211.215.9.120
18. Example
Note that if you need for example 3 subnets only from your network,
How to compute the number of bits that you need?
So, convert number 3 to binary?
2 3
1
So, we need Two bits
1
1
11000110 10101000 11010100 00 000000
Netid (For network) Hostid
Subnet
11000110 10101000 11010100 00000000
Netid (For network) Hostid
19. Routing
To route the router, need to know:
1) Destination address
2) Different routes
3) Best route
4) Maintain and verify routing information
20. Routing
Each router has a routing table to specify the different networks and best
route to this networks
To know the best route, router should perform routing process because it
only know the direct connected devices.
there are two different types of routing : Static and Dynamic
Static uses the route that is entered manually by the admin
Dynamic uses a network routing protocol adjusts automatically for
topology or traffic changes
21. Static Route
Configure unidirectional static routes to and from a sub network to allow
communications to occur.
For example, if we have packets on router A and need to travel to network
172.16.1.0 we should configure router A to decide the path to the
destination address How?
Destination address Subnet Mask Next Hop which means next router
22. Static Route
How to decide more than route in the static way?
The same command is used but with adding distance for each command to
specify the priority of each route.
The distance value ranged from 0 to 255 and default value is 1.
The low value is the best route
Distance
value
23. Dynamic Routing
Routing protocols are used to determine paths and maintain routing table such
as RIP (Routing Information Protocol).
Once the path is determined a router can route a routed protocol.
Routing
Protocols
Interior
Protocols
Hybrid
Routing
EIGRP (Enhanced
Interior Gateway
Routing Protocol)
Distance
Vector
RIP (Routing
Information
Protocol)
Link State
OSPF (Open
Shortest Path
First)
Exterior
Protocols
BGP (Border
Gateway
Protocol)
24. Dynamic Routing – Distance Vector - RIP
It uses hop count as a routing metric to find the best path between the source and the
destination network.
RIP uses port number 520.
Hop count is the number of routers occurring in between the source and destination
network. The path with the lowest hop count is considered as the best route to reach a
network and therefore placed in the routing table.
Routers periodically exchange the router information (default exchange time 30 second).
if no update comes until 180 seconds, then the destination router considers the other
router is out of service.
Default distance is 120 (priority of the route).
In case there are more than one route between two networks the RIP will prefers the
route that has least hop.
25. 25
Dynamic Routing – RIP Example
Each Router will send its Routing table to the routers in its neighbors.
For example, Router C will send its table to Router B
The 0 value in last column means number of hops to reach to the network
because its direct connection so it’s equal 0.
So, what is the content of the table at the end of round?
26. 26
So Router B will investigate the incoming table to register the missing
information in its table for example routing table of router C have two
networks 10.3.0.0 and 10.4.0.0 and in the table of router B there are two
networks 10.2.0.0 and 10.3.0.0, So Router B will add network 10.4.0.1 in
its table with port S1.
Dynamic Routing – RIP Example