CH 7 - Internet Protocol and IP Addressing
CH 7 - Internet Protocol and IP Addressing
CH 7 - Internet Protocol and IP Addressing
At the transport layer, TCP/IP defines three protocols: Transmission Control Protocol
(TCP), User Datagram Protocol (UDP), and Stream Control Transmission Protocol (SCTP). At
the network layer, the main protocol defined by TCP/IP is the Internetworking Protocol (IP);
there are also some other protocols that support data movement in this layer.
Most local-area networks use a 48-bit (6-byte) physical address written as 12 hexadecimal digits;
every byte (2 hexadecimal digits) is separated by a colon, as shown below:
07:01:02:01:2C:4B
A 6-byte (12 hexadecimal digits) physical address
2. Logical Addressing
Communication at the network layer is host-to-host (computer-to-computer); a computer
somewhere in the world needs to communicate with another computer somewhere else in the
world. Usually, computers communicate through the Internet. The packet transmitted by the
sending computer may pass through several LANs or WANs before reaching the destination
computer.
For this level of communication, we need a global addressing scheme; we called this logical
addressing.
Today, we use the term IP address to mean a logical address in the network layer of the TCP/IP
protocol suite. The Internet addresses are 32 bits in length; this gives us a maximum of 232
addresses. These addresses are referred to as IPv4 (IP version 4) addresses or simply IP
addresses if there is no confusion.
Example
4. Specific Addresses
Some applications have user-friendly addresses that are designed for that specific address. Examples
include the e-mail address (for example, [email protected]) and the Universal Resource Locator
(URL) (for example, www.BA’MNET.com). The first defines the recipient of an e-mail; the
second is used to find a document on the World Wide Web. These addresses, however, get
changed to the corresponding port and logical addresses by the sending computer.
Address Space
A protocol such as IPv4 that defines addresses has an address space. An address space is the total
number of addresses used by the protocol. If a protocol uses N bits to define an address, the
address space is 2N because each bit can have two different values (0 or 1) and N bits can have 2N
values. IPv4 uses 32-bit addresses, which means that the address space is 232 or 4,294,967,296
(more than 4 billion).
Notations
There are two prevalent notations to show an IPv4 address: binary notation and dotted decimal
notation.
Binary Notation
In binary notation, the IPv4 address is displayed as 32 bits. Each octet is often referred to as a
byte. So it is common to hear an IPv4 address referred to as a 32-bit address or a 4-byte address.
The following is an example of an IPv4 address in binary notation:
01110101 10010101 00011101 00000010
Dotted-Decimal Notation
To make the IPv4 address more compact and easier to read, Internet addresses are usually written
in decimal form with a decimal point (dot) separating the bytes. The following is the dotted
decimal notation of the above address:
Compiled By: Mr.Abdisa L. MTU Dept of CS
Page 7
7
117.149.29.2
Note that because each byte (octet) is 8 bits, each number in dotted-decimal notation is a value
ranging from 0 to 255.
Exercise
1. Change the following IPv4 addresses from binary notation to dotted-decimal notation.
a) 10000001 00001011 00001011 11101111
b) 11000001 10000011 00011011 11111111
2. Change the following IPv4 addresses from dotted-decimal notation to binary notation.
a) 111.56.45.78
b) 221.34.7.82
Classful Addressing
IPv4 addressing, at its inception, used the concept of classes.
This architecture is called classful addressing.
In classful addressing, the address space is divided into five classes: A, B, C, D, and E.
Each class occupies some part of the address space.
We can find the class of an address when given the address in binary notation or dotted-decimal
notation. If the address is given in binary notation, the first few bits can immediately tell us the
class of the address. If the address is given in decimal-dotted notation, the first byte defines the
class.
addresses in classes A, B, and C are for unicast communication; a host needs to have at
least one unicast address to be able to send and receive
Network Mask
The methods we described previously for extracting the network address are mostly used to show
the concept. The routers in the Internet normally use an algorithm to extract the network address
from the destination address of a packet. To do this, we need a network mask. A network mask
or a default mask in classful addressing is a 32-bit number with n leftmost bits all set to 1s and
(32 − n) rightmost bits all set to 0s.
The IP addresses were originally designed with two levels of addressing. To reach a host on the
Internet, we must first reach the network and then the host. It soon became clear that we need
more than two hierarchical levels, for two reasons.
First, an organization that was granted a block in class A or B needed to divide its large network
into several subnetworks for better security and management. Second, since the blocks in class A
and B were almost depleted and the blocks in class C were smaller than the needs of most
organizations, an organization that has been granted a block in class A or B could divide the
block into smaller sub blocks and share them with other organizations. The idea of splitting a
block to smaller blocks is referred to as sub netting. In sub netting, a network is divided into
several smaller subnetworks (subnets) with each subnetwork having its own subnetwork address.
In classless addressing, the prefix defines the network and the suffix defines the
host.
Example 5.22
What is the prefix length and suffix length if the whole Internet is considered as one single block
with 4,294,967,296 addresses?
Solution
Slash Notation
The difference between classful and classless addressing:
In classful addressing, the netid length is inherent in the address (8, 16, or 24).
In classless addressing, the prefix length cannot be found if we are given only an address
in the block.
In classless addressing, we need to include the prefix length to each address if we need
to find the block of the address.
In classless addressing, we need to know one of the addresses in the block and the
prefix length to define the block.
Network Mask
Compiled By: Mr.Abdisa L. MTU Dept of CS
Page 17
17
The idea of network mask in classless addressing is the same as the one in classful
addressing.
A network mask is a 32-bit number with the n leftmost bits all set to 0s and the rest of
the bits all set to 1s.
Example 5.26
The following addresses are defined using slash notations.
a) In the address 12.23.24.78/8, the network mask is 255.0.0.0. The mask has eight 1s and
twenty-four 0s. The prefix length is 8; the suffix length is 24.
b) In the address 130.11.232.156/16, the network mask is 255.255.0.0. The mask has sixteen
1s and sixteen 0s.The prefix length is 16; the suffix length is 16.
a) In the address 167.199.170.82/27, the network mask is 255.255.255.224. The mask has
twenty-seven 1s and five 0s. The prefix length is 27; the suffix length is 5.
Extracting Block Information
An address in slash notation (CIDR) contains all information we need about the block: the first
address (network address), the number of addresses, and the last address.
The number of addresses in the block can be found as:
N = 232-n
in which n is the prefix length and N is the number of addresses in the block.
The first address (network address) in the block can be found by ANDing the
address with the network mask:
First address = (any address) AND (network mask)
Alternatively, we can keep the n leftmost bits of any address in the block and set the 32− n bits
to 0s to find the first address.
The last address in the block can be found by either adding the first address with
the number of addresses or, directly, by ORing the address with the complement
(NOTing) of the network mask:
Last address = (any address) OR [NOT (network mask)]
Alternatively, we can keep the n leftmost bits of any address in the block and set the 32 − n bits
to 1s to find the last address.
Example
Subnetting
1. The number of addresses in each subnetwork should be a power of 2.
2. The prefix length for each subnetwork should be found using the following formula:
N sub = n + log2 (N/N sub)
3. The starting address in each subnetwork should be divisible by the number of addresses
in that subnetwork. This can be achieved if we first assign addresses to larger networks.
Ll
Example
An organization is granted the block 130.34.12.64/26. The organization needs four subnetworks,
each with an equal number of hosts. Design the subnetworks and find the information about each
network.
Solution
The number of addresses for the whole network can be found as N = 232 − 26 = 64. Using the
process described in the previous section, the first address in the network is 130.34.12.64/26 and
the last address is 130.34.12.127/26. We now design the subnetworks:
1. We grant 16 addresses for each subnetwork to meet the first requirement (64/16 is a
power of 2)
2. The subnetwork mask for each subnetwork is:
n1 = n2 = n3= n4 = n + log2 (N/Ni) = 26 + log24 = 28
3. We grant 16 addresses to each subnet starting from the first available address.