Basic Networking Howto.
July 16th, 2008 by amatesi
Since my job deals mainly with Networking stuff, I’m gonna post a summary for me, to remember always how does it works. The following takes into account the structure of LAN Networks with TCP/IP Suite of Protocols.
In the past, I (as many others), have fallen into confusion when talking about IP Addresses/Subnets-Subnet Mask, Broadcasts and Binary Conversion.
The following is my 2cents to help draw this confusion away.
Who invented IPv4 protocols, introduced the Classes concept to better separate and distinguish a Network from another (even if today we have CIDR – but ignore it for now). The Classes concept is just a theory and is not constraining at all; you can have a Class C address layout and yet have a different network. Let’s say you have a 192.168.1.0 Network; it is obviously a class C Network, because the address is on the range 192..203, but if you specify a Subnet Mask that is not the usual one (say 255.0.0.0), you can!
The fact I wish to underline is that, saying it is a class C address, and the Subnet Mask is 255.0.0.0 is not related: the Subnet and the Class simply are unrelated concepts (for the foretold network you’d usually apply the 255.255.255.0 Subnet Mask, but this is just to simplify things). This way we’ll have the Network (aka Subnet) address masked with its own mask, and for the example we would have a 192.0.0.0 network.
Usually the difference between a class A, B or C address lies in the first 4 bits of the first octet.
Octet: a series of 8 bits composing an IP Address; this is an octet -> | 1 1 1 1 1 1 1 1 | wich translates as 255 on decimal, for us humans (try it with the calculator!)
A class A address does have the FIRST bit of the octet as a ZERO, so -> | 0 1 1 1 1 1 1 1 | translates to 127, but 127 class A address is reserved for loopback, so the range for Class A Network is 1..126 (126 is | 0 1 1 1 1 1 1 0 | ) (loopback is a special address that refer always to "YOUR_PC").
Class B address does have the SECOND bit of the octet as a ZERO, so -> | 1 0 0 0 0 0 0 0 | translates to 128, then the range assigned to class B is 128..191 (191 is | 1 0 1 1 1 1 1 1 | ).
Class C address does have the THIRD bit of the octet as a ZERO, so -> | 1 1 0 0 0 0 0 0 | translates to 192, then the range assigned to class B is 192..203 (203 is | 1 1 0 1 1 1 1 1 | ).
Class D is another form of Classes, intuitively Class D range from 224..239 (wich is | 1 1 1 0 0 0 0 0 | to | 1 1 1 0 1 1 1 1 |), where ZERO Lies on the fourth bit position.
After the preview, now let’s analyze how subnetting works.
To understand subnetting, it is important to remember that, inside a Network, there are some constraints:
- A network have a well-defined IP address that have usually a zero (ex. 192.168.1.0) [but it can be different from zero just in case].
- A Network does have always a Broadcast address (usually in the form of network-address plus last bits set at 1, i.e.: 192.168.1.255).
- The Network is an address masked with a Subnet Mask (in fact a Network can also be called just a Subnet).
- There is a limited number of possible addresses (based on the Subnet mask).
It is almost impossible to make a huge single network (like a pure class B – 65536 hosts), without considering subnetting, because the network will become clogged, slow and unmaintainable (technically there happens "collisions"). The problem lies on broadcasting: when you have a huge segment, and a client broadcasts, this broadcast spread to the entire, 65536 hosts’ network! So when you logically separate a network from the other, the broadcasts are limited to a subnet.
For this reason we use subnetting, by separating a Network Segment from another and by joining them accordingly by using a router, usually a device with two I/Fs, one on either end, connecting two different networks (maybe next article..).
Enter Subnet Mask.
The Subnet Mask is an IP-like address composed of binary ONES and ZEROS. The SM is a layer applied to an IP Address to "identify" and distinguish a network from the hosts.
An IP address is composed of bits, these bits can be one or zeros; when you specify a mask, you have to apply this mask to the IP address to identify precisely what the network is.
Example:
IP: 192.168.1.0 – netmask: 255.0.0.0
Open questions:
- What is the class?
- What is the network?
- What is the Broadcast?
- What IP address the Network’s hosts should have?
Answers:
- The Class of the Network is Class C, because 192 translates to | 1 1 0 0 0 0 0 0 | and the ZERO lies on the third bit.
- The Network is 192.0.0.0, because the subnet mask is composed of all | 1 1 1 1 1 1 1 1 | on the first octet, and when we have all 1s on the octet, we want to distinguish the network part from the host part [by assigning a 1 to the net and a 0 to the host]. This is how it works intuitively, in reality it is the result of a logical AND operation.
- The Broadcast address is 192.255.255.255, that is because all the host bits part should be set at all 1s, since the hosts part of the network is the 0.0.0 of the 192.0.0.0 network, and we set them to all 1s ( | 1 1 1 1 1 1 1 1 | -> 255 decimal).
- A host inside this network could have an address like 192.1.10.14 or 192.100.25.1 or whatever.
Extension of answer 3:
The logical AND operation gives 1 only when applied to two 1s, so:
0 AND 0 -> 0;
0 AND 1 -> 0;
1 AND 0 -> 0;
1 AND 1 -> 1;
If we put into column IP plus Subnet Mask, and we apply the AND operation on ‘em, we’d obtain the right Network address:
IP: | 1 1 0 0 0 0 0 0 | . | 0 0 0 0 0 0 0 0 | . | 0 0 0 0 0 0 0 0 | . | 0 0 0 0 0 0 0 0 |
AND
M: | 1 1 1 1 1 1 1 1 | . | 0 0 0 0 0 0 0 0 | . | 0 0 0 0 0 0 0 0 | . | 0 0 0 0 0 0 0 0 |
we gain the right Network Address:
N: | 1 1 0 0 0 0 0 0 | . | 0 0 0 0 0 0 0 0 | . | 0 0 0 0 0 0 0 0 | . | 0 0 0 0 0 0 0 0 |
Addendum:
Today we can find some address expressed in the form IP.Address/number (like 192.168.1.0/24).
What this mean is simple: It is a network that dedicates the first 24 bits on the Subnet Mask (as 1s for the network part), and the rest 8 bits as 0s (on the hosts part). So we intuitively identify this network as 192.168.1.0 (given by the AND operation between the IP and the Subnet Mask, 192.168.1.0 AND 255.255.255.0 -> CONVERTED TO BINARY -> AND OPERATION -> CONVERT THE RESULT TO DECIMAL -> 192.168.1.0 as Network Address).
That seems all.
Posted in System Administrator | No Comments »