All about IP
Here are some excellent tutorials about how the Internet Protocol works:
- Understanding IP Addressing: Everything You Ever Wanted To Know By Chuck Semeria
- Daryl's TCP/IP Primer by Daryl Banttari
- TCP/IP Tutorial and Technical Overview IBM RedBook
- Introduction to the Internet Protocols http://oac3.hsc.uth.tmc.edu/staff/snewton/tcp-tutorial/
- http://www.ietf.org/internet-drafts/draft-ietf-zeroconf-ipv4-linklocal-04.txt
Temp stuff
- Example: 57.119.224.19/28 -> netmask = 255.255.255.240
Note: 240 in base 10 = 1111.0000 in base 2
To extract the network #
1. Find which byte has some of its bits used to specify the network # (4th here)
2. Express the value of this byte in base 2 (19 is 0001.0011 in base 2)
3. Extract network part, and convert to base 10 (the first four bits = 0001.xxxx -> 16 in base 10)
=> Network # is 57.119.244.16
To find the range of hosts available for a given network
The first host is the network # + 1 (here, 16 + 1 = .17)
The last host is (256 - 2) - bitmask, and add to network # (256 - 2 = 254; 254 - 240 = 14 ; 16 + 14 = .30)
=> Hosts range from 57.119.224.17 through 57.119.227.30
The reason for substracting 2 addresses is to remove the first and last addresses (network and broadcast, respectively)
To find the broadcast address
Any full "host byte" uses 255 for broadcast (there's none in our example; here, only one byte is left to represent hosts.) The only issue left is to compute the value of the byte whose left part represents the network #, and its right part the host range. For this, extract the "host" part from this important byte, set all bits to 1, compute the value in base 10 of the entire byte (ie. including the network part).
=> Broadcast address is 57.119.224.31 (network part = 16, host part = 15, 16 + 15 = 31)
To create sub-nets of different sizes
Assume your corporate top admin grants your site the private IP network address 10.19.54.0/255.255.255.0. Instead of building a single network, you would like to split hosts into several sub-nets, but not of the same size. Books on TCP/IP usually only present the simple case where only one netmask is used, and each sub-net ends up having the same maximum number of possible hosts. For instance, suppose you want to split your private "class C" 10.19.54.0 into 4 sub-networks: If it's OK with you and your users that each sub-net has the same size, just use a sub-net mask of 255.255.255.192, with networks being 10.19.54.0/26, 10.19.54.64/26, 10.19.54.128/26, and 10.19.54.192/26.
But, what if your local configuration is such that some sub-nets will only contain a few hosts, while others will have significantly more? In this case, you'll have to use different sub-net masks, starting with the smalled network to check how many bits you can steal to build your sub-nets.
Let's go back to the example of 10.19.54.0/24. Suppose two sub-networks (A and B) will never more than 11 hosts, a third sub-network (C) will need up to 55, while the last and fourth sub-net (D) needs 125.
2^3 = 8, and 2^4 = 16. Since sub-nets A and B will never have more than 9 hosts, the closest and adequate mask is 16, ie. 255.255.255.240 since we use the 4 left-most bits of the our class C to build those two sub-nets.
The netmask for sub-net B is /192, since no more than 55 hosts will belong to that network. Finally, the netmask for sub-net A is /128.
Host ranges are:
- Subnet A 10.19.54.1 -> 10.19.54.14 (broadcast = .15)
- Subnet B 10.19.54.17 -> 10.19.54.30 (broadcast = .31)
- Subnet C 10.19.54.65 -> 10.19.54.126 (broadcast = .126)
- Subnet D 10.19.54.129 -> 10.19.54.254 (broadcast = .255)
http://www.iana.org/assignments/ipv4-address-space
-
Resources