IP Addressing
IP Addressing – Introduction
Each host on the internet is assigned a 32-bit integer address called its
internet address or IP address. The clever part of internet addressing is that
the integers are carefully chosen to make routing efficient. Every host and
router on the internet has an IP address, which encodes its network number
and host number. The combination is unique: no two machines have the same
IP address. The address is coded to allow a variable allocation of bits to
specify network and host.
The IP address scheme is to break up the binary number into pieces and
represent each piece as a decimal number. A natural size for binary pieces is
8 bits, which is the familiar byte or octet (octet is the telecommunication term,
but two words can be used interchangeably). So let’s take our binary number ,
write it using groups of 8 bits, and then represent each group as a decimal
number:
Example 1: 140.179.220.200
Every IP address consists of two parts, one identifying the network and one
identifying the host. The Class of the address and the subnet mask determine
which part belongs to the network address and which part belongs to the host
address.
Example 2: 156.26.30.60
which is referred to as the dotted decimal notation.
BRBRAITT : Nov-2006 2
“DATA NETWORKS” FOR JTOs PH-II - IP Addessing
Address Classes
• Class A: Few networks, each with many hosts. It allows for up to 126
networks with 16 million hosts each.
• Class B: Medium number of networks, each with a medium number of
hosts. It allows for up to 16,328 networks with up to 64K hosts each;
• Class C: Many networks, each with a few hosts. It allows for up to 2
millions networks with up to 254 hosts each;
• Class D: Reserved for IP Multicasting.
• Class E: Reserved for future use. Addresses beginning with 1111 are
reserved for future use.
The Following table lists the capabilities for class A, B and C addresses.
You can determine which class any IP address is in by examining the first 4
bits of the IP address.
• Class A addresses begin with 0xxx, or 1 to 126 decimal.
• Class B addresses begin with 10xx, or 128 to 191 decimal.
• Class C addresses begin with 110x, or 192 to 223 decimal.
• Class D addresses begin with 1110, or 224 to 239 decimal.
• Class E addresses begin with 1111, or 240 to 254 decimal.
Now we can see how the Class determines, by default, which part of the IP
address belongs to the network (N) and which part belongs to the host (h).
BRBRAITT : Nov-2006 3
“DATA NETWORKS” FOR JTOs PH-II - IP Addessing
There are three IP network addresses reserved for private networks. The
addresses are 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16. They can be
used by anyone setting up internal IP networks, such as a lab or home LAN
behind a Router performing NAT (Network Address Translation) or proxy
server. It is always safe to use these because routers on the Internet will
never forward packets coming from these addresses. These addresses are
defined in RFC 1918.
Subnetting
Subnet Masking
Applying a subnet mask to an IP address allows you to identify the network
and host parts of the address. The network bits are represented by the 1s in
the mask, and the host bits are represented by the 0s. Performing a bitwise
logical AND operation between the IP address and the subnet mask results in
the Network Address or Number.
Eg, using our test IP address and the default Class B subnet mask, we get:
10001100.10110011.11110000.11001000 140.179.240.200 Class B IP Addrs
11111111.11111111.00000000.00000000 255.255. 0. 0 Default Class B S/M
--------------------------------------------------------
10001100.10110011.00000000.00000000 140.179.0.0 Network Address
BRBRAITT : Nov-2006 4
“DATA NETWORKS” FOR JTOs PH-II - IP Addessing
Additional bits can be added to the default subnet mask for a given Class to
further subnet, or break down, a network. When a bitwise logical AND
operation is performed between the subnet mask and IP address, the result
defines the Subnet Address (also called the Network Address or Network
Number). There are some restrictions on the subnet address. Host addresses
of all "0"s and all "1"s are reserved for specifying the local network (when a
host does not know it's network address) and all hosts on the network
(broadcast address), respectively. This also applies to subnets. A subnet
address cannot be all "0"s or all "1"s. This also implies that a 1 bit subnet
mask is not allowed. This restriction is required because older standards
enforced this restriction. Recent standards that allow use of these subnets
have superceded these standards, but many "legacy" devices do not support
the newer standards. If you are operating in a controlled environment, such as
a lab, you can safely use these restricted subnets.
To calculate the number of subnets or hosts, use the formula (2 n-2) where n =
number of bits in either field, and 2n represents 2 raised to the nth power.
Multiplying the number of subnets by the number of hosts available per
subnet gives you the total number of hosts available for your class and subnet
mask. Also, note that although subnet masks with non-contiguous mask bits
are allowed, they are not recommended.
Example:
BRBRAITT : Nov-2006 5
“DATA NETWORKS” FOR JTOs PH-II - IP Addessing
with calculations of the number of networks, hosts and total hosts for each
subnet.
An Example
Here is another, more detailed, example. Say you are assigned a Class C
network number of 200.133.175.0 (apologies to anyone who may actually own
this domain address). You want to utilize this network across multiple small
groups within an organization. You can do this by subnetting that network with
a subnet address.
We will break this network into 16 subnets of 14 hosts each. This will limit us
to 224 hosts on the network instead of the 254 we would have without
subnetting, but gives us the advantages of traffic isolation and security. To
accomplish this, we need to use a subnet mask 4 bits long.
Subnet
Network Number Host Addresses Broadcast Address
bits
0000 200.133.175.0 .1 thru .14 200.133.175.15
0001 200.133.175.16 .17 thru .30 200.133.175.31
0010 200.133.175.32 .33 thru .46 200.133.175.47
0011 200.133.175.48 .49 thru .62 200.133.175.63
0100 200.133.175.64 .65 thru .78 200.133.175.79
0101 200.133.175.80 .81 thru .94 200.133.175.95
0110 200.133.175.96 .97 thru .110 200.133.175.111
0111 200.133.175.112 .113 thru .126 200.133.175.127
1000 200.133.175.128 .129 thru .142 200.133.175.143
1001 200.133.175.144 .145 thru .158 200.133.175.159
1010 200.133.175.160 .161 thru .174 200.133.175.175
1011 200.133.175.176 .177 thru .190 200.133.175.191
1100 200.133.175.192 .193 thru .206 200.133.175.207
1101 200.133.175.208 .209 thru .222 200.133.175.223
1110 200.133.175.224 .225 thru .238 200.133.175.239
1111 200.133.175.240 .241 thru .254 200.133.175.255
BRBRAITT : Nov-2006 6
“DATA NETWORKS” FOR JTOs PH-II - IP Addessing
Super-netting:
People realized that addresses could be conserved if the class system was
eliminated. By accurately allocating only the amount of address space that
was actually needed, the address space crisis could be avoided for many
years. This was first proposed in 1992 as a scheme called Supernetting.
Under supernetting, the classful subnet masks are extended so that a network
address and subnet mask could, for example, specify multiple Class C
subnets with one address. For example, If I needed about 1000 addresses, I
could supernet 4 Class C networks together:
Instead of spelling out the bits of the subnet mask, it is simply listed as the
number of 1s bits that start the mask. In the above example, instead of writing
the address and subnet mask as 192.60.128.0, Subnet Mask 255.255.252.0
the network address would be written simply as: 192.60.128.0/22 which
indicates starting address of the network, and number of 1s bits (22) in the
network portion of the address. If you look at the subnet mask in binary
(11111111.11111111.11111100.00000000), you can easily see how this
notation works.
BRBRAITT : Nov-2006 7
“DATA NETWORKS” FOR JTOs PH-II - IP Addessing
IP has been in heavy use for over a decade. It has worked extremely well, as
demonstrated by the exponential growth of the Internet. Unfortunately, IP is
rapidly becoming a victim of its own popularity: it is running out of addresses.
This looming disaster has sparked a great deal of discussion and controversy
within the Internet community about what to do about it. In this section we will
describe both the problem and several proposed solutions. A more complete
description is given in (Huitema, 1996).
Back in 1987, a few visionaries predicted that some day the Internet might
grow to 100,000 networks. Most experts pooh-poohed this as being decades
in the future, if ever. The 100,000th network was connected in 1996. The
problem, simply stated, is that the Internet is rapidly running out of IP
addresses. In principle, over 2 billion addresses exist, but the practice of
organizing the address space by classes waste millions of them. In particular,
the real villain is the class B network. For most organizations, a class A
network, with 16 million addresses is too big, and a class C network, with 256
addresses is too small. A class B network, with 65,536, is just right. In Internet
folklore, this situation is known as the three bears problem (as in Goldilocks
and the Three Bears).
In reality, a class B address is far too large for most organizations. Studies
have shown that more than half of all class B networks have fewer than 50
hosts. A class C network would have done the job, but no doubt every
organization that asked for a class B address thought that one day it would
outgrow the 8-bit host field. In retrospect, it might have been better to have
had class C networks use 10 bits instead of eight for the host number,
allowing 1022 hosts per network. Had this been the case, most organizations
would have probably settled for a class C network, and there would have
been half a million of them (versus only 16,384 class B networks).
However, then another problem would have emerged more quickly: the
routing table explosion. From the point of view of the routers, the IP address
space is a two-level hierarchy, with network numbers and host numbers.
Routers do not have to know about all the hosts, but they do have to know
about all the networks. If half a million class C networks were in use, every
router in the entire Internet would need a table with half a million entires, one
per network, telling which line to use to get to that network, as well as other
information.
The actual physical storage of half a million entry tables is probably doable,
although expensive for critical routers that keep the tables in static RAM on
I/O boards. A more serious problem is that the complexity of various
algorithms relating to management of the tables grows faster than linear.
Worse yet, much of the existing router software and firmware was designed at
a time when the Internet had 1000 connected networks and 10,000 networks
seemed decades away. Design choices made then often are far from optimal
now.
BRBRAITT : Nov-2006 8
“DATA NETWORKS” FOR JTOs PH-II - IP Addessing
In addition, various routing algorithms require each router to transmit its tables
periodically. The larger the tables, the more likely some parts will get lost
underway, leading to incomplete data at the other end and possibly routing
instabilities.
The routing table problem could have been solved by going to a deeper
hierarchy. For example, having each IP address contain a country, state, city,
network, and host field might work. Then each router would only need to know
how to get to each country, the states or provinces in its own country, the
cities in its state or province, and the networks in its city. Unfortunately, this
solution would require considerably more than 32 bits for IP addresses and
would use addresses inefficiently (Liechtenstein would have as many bits as
the United States).
In short, most solutions solve one problem but create a new one. One solution
that is now being implemented and which will give the Internet a bit of extra
breathing room is CIDR (Classless InterDomain Routing). The basic idea
behind CIDR, which is described in RFC 1519, is to allocate the remaining
class C networks, of which there are almost two million, in variable-sized
blocks. If a site needs, say, 2000 addresses, it is given a block of 2048
addresses (eight contiguous class C networks), and not a full class B address.
Similarly, a site needing 8000 addresses gets 8192 addresses (32 contiguous
class C networks).
In this way, each region was given about 32 million addresses to allocate, with
another 320 million class C addresses from 204.0.0.0 through
223.255.255.255 held in reserve for the future. The advantage of this
allocation is that now any router outside of Europe that gets a packet
addressed to 194.xx.yy.zz or 195.xx.yy.zz can just send it to its standard
European gateway. In effect 32 million addresses have now been compressed
into one routing table entry. Similarly for the other regions.
BRBRAITT : Nov-2006 9
“DATA NETWORKS” FOR JTOs PH-II - IP Addessing
The routing tables all over Europe are now updated with three entries, each
one containing a base address and a mask. These entries (in binary) are:
Address Mask
This value does not match the Cambridge base address, so the original
address is next ANDed with the Oxford mask to get
This value does match the Oxford mask, so the packet is sent to the Oxford
router. In practice, the router entries are not tried sequentially; indexing tricks
are used to speed up the search. Also, it is possible for two entries to match,
in which case the one whose mask has the most 1 bits wins. Finally, the same
idea can be applied to all addresses, not just the new class C addresses, so
with CIDR, the old class A, B and C network
BRBRAITT : Nov-2006 10
“DATA NETWORKS” FOR JTOs PH-II - IP Addessing
BRBRAITT : Nov-2006 11
“DATA NETWORKS” FOR JTOs PH-II - IP Addessing
Logical Operations
This page will provide a brief review and explanation of the common logical
bitwise operations AND, OR, XOR (Exclusive OR) and NOT. Logical
operations are performed between two data bits (except for NOT). Bits can be
either "1" or "0", and these operations are essential to performing digital math
operations.
In the "truth tables" below, the input bits are in bold, and the results are plain.
AND
BRBRAITT : Nov-2006 12
“DATA NETWORKS” FOR JTOs PH-II - IP Addessing
The logical AND operation compares 2 bits and if they are both "1", then the
result is "1", otherwise, the result is "0".
0 1
0 0 0
1 0 1
OR
The logical OR operation compares 2 bits and if either or both bits are "1",
then the result is "1", otherwise, the result is "0".
0 1
0 0 1
1 1 1
XOR
The logical XOR (Exclusive OR) operation compares 2 bits and if exactly one
of them is "1" (i.e., if they are different values), then the result is "1"; otherwise
(if the bits are the same), the result is "0".
0 1
0 0 1
1 1 0
NOT
The logical NOT operation simply changes the value of a single bit. If it is a
"1", the result is "0"; if it is a "0", the result is "1". Note that this operation is
different in that instead of comparing two bits, it is acting on a single bit.
0 1
1 0
BRBRAITT : Nov-2006 13