|
||||||||||||||||||||||||
|
the concept of net mask
This is CS 101 stuff really but once in a while it is useful to make simple stuff explicit.
So, you have an IP net mask that looks like this: 255.255.0.0 in dotted decimal IP notation
This is same as 1111 1111.1111 1111.0000 0000. 0000 0000 in dotted binary IP notation.
The mask is basically a binary IP number that gets logically ANDed with an incoming IP number that can be any IP number. The result is still a 32-bit (that is 32 binary digit) IP number that basically keeps the incoming IPs binary digits the same in all the positions that the mask has a 1 and has a 0 wherever the mask has a 0.
The reason we have net masks is in order to be able to:
- define nets and subnets
- easily determine the subnet an IP packet, with a certain IP address in its destination header field, is destined for.
For this to work a net mask (or subnet mask) is paired with a network number.
For the purposes of our example let's say our network is an a B class network defined like this: 131.131.*.*This can be defined, using a net mask in the following two equivalent ways:
- Using two distinct numbers:
-
- Network number: 131.131.0.0 Net Mask: 255.255.0.0
- Using the more elegant prefix length IP notation:
-
- 131.131.0.0/16 - basically means that the mask's first 16 bits, in dotted binary notation, are all 1s
So, a router, in its routing table, would hold info that basically:
- records the router's network - this is the network number and mask combo
- records gateway routers (that is their IP numbers) for networks other that its own
Once the router receives a packet, it reads its IP destination and does a super-fast logical AND with the net mask and the resulting IP number is compared with the router's network number (in our example 131.131.0.0) and
- if it is the same then the packet is routed to the specific node of the router's network that holds the particular IP number found in the packet's destination field.
- if it not the same then the network number is looked up in the router's routing table and
-
- if found, it is forwarded to the respective router
- if not found, it is forwarded to the default router which hopefully will have a more extensive routing table. This process is continued until the the network for the packet is found or the packet is discarded after a number of hops.




Post new comment