CN Unit III
CN Unit III
1.SWITCHING
The Internet is made of many networks (or links) connected through the connecting devices. In
other words, the Internet is an internetwork, a combination of LANs and WANs.
Packetizing
The first duty of the network layer is definitely packetizing: encapsulating the payload (data
received from upper layer in a network-layer packet at the source and decapsulating the payload
from the network-layer packet at the destination.
Routing
The network layer is responsible for routing the packet from its source to the destination. A
physical network is a combination of networks (LANs and WANs) and routers that connect
them. This means that there is more than one route from the source to the destination. The
network layer is responsible for finding the best one among these possible routes.
Forwarding
Forwarding can be defined as the action applied by each router when a packet arrives at one of
its interfaces. The decision-making table a router normally uses for applying this action is
sometimes called the forwarding table and sometimes the routing table. When a router receives
a packet from one of its attached networks, it needs to forward the packet to another attached
network (in unicast routing) or to some attached networks (in multicast routing).
2.PACKET SWITCHING
When the network layer provides a connectionless service, each packet traveling in the
Internet is an independent entity; there is no relationship between packets belonging to the
same message. The switches in this type of network are called routers. A packet belonging to a
message may be followed by a packet belonging to the same message or to a different message.
A packet may be followed by a packet coming from the same or from a different source.Each
packet is routed based on the information contained in its header: source and destination
addresses. The destination address defines where it should go; the source address defines
where it comes from. The router in this case routes the packet based only on the destination
address. The source address may be used to send an error message to the source if the packet
is discarded. Figure below shows the forwarding process in a router in this case. We have used
symbolic addresses such as A and B.
Data-Transfer Phase
The second phase is called the data-transfer phase. After all routers have created their
forwarding table for a specific virtual circuit, then the network-layer packets belonging to
one message can be sent one after another. In Figure below, we show the flow of a single
packet, but the process is the same for 1, 2, or 100 packets. The source computer uses the
label 14, which it has received from router R1 in the setup phase. Router R1 forwards the
packet to router R3, but changes the label to 66.Router R3 forwards the packet to router R4,
but changes the label to 22. Finally, router R4 delivers the packet to its final destination with
the label 77. All the packets in the message follow the same
sequence of labels, and the packets arrive in order at the destination.
Teardown Phase
In the teardown phase, source A, after sending all packets to B, sends a special packet called a
teardown packet. Destination B responds with a confirmation packet. All routers delete the
corresponding entries from their tables.
3. IPV4 ADDRESSES
*Draw the IPV4 Packet header format(Nov/Dec 2018)(13)
* Explain in detail about Subnetting and Supernetting(8)
An IPv4 address is a 32-bit address that uniquely and universally defines the connection of a
host or a router to theInternet.
Address Space
A protocol like IPv4 that defines addresses has an address space. An address space is the
total number of addressesused by the protocol. If a protocol uses b bits to define an address,
the address space is 2b because each bit can have two different values (0 or 1). IPv4 uses
32-bit addresses, which means that the address space is 232 or 4,294,967,296 (more than
four billion)
Notation
There are three common notations to show an IPv4 address:
1.Binary notation (base
2),dotted-decimal notation (base 256), and hexadecimal notation (base 16).
In binary notation, an IPv4 address is displayed as 32 bits. To make the address more
readable, one or more spaces are usually inserted between each octet (8 bits). Each
octet is often referred to as a byte. To make the IPv4 address more compact and easier
to read, it is usually written in decimal form with a decimal point (dot) separating the
bytes. This format is referred to as dotted-decimal notation. Note that because each
byte (octet) is only 8 bits,each number in the dtted-decimal notation is between 0 and
255. We sometimes see an IPv4 address in hexadecimal notation. Each hexadecimal
digit is equivalent to four bits.This means that a 32-bit address has 8hexadecimal digits.
Hierarchy in Addressing
A 32-bit IPv4 address is also hierarchical, but divided only into two parts. The first part
of the address, called the prefix, defines the network; the second part of the address,
called the suffix, defines the node (connection of a device to the Internet). The prefix
length is n bits and the suffix length is (32 - n) bits.
Classful Addressing
When the Internet started, an IPv4 address was designed with a fixed-length prefix, but
to accommodate both small and large networks, three fixed-length prefixes were
designed instead of one (n =8, n =16, and n =24). The whole address space was
divided into five classes (class A, B, C, D, and E), as shown in Figure 18.18. This scheme
is referred to as classful addressing.
In class A, the network length is 8 bits, but since the first bit, which is 0, defines the class,
we can have only seven bits as the network identifier.
This means there are only 27 =128 networks in the world that can have a class A address.
In class B, the network length is 16 bits, but since the first two bits, which are(10)2, define
the class, we can have only 14 bits as the network identifier. This means there are only
214 =16,384 networks in the world that can have a class B address. All addresses that
start with (110)2 belong to class C. In class C, the network
length is 24 bits, but since three bits define the class, we can have only 21 bits as the
network identifier. This means there are 221 = 2,097,152 networks in the world that
can have a class C address. Class D is not divided into prefix andsuffix. It is used for
multicast addresses. All addresses that start with 1111 in binary belong to class E. As in
Class D, Class E is not divided into prefix and suffix and is used as reserve.
Address Depletion
The reason that classful addressing has become obsolete is address depletion. Since the
addresses were not distributed properly, the Internet was faced with the problem of the
addresses being rapidly used up, resulting in no more addresses available for
organizations and individuals that needed to be connected to the Internet. To
understand the problem, let us think about class A. This class can be assigned to only 128
organizations in the world, but each organization needs to have a single network (seen
by the rest of the world) with 16,777,216 nodes (computers in this single network). Since
there may be only a few organizations that are this large, most of the addresses in this
class were wasted (unused). Class B addresses were designed for midsize organizations,
but many of the addresses in this class also remained unused. Class C addresses have a
completely different flaw in design. The number of addresses that can be used in each
network (256) was so small that most companies were not comfortable using a block in
this address class. Class E addresses were almost never used, wasting the whole class.
4.SUBNETTING
To alleviate address depletion, two strategies were proposed and, to some extent,
implemented: subnetting and supernetting. In subnetting, a class A or class B block is
divided into several subnets. Each subnet has a larger prefix length than the original
network. For example, if a network in class A is divided into four subnets, each subnet
has a prefix of nsub = 10. At the same time, if all of the addresses in a network are not
used, subnetting allows the addresses to be divided among several organizations. This
idea did not work because most large organizations were not happy about dividing the
block and giving some of the unused addresses to smaller organizations. While
subnetting was devised to divide a large block into smaller ones, supernetting was
devised to combine several class C blocks into a larger block to be attractive to
organizations that need more than the 256 addresses available in a class C block. This
idea did not work either because it makes the routing of packets more difficult.
Classless Addressing
Subnetting and supernetting in classful addressing did not really solve the address
depletion problem. With the growth of the Internet, it was clear that a larger address
space was needed as a long-term solution. The larger address space, however, requires
that the length of IP addresses also be increased, which means the format of the IP
packets needs to be changed.
In 1996, the Internet authorities announced a new architecture called classless
addressing. In classless addressing, variable-length blocks are used that belong to no
classes. We can have a block of 1 address, 2 addresses, 4 addresses, 128 addresses, and
so on.
In classless addressing, the whole address space is divided into variable length blocks.
The prefix in an address defines the block (network); the suffix defines the node (device).
Theoretically, we can have a block of 20, 21, 22,
…..232 addresses. One of the restrictions, as we discuss later, is that the number of
addresses in a block needs to be a power of 2. An organization can be granted one block of
addresses.
Prefix Length: Slash Notation
The first question that we need to answer in classless addressing is how to find the prefix
length if an address is given. Since the prefix length is not inherent in the address, we need
to separately give the length of the prefix. In this case, the prefix length, n, is added to the
address, separated by a slash. The notation is informally referred to as slash notation and
formally as classless interdomain routing or CIDR (pronounced cider) strategy.
Extracting Information from an Address
Given any address in the block, we normally like to know three pieces of information
about the block to which the address belongs: the number of addresses, the first address
in the block, and the last address. Since the value ofprefix length, n, is given, we can
easily find these three pieces of information.
1. The number of addresses in the block is found as N =232-n.
2. To find the first address, we keep the n leftmost bits and set the (32 - n)
rightmost bits all to 0s.
3. To find the last address, we keep the n leftmost bits and set the (32 - n) rightmost
bits all to 1s.
EXAMPLE:
A classless address is given as 167.199.170.82/27. We can find the
above three pieces of information as follows. The number of addresses
in the network is 232 - n = 25 = 32 addresses.
Address Mask
Another way to find the first and last addresses in the block is to use the address
mask.The address mask is a 32-bit number in which the n leftmost bits are set to 1s and
the rest of the bits (32 -n) are set to 0s. A computer can easily find the address mask
because it is the complement of (2 32 -n -1). The reason for defining a mask in this way
is that it can be used by a computer program to extract the information in a block, using
the three bit-wise operations NOT, AND, and OR.
1. The number of addresses in the block N =NOT (mask) +1.
2. The first address in the block =(Any address in the block) AND (mask).
3. The last address in the block =(Any address in the block) OR [(NOT
(mask)]. The mask in dotted-decimal notation is 256.256.256.224. The
AND, OR, and NOT operations can be applied toindividual bytes using
calculators
Address: 167.199.170.82/27 10100111 11000111 10101010 01010010
First address: 167.199.170.64/27 10100111 11000111 10101010 01000000
Address: 167.199.170.82/27 10100111 11000111 10101010 01011111
Last address: 167.199.170.95/27 10100111 11000111 10101010 01011111
5.IPv6
PROTOCOL
IPv6 ADDRESSING
*Draw the IPV6 packet header format
The main reason for migration from IPv4 to IPv6 is the small size of the address space
in IPv4. An IPv6 address is128 bits or 16 bytes (octets) long, four times the address
length in IPv4. An IPv6 address is 128 bits or 16 bytes (octets) long, four times the
address length in IPv4.
Abbreviation
Although an IPv6 address, even in hexadecimal format, is very long, many of the digits are
zeros. In this case, we can abbreviate the address. The leading zeros of a section can be omitted.
Using this form of abbreviation, 0074 can be written as 74, 000F as F, and 0000 as
0. Note that 3210 cannot be abbreviated. Further abbreviation, often called zero
compression, can be applied to colon hex notation if there are consecutive sections
consisting of zeros only. We can remove all the zeros and replace them with a double
semicolon.
Address Space
The address space of IPv6 contains 2128 addresses. This address space is 296 times the IPv4
address—definitely no address depletion—as shown, the size of the space is
Packet Format
Each packet is composed of a base header followed by the payload. The base header occupies
40 bytes, whereas payload can be up to 65,535 bytes of information. The description of fields
follows.
Version. The 4-bit version field defines the version number of the IP. For IPv6, the value is 6.
● Traffic class. The 8-bit traffic class field is used to distinguish different payloads with
different deliveryrequirements. It replaces the type-of-service field in IPv4.
● Flow label. The flow label is a 20-bit field that is designed to provide special handling
for a particular flow of data. We will discuss this field later.
● Payload length. The 2-byte payload length field defines the length of the IP datagram
excluding the header. Note that IPv4 defines two fields related to the length: header length
and total length. In IPv6, the length of the baseheader is fixed (40 bytes); only the length of
the payload needs to be defined.
● Next header. The next header is an 8-bit field defining the type of the first extension
header (if present) or the type of the data that follows the base header in the datagram. This
field is similar to the protocol field in IPv4
● Hop limit. The 8-bit hop limit field serves the same purpose as the TTL field in IPv4.
● Source and destination addresses. The source address field is a 16-byte (128-bit)
Internet address that identifies the original source of the datagram. The destination address
field is a 16-byte (128-bit) Internet address that identifies the destination of the datagram.
● Payload. Compared to IPv4, the payload field in IPv6 has a different format and
meaning, as shown in Figure below.
6.ARP
ARP Operation
For example: in Ethernet, MAC header ’ s destination address is all 1s (broadcast address)
Received by every station on the physical network
Packet Format
● HTYPE (Hardware type):16-bit field defining the underlying type of the network
o Ethernet is given the type 1
o ARP can be used on any physical network
● HLEN (Hardware length) : 8-bit field defining the length of the physical address in
bytes
o Ethernet has the value of 6
● PLEN (Protocol length) :8-bit field defining the length of the logical address in bytes
o IPv4 has the value of 4 o OPER (Operation) n 16-bit field defining the type of
packet n (1) = ARP request, (2) = ARP reply
● SPA (Sender protocol address) : A variable-length field defining the logical address
of the sender
● For an ARP request operation packet o This field is all 0s o TPA (Target protocol
address) n A variable-length field defining the logical address of the target
Case 1: The sender is a host and wants to send a packet to another host on the same
network
Use ARP to find another host’ s physical address
Case 2: The sender is a host and wants to send a packet to another host on another network
Sender looks at its routing table
Find the IP address of the next hop (router) for this destination
Use ARP to find the router ’ s physical address
Case 3: the sender is a router and received a datagram destined for a host on another
network
Router check its routing table
Find the IP address of the next router
Use ARP to find the next router ’ s physical address
Case 4: the sender is a router that has received a datagram destined for a host in the same
network
Use ARP to find this host’ s physical address
Proxy ARP
● Whenever the the router running a proxy ARP receives an ARP request looking for
the IP address of one of these hosts, the router sends an ARP reply announcing its
own hardware(physical) address.
● Later when the router receives the actual IP packet, it will send the packet to the
appropriate host or router.
ARP DESIGN
– A cache table
–A queues
–A cache-control module
Cache Table
When a host or router receives the corresponding physical address for IP datagram,
the address can be saved in the cache table.
This address can be used for the datagram destined for the same receiver within the
next few minutes.
Cache Table.. .
The cache table is implemented as an array of entries, In our design, each entry contains
the following fields:
State: This column shows the state of the entry. It can have one of three values:
FREE: The time-to-live for this entry has expired. The space can be used for a new entry.
PENDING: A request for this entry has been sent, but the reply has not yet been received. –
RESOLVED: The entry is complete. The entry now has the physical address of the
destination. The packets waiting to be sent this destination can use information in this
entry.
Hardware type : This field is the same as corresponding field in the ARP packet.
Protocol type: This field is the same as corresponding field in the ARP packet.
Hardware length : This field is the same as corresponding field in the ARP packet.
Protocol length : This field is the same as corresponding field in the ARP packet.
Interface number: A router (or multihomed host) can be connected to different networks,
each with a different interface number. Each networks can have different hardware and
protocol types.
Queue number: ARP uses different queues to enqueue the packets waiting for address
resolution. Packets for the same destination are usually enqueued in the same queue. The
queue number refers to the queue whose packets are waiting for this entry to be resolved.
Attempts : This column shows how many times an ARP requesu is sent out for this entry.
Hardware address : This column shows the destination hardware address. It remains
empty until resolved by an ARP reply.
Queues
The ARP package maintains a set of queues, one for each destination, to hold the IP packets
while ARP tries to resolve the hardware address.
The output module sends unresolved packets into the corresponding queue.
The input module removes a packet from a queue and sends it, with the resolved physical
address, to the data link layer for transmission.
OUTPUT MODULE
Cache-Control Module
1.Sleep until the periodic timer matures.
2.For every entry in the cache table.
1.If (the state is FREE)
1.Continue.
2.If (the state is PENDING)
1.Increment the value of attempts by 1.
2.If (attempts greater than maxium)
1.Change the state to FREE
2.Destroy the corresponding queue.
3.If (not) 1.Send an ARP request.
4.Continue.
3.If (the state is RESOLVED)
1.Decrement the value of time-out by the value of elapsed time.
2.If (time-out less than or equal to zero)
1.Change the state to FREE
2.Destroy the corresponding queue.
3.Return.
7.RARP
● The RARP is designed to resolve the address mapping problem in which a machine
knows its physical address but does not know its logical address.
● To create an IP datagram, a host or a router needs to know its own IP address or
address.
● The IP address of a machine is usually read from its configuration file stored on a disk
file.
● However, a diskless machine is usually booted from ROM, which has minimum
booting information.
● The machine can get its physical address (by reading its NIC, for example), which is
unique locally. It can then use the physical address to get the logical address using the
RARP protocol.
● A ARP request is created and broadcast on the local network.
● Another machine on the local network that knows all the IP address will respond with
RARP reply.
RARP Packet
Encapsulation of RARP Packet
8.ICMP
The IP protocol has no error-reporting or error correcting mechanism. The IP protocol also
lacks a mechanism for host and management queries. The Internet Control Message Protocol
(ICMP) has been designed to compensate for the above two deficiencies. It is a companion to
the IP protocol.
General format of ICMP messages
Types of Messages
Error-reporting messages
Echo Request and Reply: The echo-request and echo-reply messages are designed for
diagnostic purposes
Timestamp Request and Reply Two machines (hosts or routers) can use the timestamp
request and timestamp reply messages to determine the round-trip time needed for an IP
datagram to travel between them. It can also be used to synchronize the clocks in two
machines
A host may know its IP address, but it may not know the corresponding mask.
A host that wants to send data to a host on another network needs to know the address of
routers connected to its own network.
checksum In ICMP the checksum is calculated over the entire message (header and data).
Message Type
DHCP Operation
• DCHP DISCOVER
• DCHP OFFER
• DCHP RELEASE
• DCHP DISCOVER
• At this time, the DHCP client can start to use the IP address
• Renewing a Lease(sent when 50% of lease has expired)