You are on page 1of 22

CHAPTER 7

Internet Protocol and IP addressing


Internet Protocol
The Internet's network layer does not provide a virtual-circuit service, but instead a
connectionless datagram service. When the network layer at the sending host receives a
segment from the transport layer, it encapsulates the segment within an IP datagram, writes
the destination address of the host (as well as other fields) on the datagram, and drops the
datagram into the network.
 The network layer for a datagram network, such as the Internet, has two major
components.
 First, it has a network protocol component, which defines network-layer
addressing,
 The fields in the datagram (i.e., the network layer PDU), and how the end
systems and routers act on these fields. The network protocol in the Internet is
called the Internet Protocol, or more commonly, the IP Protocol.

TCPI IP and OSI model

Compiled By: Mr.Abdisa L. MTU Dept of CS


Page 1
1
TCP/IP is a hierarchical protocol made up of interactive modules, each of which provides a
specific functionality; however, the modules are not necessarily interdependent. Whereas the
OSI model specifies which functions belong to each of its layers, the layers of the TCP/IP
protocol suite contain relatively independent protocols that can be mixed and matched depending
on the needs of the system. The term hierarchical means that each upper-level protocol is
supported by one or more lower-level protocols.

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.

Physical and Data Link Layers


At the physical and data link layers, TCPIIP does not define any specific protocol. It supports all
the standard and proprietary protocols. A network in a TCPIIP internetwork can be a local-area
network or a wide-area network.
Network Layer
At the network layer (or, more accurately, the internetwork layer), TCP/IP supports the
Internetworking Protocol. IP, in turn, uses four supporting protocols: ARP, RARP, ICMP, and
IGMP.

Internetworking Protocol (IP)


The Internetworking Protocol (IP) is the transmission mechanism used by the TCP/IP
protocols. It is an unreliable and connectionless protocol-a best-effort delivery service. The term
best effort means that IP provides no error checking or tracking. IP assumes the unreliability of
the underlying layers and does its best to get a transmission through to its destination, but with
no guarantees.
IP transports data in packets called datagrams, each of which is transported separately.
Datagrams can travel along different routes and can arrive out of sequence or be duplicated. IP
does not keep track of the routes and has no facility for reordering datagrams once they arrive at
their destination. The limited functionality of IP should not be considered a weakness, however.
IP provides bare-bones transmission functions that free the user to add only those facilities
necessary for a given application and thereby allows for maximum efficiency.
Address Resolution Protocol
The Address Resolution Protocol (ARP) is used to associate a logical address with a physical
address. On a typical physical network, such as a LAN, each device on a link is identified by a
physical or station address, usually imprinted on the network interface card (NIC). ARP is used
to find the physical address of the node when its Internet address is known.
Reverse Address Resolution Protocol
Compiled By: Mr.Abdisa L. MTU Dept of CS
Page 2
2
The Reverse Address Resolution Protocol (RARP) allows a host to discover its Internet address
when it knows only its physical address. It is used when a computer is connected to a network
for the first time or when a diskless computer is booted.
Internet Control Message Protocol
The Internet Control Message Protocol (ICMP) is a mechanism used by hosts and gateways to
send notification of datagram problems back to the sender. ICMP sends query and error reporting
messages.
Internet Group Message Protocol
The Internet Group Message Protocol (IGMP) is used to facilitate the simultaneous transmission
of a message to a group of recipients.
Transport Layer
Traditionally the transport layer was represented in TCP/IP by two protocols: TCP and UDP. IP
is a host-to-host protocol, meaning that it can deliver a packet from one physical device to
another. UDP and TCP are transport level protocols responsible for delivery of a message from a
process (running program) to another process. A new transport layer protocol, SCTP, has been
devised to meet the needs of some newer applications.
User Datagram Protocol
The User Datagram Protocol (UDP) is the simpler of the two standard TCPIIP transport
protocols. It is a process-to-process protocol that adds only port addresses, checksum error
control, and length information to the data from the upper layer.
Transmission Control Protocol
The Transmission Control Protocol (TCP) provides full transport-layer services to applications.
TCP is a reliable stream transport protocol. The term stream, in this context, means connection-
oriented: A connection must be established between both ends of a transmission before either can
transmit data. At the sending end of each transmission, TCP divides a stream of data into smaller
units called segments. Each segment includes a sequence number for reordering after receipt,
together with an acknowledgment number for the segments received. Segments are carried
across the internet inside of IP datagrams. At the receiving end, TCP collects each datagram as it
comes in and reorders the transmission based on sequence numbers.
Stream Control Transmission Protocol
The Stream Control Transmission Protocol (SCTP) provides support for newer applications such
as voice over the Internet. It is a transport layer protocol that combines the best features of UDP
and TCP.

Compiled By: Mr.Abdisa L. MTU Dept of CS


Page 3
3
IP ADDRESSING
The IPv4 addresses are unique and universal.
Four levels of addresses are used in an internet employing the TCP/IP protocols:
 physical (link) addresses
 logical (IP) addresses
 port addresses and
 Specific addresses

Each address is related to a specific layer in the TCPIIP architecture.

Compiled By: Mr.Abdisa L. MTU Dept of CS


Page 4
4
Relationship of layers and addresses in TCPIIP
1. Physical Addresses
The physical address, also known as the link address, is the address of a node as defined by its
LAN or WAN. It is included in the frame used by the data link layer. It is the lowest-level
address. The physical addresses have authority over the network (LAN or WAN). The size and
format of these addresses vary depending on the network. For example, Ethernet uses a 6-byte
(48-bit) physical address that is imprinted on the network interface card (NIC). Local Talk
(Apple), however, has a I-byte dynamic address that changes each time the station comes up.
Example.

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

Compiled By: Mr.Abdisa L. MTU Dept of CS


Page 5
5
The physical addresses will change from hop to hop, but the logical addresses usually remain the same.
3. Port Addresses
The IP address and the physical address are necessary for a quantity of data to travel from a
source to the destination host. However, arrival at the destination host is not the final objective of
data communications on the Internet. A system that sends nothing but data from one computer to
another is not complete. Today, computers are devices that can run multiple processes at the
same time. The end objective of Internet communication is a process communicating with
another process. For example, computer A can communicate with computer C by using
TELNET. At the same time, computer A communicates with computer B by using the File
Transfer Protocol (FTP). For these processes to receive data simultaneously, we need a method
to label the different processes. In other words, they need addresses. In the TCPIIP architecture,
the label assigned to a process is called a port address. A port address in TCPIIP is 16 bits in
length. Example

Compiled By: Mr.Abdisa L. MTU Dept of CS


Page 6
6
The physical addresses change from hop to hop, but the logical and port addresses usually remain the
same. A port address is a 16-bit address represented by one decimal number.

4. Specific Addresses
Some applications have user-friendly addresses that are designed for that specific address. Examples
include the e-mail address (for example, ethio@gmail.com) 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

3. Find the error, if any, in the following IPv4 addresses.


a) 111.56.045.78
b) 221.34.7.8.20
c) 75.45.301.14
d) 11100010.23.14.67
Solution
a) There must be no leading zero (045).
b) There can be no more than four numbers in an IPv4 address.
c) Each number needs to be less than or equal to 255 (301 is outside this range).
Compiled By: Mr.Abdisa L. MTU Dept of CS
Page 8
8
d) A mixture of binary notation and dotted-decimal notation is not allowed.

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

 addresses in class D are for multicast communication (only as a destination); if a host


belongs to a group or groups, it can have one or more multicast addresses
 addresses in class E are reserved; the idea was to use them for special purposes
 Classes and Blocks
 one problem with classful addressing is that each class is divided into a fixed
number of blocks with each block having a fixed size
Class A
 divided into 128 blocks, each block having a different netid (the first bit of byte 1 is
always 0)
 block 1: from 0.0.0.0 to 0.255.255.255 - netid 0
 block 2: from 1.0.0.0 to 1.255.255.255 - netid 1
.
.
 last block: from 127.0.0.0 to 127.255.255.255 - netid 127
 class A addresses were designed for large organizations (up to 16 million hosts 224)

 e.g. organization X granted a block with netid 73


 the first address (73.0.0.0) is used to identify the organization (called the network
address)
 the last address is reserved for a special purpose
 total number of organizations that can be assigned class A addresses is 126 (128-2)
because all 0’s and 1’s are reserved
 the number of addresses in each block (16,777,214= 224-2) are larger than the needs
of almost all organizations
 millions of class A addresses are wasted

Compiled By: Mr.Abdisa L. MTU Dept of CS


Page 9
9
Class B
 divided into 16,384 (214) blocks, each block having a different netid (the first two bits of
byte 1 are always 10)
 block 1: from 128.0.0.0 to 128.0.255.255 - netid 128.0
 block 2: from 128.1.0.0 to 128.1.255.255 - netid 128.1
.
.
 last block: from 191.255.0.0 to 191.255.255.255 - netid 191.255
 16 blocks are reserved for private addresses
 total number of organizations that can be assigned class B addresses is 16,368 (16,384-
16)
 class B addresses were designed for midsize organizations (up to 65,534 = 216-2 hosts)
 the number of addresses in each block is larger than the needs of most midsize
organizations
 many class B addresses are wasted

Compiled By: Mr.Abdisa L. MTU Dept of CS


Page 10
10
Class C
 divided into 2,097,152 (221) blocks, each block having a different netid (the first three
bits of byte 1 are always 110)
 block 1: from 192.0.0.0 to 192.0.0.255 - netid 192.0.0
 block 2: from 192.0.1.0 to 192.0.1.255 - netid 192.0.1
.
.
 last block: from 223.255.255.0 to 223.255.255.255 - netid 223.255.255
 256 blocks are used for private addresses
 total number of organizations that can be assigned class C addresses is 2,096,902
(2,097,152-256)
 class C addresses were designed for small organizations (up to 254 = 28-2 hosts)
 the number of addresses in each block is so limited that most organizations do not want
a block in this class

Compiled By: Mr.Abdisa L. MTU Dept of CS


Page 11
11
Class D: there is just one block of class D addresses; designed for multicasting
Class E: there is just one block of class E addresses; designed for use as reserved addresses; for
research by IETF (Internet Engineering Task Force) it develops Internet standards

Netid and Hostid


In classful addressing, an IP address in classes A, B, and C is divided into netid and hostid.
These parts are of varying lengths, depending on the class of the address. Note that classes D and
E are not divided into netid and hostid.

Compiled By: Mr.Abdisa L. MTU Dept of CS


Page 12
12
Compiled By: Mr.Abdisa L. MTU Dept of CS
Page 13
13
IP addresses can be divided into 5 classes. There are 3 primary classes, A, B, and C, used for
host addresses. Class D is used for multicasting which allows delivery to a set of computers.
Class E is reserved for future use.
1. Find the class of each address.
a) 00000001 00001011 00001011 11101111
b) 11000001 10000011 00011011 11111111
c) 14.23.120.8
d) 252.5.15.111
Solution
a. The first bit is O. This is a class A address.
b. The first 2 bits are 1; the third bit is O. This is a class C address.
c. The first byte is 14 (between 0 and 127); the class is A.
d. The first byte is 252 (between 240 and 255); the class is E.

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.

 How can a router find the network address or subnet address?


 a 32-bit number called the mask is used; routers outside the organization use a default
mask; routers inside the organization use a subnet mask
 default mask: a 32-bit binary number that gives the network address when ANDed with an
address in the block; the number of 1s is the same as the number of bits in the netid ( 8 for
A, 16 for B, 24 for C); the rest are all 0
 slash notation: an alternative mask notation, a slash followed by the number of 1s
Using
Class In Binary In Dotted-Decimal
Slash

A 11111111 00000000 00000000 00000000 255.0.0.0 /8

B 11111111 11111111 00000000 00000000 255.255.0.0 /16

C 11111111 111111111 11111111 00000000 255.255.255.0 /24

Compiled By: Mr.Abdisa L. MTU Dept of CS


Page 14
14
Subnetting
 the netid is used by routers to route a packet destined for a network
 IP addresses are designed with two levels of hierarchy (site and host) a network with

two levels of hierarchy


 all the hosts in a network must have the same netid
 problem: does not allow dividing of a network into logical groups (such as
Departments in a University)
 solution 1: get netids for all groups; impossible
 solution 2: allow a network to be split into several parts for internal use but still
act like a single network to the outside world (three levels of hierarchy: site,
subnet, host)

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.

Compiled By: Mr.Abdisa L. MTU Dept of CS


Page 15
15
Classless Addressing
 there is too much wastage of IP addresses in classful addressing creating shortage of IP
addresses
 classless addressing was announced in 1996
 the idea of variable-length blocks that belong to no class was introduced to allocate the
remaining IP addresses
 blocks of 2 addresses, 4 addresses, 64 addresses, ... can be assigned to an organization
based on size
 the number of addresses in a block must be a power of 2
 the whole address space (232 addresses) is divided into blocks of different sizes
 the beginning address must be evenly divisible by the number of addresses;
 In classless addressing, the whole address space is divided into variable length
blocks
 Theoretically, we can have a block of 20, 21, 23 . . . 232 addresses.

 In classless addressing, the prefix defines the network and the suffix defines the
host.

 The prefix length in classless addressing can be 1 to 32.

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

Compiled By: Mr.Abdisa L. MTU Dept of CS


Page 16
16
In this case, the prefix length is 0 and the suffix length is 32. All 32 bits vary to define 232 =
4,294,967,296 hosts in this single block.

 we can still use Subnetting if there is a need


 an organization is given the beginning address of the block and a mask (in slash
notation)
 classless addressing alleviates the depletion of addresses, but we now need a new
method of forwarding packets, called CIDR (Classless Inter Domain Routing)
 there is now a single routing table for all networks consisting of an array of (IP
address, subnet mask, outgoing line) triples
 when a packet comes in, its destination IP address is first extracted; the routing
table is then scanned entry by entry, masking the destination address and
comparing it to the table entry looking for a match

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

Compiled By: Mr.Abdisa L. MTU Dept of CS


Page 18
18
One of the addresses in a block is 17.63.110.114/24. Find the number of addresses, the first
address, and the last address in the block.
Solution
The network mask is 255.255.255.0.
a. The number of addresses in the network is 232 - 24 = 256.
b. To find the first address, the first address is 17.63.110.0/24.
c. To find the last address, we use the complement of the network mask and the first short
cut method we discussed before. The last address is 17.63.110.255/24.

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.

Compiled By: Mr.Abdisa L. MTU Dept of CS


Page 19
19
IPv5
 Is (was) there IPv5?
 yes, it was an experimental real-time stream protocol that was never widely used
 was designed to coexist with IPv4, not a replacement
IPv6
 the major goals are
 Larger address space: to support billions of hosts, even with inefficient
address space allocation (2128 of them - if the entire earth, land and water, were
covered with computers, IPv6 would allow 7 x 1023 IP addresses per square
meter - Tannenbaum)
 Better header format: to simplify and speed-up the routing process
 Better security: better encryption and authentication options
 Support for resource allocation: to deal with the special requirements of
real-time data (audio and video)
 Allowance for extension: to allow the extension of the protocol if required by
new technologies or applications in the future
 Coexistence: permit the old and new protocols to coexist for years
 IPv6 header has 8 fields (40 bytes long)
 Version (4 bits): is always 6 for IPv6 (and 4 for IPv4)
 Traffic class (4 bits): used to distinguish between packets with different real-
time delivery requirements
Compiled By: Mr.Abdisa L. MTU Dept of CS
Page 20
20
 Flow label (24 bits): to provide special handling for a particular flow of data;
for example, to reserve bandwidth because of some delay requirements

 IPv6 address notation


 hexadecimal colon notation: written as eight groups (each 2 bytes) of four
hexadecimal digits with colons between the groups
8000:0000:0000:0000:0123:4567:89AB: CDEF
 many addresses usually will have many zeros
 three abbreviation methods
 leading zeros (not the trailing ones) within a group can be omitted; 0123 can be
written as 123
 one or more groups of 16 zero bits can be replaced by a pair of colons; the above
address now becomes
8000: 123:4567:89AB: CDEF
 it is allowed only once per address (if there are two runs of zero sections, only
one of them can be abbreviated)
Compiled By: Mr.Abdisa L. MTU Dept of CS
Page 21
21
 IPv4 addresses can be written as a pair of colons and an old dotted decimal
number, for example
::192.31.20.46
Read about IP as a Routed Protocol and Packet Propagation

Compiled By: Mr.Abdisa L. MTU Dept of CS


Page 22
22

You might also like