An introduction to IP networksBy Eddie Lord. Published: 4th Sep 2004, 21:09:56 | Permalink | Printable
Part one of masking the 'netIn a series of articles originally published earlier in Archive magazine, Eddie Lord gently talks us through the growth and structure of IP based networks
Anyone who has the delved into the Network section of the !Boot configuration tool might be forgiven for wondering what on earth the IP address and netmask numbers are all about. My aim in this article is to give the general readership some background material on network addressing, and subnet masks in particular.
In order to do this, I will go back into Internet history and quickly recap on some elementary binary arithmetic. I will then look at the gory details of network classes, subnet masks, subnetting and CIDR (classless inter-domain routing).
Some network jargon
Networks have acquired a jargon all of their own, as is usual with anything technical, so I will try to explain any jargon as it arises, but first some elementary definitions are required.
Networks can be either a local area network (LAN), such as you might have at home, or that mother of all networks, the ‘Internet’. Generally, large networks are called wide area networks or WANs. Networks of all kinds are just a collection of hosts or nodes connected together.
The words ‘host’ and ‘node’ are used extensively in network jargon. A host or node is simply any computer, printer, Internet router or other device with its own network card or interface. Each host or device requires an address in order to communicate with the net. In the context of a network, it’s actually the interface that is important. Some hosts, such as a device called a router/modem, can have more than one interface, and it is each interface that needs an address.
Data sent via a network has to be packaged in a certain way. This is known as a protocol. There are many protocols on the Internet, TCP/IP being probably the most common. Other common protocols are NetBEUI, AppleTalk and IPx.
The term TCP/IP stands for Transmission Control Protocol/Internet Protocol. In simple terms, TCP ensures that any message is sent error free, whilst the IP controls the routing of the message. It’s not the most efficient protocol, but many of the other protocols are proprietary, being marketed by various big companies.
TCP/IP is equally at home on a small network, even if it is only two machines connected together by a single cable.
To successfully deliver a message, the Internet protocol requires that each host has a unique address. This is the IP address which currently consists of a 32bit binary number. As I shall explain in more detail later, hosts must be arranged in a series of networks. To control the division of these networks, we need another 32bit number called the subnet mask or just ‘netmask’.
History of the IP address
The origins of the Internet can be traced back to the US military who were concerned about their ability to communicate in the event that all centres of communication were destroyed. In 1969, a project was set up to try to address this problem and build a ‘web’ of routes which would automatically bypass any failed communication centre.
By the mid 1980s, the project had become dominated by universities and research sites. TCP/IP was developed and in place as the major protocol, and email started to become popular amongst the researchers. In 1983, a total of 562 hosts had been registered.
In the early days, it was possible for anyone to just request an IP address from the controlling organisation. However, it soon became evident that some sort of system had to be put in place to administer IP address allocation.
The Internet Assigned Numbers Authority (IANA) is now the international organisation that oversees the issue of IP addresses. In fact, IANA allocates parts of the address space to the various Regional Internet Registries according to their requirements. These regional bodies are then responsible for assigning addresses to other operators and users within their own regions.
A major problem with the established scheme is that the supply of available IP addresses is running out. A new scheme is now being rolled out which extends the current 32bit number regime (called IPv4) to 128 bits (called IPv6 or IPng - next generation).
The growth in the Internet has been stunning and continues to grow beyond the original designers’ wildest estimates. A typical pattern of growth can be seen in the chart (figure 1), which shows the growth in the number of active routes of a major ‘backbone’ network. A backbone network is just one of many central networks that connect smaller and usually slower speed networks together. This phenomenal growth also brought further problems with the storage of all the IP addresses – an issue which I’ll look at later.
Figure 1: Growth in routing tables
On a practical note, when you log on to your ISP, they lend you an IP address for the duration of the session, and this is known as dynamic addressing. A static IP address means that the ISP will allocate you an IP address of your very own. (Buy one now whilst stocks last!). However, in reality, if you move to another ISP, you will have to change your IP address anyway. This means that you don’t ‘own’ the IP address but only rent it.
Decoding the IP address
Should you ever look at the network configuration option within !Boot, you will see that the IP address is expressed as four decimal numbers separated by dots. This is known as the dotted decimal notation. The decimal notation is simply a shorthand method of writing the address which, in reality, is a 32bit binary sequence. Since we poor mortals find it difficult to count in binary, the decimal notation is intended to help with the understanding and handling of IP addresses.
Any 32bit number can be broken down into four bytes. Each byte represents eight bits. (These bytes are sometimes called octets.) Each decimal number of the dotted decimal IP address represents one of these bytes. Each byte or eight bits can range in value from 0 to 255 which, in binary, is 00000000 to 11111111. Figure 2 illustrates how the dotted decimal notation relates to the 32bit binary equivalent.
Figure 2: Dotted decimal notation
Note that the binary number is, in fact, one long number and has only been separated for clarity. In theory, a 32bit number can represent 232 addresses. That’s 4,294,967,296 or just under 4.3 billion addresses. Of course, life is not that simple; what nature gives with one hand, it takes away with the other. In this case, trying to attach four billion computers together on one (very long) wire just wouldn’t work.
Apart from anything else, one wire couldn’t support all the network traffic at once as there would be insufficient bandwidth. It was clear that the one wire network had to be broken down into a series of subnetworks and, in order to subdivide the 232 addresses available into more manageable sizes, the class system was devised. Three classes were designed to accommodate large, medium and small networks, respectively. However, before discussing network classes, it’s time for some education.
Back to school
To fully understand IP addressing and netmasks, some elementary binary sums are required to convert decimal numbers to and from binary, and to handle binary addition.
Conversion between binary and decimal numbers is relatively easy when you recall that each 0 or 1 in a binary number stands for some power of 2. Table 1 will give a clue. In the example shown, we convert the binary number 00110001 to decimal by noting the numbers represented by the 1’s and adding them up. In this case, add 32+16+1=49.
Conversion from decimal to binary is similar. Just divide the decimal number by the highest power of two and, if there is a remainder, divide that by the next lower power of 2, and so on. If the number is less than the power of two then record a 0 - otherwise record a 1. In this example (table 2), the number 220 converts to 11011100.
One other concept we need to know is the special manipulation of binary numbers known as ‘bitwise logical AND’. This is relatively simple idea that is illustrated below:
1 AND 1 = 1
0 AND 1 = 0
1 AND 0 = 0
0 AND 0 = 0
In other words, if you are ANDing with 1, the original binary number is passed through:
1 AND 1 = 1
0 AND 1 = 0
If ANDing with 0, the result is always 0:
1 AND 0 = 0
0 AND 0 = 0
This is the fundamental principle used in netmasks which we will come to later. The term ‘bitwise’ just means handle each byte one bit at a time.
You can see a practical analogy of the ANDing process if you consider two switches in series as shown in figure 3. Electricity will only flow in the first example.
Figure 3: ANDing two bits
These binary manipulations can be checked on the computer. Just go to the task window <ctrl-F12> and type
BASIC. This will start Basic V and, at the command line, type
PRINT %1010 AND %1100. This will calculate the AND of these two binary numbers and display the result in decimal.
You may well wonder why I have indulged in this interlude of binary conversions but that will start to become clear as we continue. In fact, binary notation is an essential part of understanding how IP addresses and netmasks work, so it’s worth getting to grips with it. I said earlier that dotted decimal notation was used to make IP addresses easier to understand but, on occasions, it actually makes it more difficult to see what is going on. Using the binary notation is then essential for understanding the principles.
You will also notice how the powers of two keep cropping up throughout this article.
Classic IP addressing
In 1981, the Internet protocol was standardised as a 32bit number which consisted of two parts, the network part and the host part. The two-part structure allows the various routers to correctly forward any data packets by referring to the network part alone. Each router looks up its routing table and forwards the packet to the next router closest to the destination. Once the packet reaches the destination network, the router then uses the host part of the address to deliver the message to its final destination host.
Originally the whole IP address space was broken down into five classes. Each class was defined by the first four bits of the binary address plus the length of the network part of the address. Figure 4 illustrates this division of classes whilst tables 3 and 4 add the details. Note the alternative names given to the different parts, which are often used interchangeably in networking literature. These days ‘network prefix’ is the preferred term for the network part − more of that later.
Figure 4: Classic IP address space
|Table 3: Classic IP Network and Host Division|
|Class||Binary Network and Host parts||Network bits||Host bits||Number of Nets per Class2N||No. ofHost per Net2h||Total No. of hosts supported|
|C||110NNNNN.NNNNNNNN.NNNNNNNN.hhhhhhhh||21 || 8||2,097,152||256||536,870,912|
|Total hosts supported (theoretical)||3,758,096,384|
In the early days, Internet routers would detect the first four bits and automatically decide which class the address belonged to and hence, the length of the network part of the address.
Table 3 shows how each class has its address bits divided into network bits and host bits. The ‘N’ represents the network bits. The ‘h’ represents the host bits. Note how the parts divide on the byte boundary. The first part gives the network address or network number and the second part the host ID.
For class A, the length of the network part is defined by the first byte, for class B the first two bytes, and class C by the first three bytes.
Table 4 illustrates how each class is also defined by the first four bits of the address. Class A is specified as 0yyy, class B as 10yy and class C as 110y, where y can be either 0 or 1.
|Table 4: Original Class System for IP Address Space|
|Class||First 4 address bits||Address range of the first byte or octet||Full address range for each class||Intended use|
|Binary range||Decimal range|
|Class A||0yyy||0000 0001 to 0111 1110||1 to 126||1.x.x.x126.x.x.x||Large Organisations|
|0111 1111||127||127.x.x.x||Loop Back test|
|Class B||10yy||1000 0000 to 1011 1111||128 to 191||128.0.x.x191.255.x.x||Medium Networks|
|Class C||110y||1100 0000 to 1101 1111||192 to 223||192.0.0.x223.255.255.x||Small networks|
|Class D||1110||1110 0000 to 1110 1111||224 to 239||Multicasting|
|Class E||1111||1111 0000 to 1111 1111||240 to 255||Experimental|
Using the first four bits, the address range of each class can be found. For example, class C has the first three bits set to 110. All the other bits in the network part can be either 0 or 1. The first byte must, therefore, range from 1100 0000 (192) to 1101 1111 (223). As the next two bytes of a class C address are also part of the network address, each of these bytes can range from 0 to 255. The host part is left to the client to select.
In simple terms, this just means that the network bytes are assigned by IANA, whilst the ‘x’ part of the address is assigned by the ISP or network administrator. So the full address range for class C networks is 192.0.0.x to 223.255.255.x
The observant amongst you will notice that not all possible values are represented or used. In particular, addresses 0.0.0.0 to 0.255.255.255 are reserved for use as the ‘default’ route.
One other important address which is reserved is 255.255.255.255. This is used as the ‘all hosts’ broadcast address. (Broadcast addresses are covered below).
Addresses beginning 127.x.x.x are also excluded and are used for loopback testing on the local host. (If you look at the !Boot configuration Network->Hosts, you will note that the loopback address is 127.0.0.1, which is a standard IP address for loopback testing. This must not be changed.) You can test this by pinging 127.0.0.1 which, of course, points to your own computer. (<F12>
*ping 127.0.0.1). When you get bored watching the results scroll past, just hit escape.
As far as we are concerned, only classes A, B and C are important as class D and E are used for other purposes and shouldn’t be used as valid IP addresses.
In fact, class D is reserved for multicasting, and class E is reserved for experimental work and future expansion. Observe from figure 4 that class A takes up half of the available address space, whilst class B uses a quarter and class C takes up an eighth. The power of two strikes once again.
Calculating network sizes
Now for some more sums. Look again at table 3 and the importance of the network part and host part becomes apparent when calculating the size of each network class. The number of networks available in each class is given by 2N and the number of hosts on each network is 2h.
One conclusion from table 3 is that the theoretical number of hosts supported by a 32bit number has dropped from the original 4.3 billion down to 3.7 billion, as class D & E addresses are excluded from the normal address space. Even this is only a theoretical limit as we’ll see in a moment.
In particular, addresses beginning with 0.x.x.x and 127.x.x.x aren’t available, reducing the number of class A nets to 126 and the number of hosts by 33,554,432 (2×256×256×256). Several other address blocks have been set aside for special purposes such as private address space and other ‘martian’ addresses − more in a moment.
Network and broadcast addresses
In addition to the reserved blocks, noted above, two of the available addresses within every network are also reserved and shouldn’t be assigned to any hosts. These reserved addresses are designated as the network and the broadcast address of the network respectively.
This is best illustrated with another example. Take a host address of 192.0.2.10, which from table 4, we can see is a class C address. There are a total of 2,097,152 class C networks, and each network can, in theory, support 256 hosts. The full address range for our example network will be from 192.0.2.0 to 192.0.2.255. It is the start and end addresses which are special cases and are reserved.
These addresses are special because the hosts bits are either all ‘0’ or all ‘1’. When all the host bits are set to ‘0’, the resulting IP address becomes 192.0.2.0, and is called the network route address. Think of the network address as the address of the network cable.
When all the host bits are set to ‘1’ then the IP address becomes 192.0.2.255 which is called the broadcast address. The broadcast address is used to address all the hosts at once, so any packet sent to 192.0.2.255 is sent to every host on that network. For class C networks, the actual number of available hosts on each network is now reduced to 254.
Private address space and other martian addresses
IANA had the foresight to set aside some of the available IP addresses for some private address space. These IP numbers can be used by anyone building a private network, as these numbers aren’t registered to anybody on the Internet.
Owing to the fact that they are unregistered, Internet routers won’t forward messages from these IP addresses. The down side is that you can’t use these numbers if you intend to connect your LAN directly to the Internet unless you are isolated behind a router, or a proxy server.
The security aspect is another important advantage of using private address IP numbers. Since these numbers are undefined on the Internet routing tables, these networks should be relatively secure from discovery.
One set of private addresses has been taken from each class and these are shown in table 5.
|Table 5: Private Address Space|
|Class||Private Address Range||No of Classic Nets||Hosts Supported||Network prefix|
|A||10.0.0.0 to 10.255.255.255||1 x A||16,777,216||10.0.0.0/8|
|B||172.16.0.0 to 172.31.255.255||16 x B||1,048,576||172.16.0.0/12|
|C||192.168.0.0 to 192.168.255.255||255 x C||65,536||192.168.0.0/16|
If you are setting up a LAN at home then you are strongly advised to choose your host addresses from these IP numbers. In fact, you will probably find that the LAN side of any router you buy will already programmed with one of these addresses, and in my case it was 10.0.0.2, with a netmask of 255.0.0.0.
As mentioned earlier, there are several other addresses reserved for special purposes and these are listed in table 6 with a brief explanation of their purpose. These are sometimes known as ‘martian addresses’.
|Table 6: Other Reserved Addresses|
|Reserved IP Addresses||Network prefix||Network usage|
|0.0.0.0 to 0.255.255.255||0.0.0.0/8||Default “This” network|
|126.96.36.199 to 188.8.131.52||184.108.40.206/8||Public data networks|
|220.127.116.11 to 18.104.22.168||22.214.171.124/8||Cable TV networks|
|127.0.0.0 to 127.255.255.255||127.0.0.0/8||Loopback address|
|169.254.0.0 to 169.254.255.255||169.254.0.0/16||Auto configuration on a local link|
|192.0.2.0 to 192.0.2.255||192.0.2.0/24||Test network (Use in docs)|
|126.96.36.199 to 188.8.131.52||184.108.40.206/24||6 to 4 relay|
|198.18.0.0 to 198.19.255.255||198.18.0.0/15||Network Interconnect|
|255.255.255.255||All hosts broadcast address|
Notice that a network prefix has suddenly appeared, and this will be covered later.
By 1985, it became obvious that the original class system had its problems. This is no surprise really as the original designers never envisioned the phenomenal growth of the Internet.
In retrospect, the class system was found to be extremely wasteful of address space. The class A regime takes up half the available IP address space and was quickly allocated, often to organisations that couldn’t possibly use the huge number of host addresses available to them. Class B addresses were also quickly exhausted, but again they were found to be wasteful, leaving class C addresses which were really too small for the needs of many organisations.
For instance, if an ISP needed enough addresses for, say, 30,000 hosts, a class B address might have been allocated. Since a class B network can support 65,536 hosts, the remaining 35,536 addresses were just wasted.
As a consequence, the availability of IP numbers was severely reduced. A second problem was also beginning to emerge with the global routing tables.
Global routing tables reach capacity
In order for messages to be delivered anywhere on the Internet, all the Internet backbone routers have to maintain a complete set of lookup tables with all the IP addresses logged. (Figure 1 actually shows the growth in these routing tables.)
Routing tables are complex and have to be constantly updated to keep up with the dynamic changes in the Internet. These tables started to grow beyond the ability of the software and personnel to manage the tables effectively. The problems of keeping the routing tables in sync started to threaten the growth of the Internet.
In Part Two
The story of the Internet is largely one of solving the above problems and the next development in the story was subnetting, which is covered in part two.
Archive magazine - the subscription magazine for RISC OS users
Previous: Iyonix price slash offer, yawns stifled
Next: Solar powered RISC OS: wrong place at right time
DiscussionViewing threaded comments | View comments unthreaded, listed by date | Skip to the end
Please login before posting a comment. Use the form on the right to do so or create a free account.
Search the archives
Today's featured article
Wakefield 2006 show report
All the thrills and spills from the weekend [Updated]
90 comments, latest by bucksboy on 23/05/06 5:57PM. Published: 15 May 2006
Intel to shed XScale chips
Rids itself of non-mobile families, it's claimed
15 comments, latest by druck on 7/5/06 9:19PM. Published: 5 May 2006
News and media:
RISCOS Ltd •
RISC OS Open •
MW Software •
Advantage Six •
CJE Micros •
Liquid Silicon •
Chris Why's Acorn/RISC OS collection •
The Register •
The Inquirer •
Apple Insider •
BBC News •
Sky News •
Google News •