Chapter06.IP Addressing
Chapter06.IP Addressing
CHAPTER-6
IP ADDRESSING
(Date of Creation:01-04-2011)
IP Addressing
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: This is called Dotted Decimal Notation
Example 1: 140.179.220.200
It is sometimes useful to view the values in their binary form.
140 .179 .220 .200
10001100.10110011.11011100.11001000
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.
10111100 00011010 000111110 00111100
156 26 30 60
We can use a dot as a separator. Now our IP address has the form
Example 2: 156.26.30.60
which is referred to as the dotted decimal notation.
This encoding provides flexibility in assigning addresses to host and allows a mix of
network sizes on an internet. In particular, the three network classes are best suited to the
following conditions:
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.
Addresses beginning with 01111111, or 127 decimal, are reserved for loopback and for
internal testing on a local machine. [You can test this: you should always be able to ping
127.0.0.1, which points to yourself] Class D addresses are reserved for multicasting.
Class E addresses are reserved for future use. They should not be used for host addresses.
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).
In order to specify the network address for a given IP address, the host section is set to all
"0"s. In our example, 140.179.0.0 specifies the network address for 140.179.220.200.
When the host section is set to all "1"s, it specifies a broadcast that is sent to all hosts on
the network. 140.179.255.255 specifies the example broadcast address. Note that this is
true regardless of the length of the host section.
3.2. Class-A address
3.6. Summary
Class Higher Order Bit Address range No of No. of Hosts
Networks
Class A 0XXXXXXX 1 to 126 126 16,777,214
Class B 10XXXXXX 128 to 191 16384 65534
Class C 110XXXXX 192 to 223 2097152 254
Class D 1110XXXX 224 to 239 Multicasting
4.0. Subnetting
Chopping up of a network into a number of smaller networks is called subnetting..It
allows to assign some of the bits, normally used by the host portion of the address, to the
network portion of the address. Subnet is a real network under a network. Any of the
classes can be subnetted. Subnetting allows efficiently uses the full network address.
The format of subnetted IP address would be <network number, subnet number, host
number>
For example, 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 Address
11111111.11111111.00000000.00000000 255.255. 0. 0 Default Class B S/N Mask
--------------------------------------------------------
10001100.10110011.00000000.00000000 140.179.0.0 Network Address
To calculate the number of subnets or hosts, use the formula (2n-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:
10001100.10110011.11011100.11001000 140.179.220.200 IP Address
11111111.11111111.11100000.00000000 255.255.224.000 Subnet Mask
--------------------------------------------------------
10001100.10110011.11000000.00000000 140.179.192.000 Subnet Address
10001100.10110011.11011111.11111111 140.179.223.255 Broadcast Address
In this example a 3 bit subnet mask was used. There are 6 (23-2) subnets available with
this size mask (remember that subnets with all 0's and all 1's are not allowed). Each
subnet has 8190 (213-2) hosts. Each subnet can have hosts assigned to any address
between the Subnet address and the Broadcast address. This gives a total of 49,140 hosts
for the entire class B address subnetted this way. Notice that this is less than the 65,534
hosts an unsubnetted class B address would have.
You can calculate the Subnet Address by performing a bitwise logical AND operation
between the IP address and the subnet mask, then setting all the host bits to 0s. Similarly,
you can calculate the Broadcast Address for a subnet by performing the same logical
AND between the IP address and the subnet mask, then setting all the host bits to 1s. That
is how these numbers are derived in the example above.
Subnetting always reduces the number of possible hosts for a given network. There are
complete subnet tables available here for Class A, Class B and Class C. These tables list
all the possible subnet masks for each class, along with calculations of the number of
networks, hosts and total hosts for each subnet.
4.3 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.
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.
5.0. Supernetting:
The "classful" system of allocating IP addresses can be very wasteful; anyone who could
reasonably show a need for more that 254 host addresses was given a Class B address
block of 65533 host addresses. Even more wasteful were companies and organizations
that were allocated Class A address blocks, which contain over 16 Million host
addresses! Only a tiny percentage of the allocated Class A and Class B address space has
ever been actually assigned to a host computer on the Internet.
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:
192.60.128.0 (11000000.00111100.10000000.00000000) Class C subnet address
192.60.129.0 (11000000.00111100.10000001.00000000) Class C subnet address
192.60.130.0 (11000000.00111100.10000010.00000000) Class C subnet address
192.60.131.0 (11000000.00111100.10000011.00000000) Class C subnet address
------------------------------------------------------------------------------------------------------------
----
192.60.128.0 (11000000.00111100.10000000.00000000) Supernetted address
255.255.252.0 (11111111.11111111.11111100.00000000) Subnet Mask
192.60.131.255 (11000000.00111100.10000011.11111111) Broadcast address
In this example, the subnet 192.60.128.0 includes all the addresses from 192.60.128.0 to
192.60.131.255. As you can see in the binary representation of the subnet mask, the
Network portion of the address is 22 bits long, and the host portion is 10 bits long.
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.
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.
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 addition to using blocks of contiguous class C networks as units, the allocation rules
for the class C addresses were also changed in RFC 1519. The world was partitioned into
four zones, and each one given a portion of the class C address space. The allocation was
as follows:
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.
Of course, once a 194.xx.yy.zz packet gets to Europe, more detailed routing tables are
needed. One possibility is to have 131,070 entries for networks 194.0.0.xx through
195.255.255.xx, but this is precisely this routing table explosion that we are trying to
avoid. Instead, each routing table entry is extended by giving it a 32-bit mask. When a
packet comes in, its destination address is first extracted. Then (conceptually) the routing
table is scanned entry by entry, masking the destination address and comparing it to the
table entry looking for a match.
To make this comparison process clearer, let us consider an example. Suppose that
Cambridge University need 2048 addresses and is assigned the addresses 194.24.0.0
through 194.24.7.255, along with mask 255.255.248.0. Next, Oxford University asks for
4096 addresses. Since a block of 4096 addresses must lie on a 4096-byte boundary, they
cannot be given addresses starting at 194.8.0.0. Instead they get 194.24.16.0 through
194.24.31.255 along with mask 255.255.240.0. Now the University of Edinburgh asks for
1024 addresses and is assigned addresses 194.24.8.0 through 194.24.11.255 and mask
255.255.252.0.
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
7.0 IPv6
• To meet the continual growth of the Internet ,IETF(Internet Engineering Task
Force) has proposed a set of specifications commonly known as the next
generation IP protocol (“IPng” or IPv6”).
• IPv6 increases the address size from 32 bits to 128 bits, supporting up to 3.4X1038
nodes.
• It is represented using hexadecimal values separated by colons using the format
X:X:X:X:X:X:X:X:, where each X refers to a four digit hexadecimal integer (16
bits each).
• One such address could be
BA98:7654:3210:FEDC:BA98:7654:3210:0043.
7.1 Advantages
• Bigger address space
– The bigger address space IPv6 offers is the most obvious enhancement over
IPv4.
– Allows full, unconstrained IP connectivity for today's
• IP based machines
• Upcoming mobile devices like PDAs and cell phones
• Mobility
– IPv6 supports for roaming between different networks, with global
notification when you leave one network and enter the other one.
• Security
– IPv6 protocol stacks are required to include IPsec.
– IPsec allows authentication, encryption, and compression of IP traffic.
– This allows that all applications on a machine can benefit from
• Encryption
• Authentication
• Policies can be set on a per host (or even per-network) basis, not
per application/service.
• Stateless auto configuration of hosts
• Multicast
• Jumbo grams
• Network layer security
AND:The logical AND operation compares 2 bits and if they are both "1", then the result
is "1", otherwise, the result is "0".
Input 1 1 0 1 0
Input 2 1 0 0 1
Output 1 0 0 0
9.0. Conclusion
IP is Internet Protocol & is responsible for moving packet of data from node to node. &
forwarding each packet based on a four-byte destination address (the IP address). IP
version 4 uses 32 bits and addressing schemes are (a) classfull which has 5 classes A, B,
C,D & E and (b) classless.The Subnetting and supernetting alongwith CIDR are used for
optimum utilization of IP addresses. IPV6 has 128 bits and has features of bigger address
space, enhanced security, mobility, Stateless auto configuration of hosts, Jumbo grams.
4. In order to specify the network address for a given IP address, the host section is
set to all "-------"s.
a. 1
b. 0
c. No change
d. Data insufficient
6. CIDR, is described in
a. RFC 1519
b. RFC 1918
c. RFC 1520
d. RFC 1920
10. Class C addresses have how many bits used for networks?
a. 8
b. 16
c. 24
d. 0