Problem
What is a network / subnet mask? Explain how host A sends a message / packet to host B when:
(a) both are on same network and
(b) both are on different networks.
Explain which layer makes the routing decision and how.
Solution
A mask is a bit pattern used to identify the network/subnet address. The IP address consists of two components: the network address and the host address.The IP addresses are categorized into different classes which are used to identify the network address, i.e. class A, B and C.
Example: Consider IP address 152.210.011.002. This address belongs to Class B, so:
Network Mask: 11111111.11111111.00000000.00000000
Given Address: 10011000.11010101.00001011.00000010
By ANDing Network Mask and IP Address, we get the following network address:
10011000.11010101.00000000.00000000 (152.210.0.0)
Host address: 00001011.00000010
Historical table taken from wikipedia:
Class | Leading bits |
Size of network number bit field |
Size of rest bit field |
Number of networks |
Addresses per network |
Start address | End address |
---|---|---|---|---|---|---|---|
A | 0 | 8 | 24 | 128 (27) | 16,777,216 (224) | 0.0.0.0 | 127.255.255.255 |
B | 10 | 16 | 16 | 16,384 (214) | 65,536 (216) | 128.0.0.0 | 191.255.255.255 |
C | 110 | 24 | 8 | 2,097,152 (221) | 256 (28) | 192.0.0.0 | 223.255.255.255 |
Similarly, a network administrator can divide any network into sub-networks by using subnet mask. To do this, we further divide the host address into two or more subnets.
For example, if the above network is divided into 18 subnets (requiring a minimum of 5 bits to represent 18 subnets), the first 5 bits will be used to identify the subnet address.
Subnet Mask: 11111111.11111111.11111000.00000000 (255.255.248.0)
Given Address: 10011000.11010101.00001011.00000010
So, by ANDing the subnet mask and the given address, we get the following subnet address: 10011000.11010101.00001000.00000000 (152.210.1.0)
How Host A sends a message/packet to Host B:
When both are on same network: the host address bits are used to identify the host within the network.
Both are on different networks: the router uses the network mask to identify the network and route the packet. The host can be identified using the network host address.
The network layer is responsible for making routing decisions. A routing table is used to store the path information and the cost involved with that path, while a routing algorithm uses the routing table to decide the path on which to route the packets.
Routing is broadly classified into Static and Dynamic Routing based on whether the table is fixed or it changes based on the current network condition.
References
- http://tianrunhe.wordpress.com/2012/04/25/what-is-a-networksubnet-mask/
- http://stackoverflow.com/questions/12918644/calculating-range-of-ips-from-subnet-mask
- http://stackoverflow.com/questions/20430100/find-mask-to-meet-a-subnetting-requirement
- http://stackoverflow.com/questions/21097430/subnet-masking-is-the-following-calculations-right
- http://stackoverflow.com/questions/13536822/subnet-mask-division
- http://www.iplocation.net/tools/netmask.php
0 comments:
Post a Comment