N&S Unit 2
N&S Unit 2
N&S Unit 2
Network Layer – IPv4 Addressing – Network Layer Protocols (IP, ICMP and Mobile IP)- Unicast and
Multicast Routing – Intradomain and Interdomain Routing Protocols – IPv6 Addresses – IPv6 –
Datagram Format - Transition from IPv4 to IPv6.
Network Layer:
The network layer is involved at the source host, destination host, and all routers in the path.
At the source host (Alice), the network layer accepts a packet from a transport layer,
encapsulates the packet in a datagram, and delivers the packet to the data-link layer
At the destination host (Bob), the datagram is decapsulated, and the packet is extracted and
delivered to the corresponding transport layer
IPv4 Addressing:
An IPv4 address is a 32-bit address that uniquely and universally defines the connection of a
device (for example, a computer or a router) to the Internet
IPv4 addresses are unique. They are unique in the sense that each address defines one, and
only one, connection to the Internet.
Two devices on the Internet can never have the same address at the same time
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.
A prefix can be fixed length or variable length.
The scheme which uses fixed length prefix is called as classful addressing and the scheme
which uses variable-length network prefix is referred to as classless addressing
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).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.
Example:
c. 201.24.44.32
11001001 00011000 00101100 00100000
Address Depletion:
In the Internet if the addresses were not distributed properly, the Internet was faced
with the problem of the addresses being rapidly used up.
For an Example consider class A address in this 128 organizations connected and each
organization allowed to use with 16,777,216 nodes (232). Since there may be only a few
organizations that are this large, most of the addresses in this class were wasted.
Class B addresses was 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. C
Class E addresses were almost never used, wasting the whole class.
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.
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
For the given an address, we can easily find the class of the address and, since the prefix
length for each class is fixed, we can find the prefix length immediately.
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
In classless addressing, the whole address space is divided into variable length blocks.
The prefix in an address defines the block
Theoretically, there is a block of 20, 21 , 22 , ..., 232 addresses.
An organization can be granted one block of addresses
Internet Protocol version 4 (IPv4), is responsible for packetizing, forwarding, and delivery of a
packet at the network layer
IPv4 is an unreliable datagram protocol—a best-effort delivery service.
The term best-effort means that IPv4 packets can be corrupted, be lost, arrive out of order, or
be delayed, and may create congestion for the network.
IPv4 is also a connectionless protocol that uses the datagram approach.
Packets used by the IP are called datagrams.
Each datagram is handled independently, and each datagram can follow a different route to the
destination
Datagram Format:
IPv4 defines the format of a packet in which the data coming from the upper layer or other
protocols are encapsulated
A datagram is a variable-length packet consisting of two parts: header and payload (data).
The header is 20 to 60 bytes in length and contains information essential to routing and
delivery.
Header Length:
The 4-bit header length (HLEN) field defines the total length of the datagram header in 4-
byte words. The IPv4 datagram has a variable-length header.
When a device receives a datagram, it needs to know when the header stops and the data,
which is encapsulated in the packet, starts.
However, to make the value of the header length (number of bytes) fit in a 4-bit header
length, the total length of the header is calculated as 4-byte words.
The total length is divided by 4 and the value is inserted in the field. The receiver needs to
multiply the value of this field by 4 to find the total length.
Service:
In the original design of the IP header, this field was referred to as type of service (TOS),
which defined how the datagram should be handled.
Total Length.
This 16-bit field defines the total length (header plus data) of the IP datagram in bytes.
A 16-bit number can define a total length of up to 65,535 (when all bits are 1s). However,
the size of the datagram is normally much less than this.
This field helps the receiving device to know when the packet has completely arrived.
To find the length of the data coming from the upper layer, subtract the header length from
the total length.
The header length can be found by multiplying the value in the HLEN field by 4.
Length of data = total length − (HLEN) × 4
Identification, Flags, and Fragmentation Offset.
These three fields are related to the fragmentation of the IP datagram when the size of
the datagram is larger than the underlying network can carry.
Time-to-live.
Due to some malfunctioning of routing protocols a datagram may be circulating in the
Internet, visiting some networks over and over without reaching the destination.
This may create extra traffic in the Internet.
The data section in error messages carries information for finding the original packet
that had the error. In query messages, the data section carries extra information based
on the type of query
Error Reporting Messages
Since IP is an unreliable protocol, one of the main responsibilities of ICMP is to report
some errors that may occur during the processing of the IP datagram.
ICMP does not correct errors, it simply reports them.
Error correction is left to the higher-level protocols.
Error messages are always sent to the original source because the only information
available in the datagram about the route is the source and destination IP addresses.
ICMP uses the source IP address to send the error message to the source (originator) of
the datagram.
To make the error-reporting process simple, ICMP follows some rules in reporting
messages
Destination Unreachable
The most widely used error message is the destination unreachable (type 3).
This message uses different codes (0 to 15) to define the type of error message and the
reason why a datagram has not reached its final destination
Source Quench
It informs the sender that the network has encountered congestion and the datagram
has been dropped; the source needs to slow down sending more datagrams
Redirection Message
The redirection message (type 5) is used when the source uses a wrong router to send
out its message.
The router redirects the message to the appropriate router, but informs the source that
it needs to change its default router in the future. The IP address of the default router is
sent in the message.
Parameter Problem
Mobile IP has two addresses for a mobile host: one home address and one care-of
address. The home address is permanent; the care-of address changes as the mobile
host moves from one network to another
Agents
To make the change of address transparent to the rest of the Internet requires a home
agent and a foreign agent.
Home Agent
The home agent is usually a router attached to the home network of the
mobile host. The home agent acts on behalf of the mobile host when a
remote host sends a packet to the mobile host.
The home agent receives the packet and sends it to the foreign agent.
Foreign Agent
The foreign agent is usually a router attached to the foreign network. The
foreign agent receives and delivers packets sent by the home agent to the
mobile host.
When the mobile host acts as a foreign agent, the care-of address is called a
collocated care-of address.
Three Phases
To communicate with a remote host, a mobile host goes through three phases: agent
discovery, registration, and data transfer
Lifetime.
This field defines the number of seconds the registration is valid. If the field is a
string of 0s, the request message is asking for deregistration. If the field is a string of 1s,
the lifetime is infinite.
Home address. This field contains the permanent (first) address of the mobile host.
Home agent address. This field contains the address of the home agent.
Care-of address. This field is the temporary (second) address of the mobile host.
Identification. This field contains a 64-bit number that is inserted into the request by the
mobile host and repeated in the reply message. It matches a request with a reply.
Extensions. Variable length extensions are used for authentication
Unicast Routing:
In unicast routing, a packet is routed, hop by hop, from its source to its destination by the help
of forwarding tables.
The source host needs no forwarding table because it delivers its packet to the default router in
its local network.
The destination host needs no forwarding table because it receives the packet from its default
router in its local network.
Routing a packet from its source to its destination means routing the packet from a source
router to a destination router.
Least-Cost Routing
When an internet is modeled as a weighted graph, one of the ways to interpret the best route from the
source router to the destination router is to find the least cost between the two.
That is, the source router chooses a route to the destination router in such a way that the total cost for
the route is the least cost among all possible routes.
Routing Table:
To route a packet in the network a host or a router has a routing table with an entry for
each destination, or a combination of destinations, to route IP packets.
The routing table can be either static or dynamic.
Static Routing Table
A static routing table contains information entered manually.
The administrator enters the route for each destination into the table. When a table is created,
it cannot update automatically when there is a change in the Internet.
The table must be manually altered by the administrator.
A static routing table can be used in a small internet that does not change very often.
Dynamic Routing Table
A dynamic routing table is updated periodically by using one of the dynamic routing protocols
such as RIP, OSPF, or BGP.
Whenever there is a change in the Internet, such as a shutdown of a router or breaking of a link,
the dynamic routing protocols update all the tables in the routers automatically.
Distance Vector Routing:
In distance vector routing, the least-cost route between any two nodes is the route with
minimum distance
In distance-vector routing, the first thing each node creates is its own least-cost tree with the
limited information it has about its immediate neighbors.
The incomplete trees are exchanged between immediate neighbors to make the trees more and
more complete and to represent the whole internet.
In distance-vector routing, a router continuously tells all of its neighbors what it knows about
the whole internet
A least-cost tree is a combination of least-cost paths from the root of the tree to all destinations.
These paths are graphically fix together to form the tree.
Distance-vector routing unfixes these paths and creates a distance vector, a one-dimensional
array to represent the tree
Example: Consider the graph shown in figure
After each node has created its vector, it sends a copy of the vector to all its immediate
neighbors.
After a node receives a distance vector from a neighbor, it updates its distance vector
using the Bellman-Ford equation
Consider the figure, In the first event, node A has sent its vector to node B. Node B
updates its vector using the cost CBA = 2. In the second event, node E has sent its vector
to node B. Node B updates its vector using the cost CEA = 4.
After the first event, node B has one improvement in its vector: its least cost to node D
has changed from infinity to 5 (via node A). After the second event, node B has one
more improvement in its vector; its least cost to node F has changed from infinity to 6
(via node E).
Count to Infinity:
A problem with distance-vector routing is that any decrease in cost propagates quickly,
but any increase in cost will propagate slowly.
Example:
Consider the graph shown in Figure
Initialization Table:
In the distance-vector routing algorithm, each router tells its neighbors what it knows
about the whole internet. In the link-state routing algorithm, each router tells the
whole internet what it knows about its neighbors.
Intradomain Protocols:
Routing Information Protocol (RIP):
Forwarding Tables
A forwarding table in RIP is a three-column table in which the first column is the
address of the destination network, the second column is the address of the next
router to which the packet should be forwarded, and the third column is the cost (the
number of hops) to reach the destination network.
RIP Implementation:
RIP is implemented as a process that uses the service of UDP on the well-known port
number 520.
RIP has gone through two versions: RIP-1 and RIP-2. The second version is backward
compatible with the first section; it allows the use of more information in the RIP
messages that were set to 0 in the first version.
RIP Messages:
Two RIP processes, a client and a server, like any other processes, need to exchange
messages
Forwarding Tables
Each OSPF router can create a forwarding table after finding the shortest-path tree between
itself and the destination using Dijkstra’s algorithm
Compared with RIP, which is normally used in small ASs, OSPF was designed to be able to handle
routing in a small or large autonomous system.
However, the formation of shortest-path trees in OSPF requires that all routers flood the whole
AS with their LSPs to create the global LSDB.
The routers in the backbone area are responsible for passing the information collected by each
area to all other areas
OSPF is based on the link-state routing algorithm, which requires that a router advertise the
state of each link to all neighbors for the formation of the LSDB.
There are five types of link-state advertisements are there: router link, network link, summary
link to network, summary link to AS border router, and external link.
OSPF Messages:
OSPF is a very complex protocol; it uses five different types of messages.
The hello message (type 1) is used by a router to introduce itself to the neighbors and announce
all neighbors that it already knows.
The database description message (type 2) is normally sent in response to the hello message to
allow a newly joined router to acquire the full LSDB.
The linkstate request message (type 3) is sent by a router that needs information about a
specific LS.
The eBGP variation of BGP allows two physically connected border routers in two different ASs
to form pairs of eBGP speakers and exchange messages.
The first message (numbered 1) is sent by R1 announcing that networks N8 and N9 are
reachable through the path AS1-AS2, but the next router is R1.
This message is sent, through separate sessions, to R2, R3, and R4. Routers R2, R4, and
R6 do the same thing but send different messages to different destinations.
The interesting point is that, at this stage, R3, R7, and R8 create sessions with their
peers, but they actually have no message to send.
After R1 receives the update message from R2, it combines the reachability information
about AS3 with the reachability information it already knows about AS1 and sends a
new update message to R5.
Now R5 knows how to reach networks in AS1 and AS3. The process continues when R1
receives the update message from R4
IPv6 uses hierarchical addressing. The address space of IPv6 contains 2128 addresses.
This address space is 296 times the IPv4 address—definitely no address depletion
Address Types
In IPv6, a destination address can belong to one of three categories: unicast, anycast, and
multicast.
Unicast Address
A unicast address defines a single interface (computer or router).
The packet sent to a unicast address will be routed to the intended recipient.
Anycast Address
An anycast address defines a group of computers that all share a single address.
A packet with an anycast address is delivered to only one member of the group, the
most reachable one. An anycast communication is used, for example, when there are
several servers that can respond to an inquiry.
The request is sent to the one that is most reachable. The hardware and software
generate only one copy of the request; the copy reaches only one of the servers.
IPv6 does not designate a block for anycasting; the addresses are assigned from the
unicast block.
Multicast Address
A multicast address also defines a group of computers. However, there is a difference
between anycasting and multicasting.
In anycasting, only one copy of the packet is sent to one of the members of the group; in
multicasting each member of the group receives a copy.
Global Unicast Addresses
The block in the address space that is used for unicast (one-to-one) communication
between two hosts in the Internet is called the global unicast address block.
CIDR for the block is 2000::/3, which means that the three leftmost bits are the
same for all addresses in this block (001).
IPv6 PROTOCOL:
The change of the IPv6 address size requires the change in the IPv4 packet format.
Better header format. IPv6 uses a new header format in which options are separated
from the base header and inserted, when needed, between the base header and the
data.
New options. IPv6 has new options to allow for additional functionalities.
Allowance for extension. IPv6 is designed to allow the extension of the protocol if
required by new technologies or applications.
Support for resource allocation. In IPv6, the type-of-service field has been removed, but
two new fields, traffic class and flow label, have been added to enable the source to
request special handling of the packet. This mechanism can be used to support traffic
such as real-time audio and video.
Support for more security. The encryption and authentication options in IPv6 provide
confidentiality and integrity of the packet.
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.
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 delivery requirements. It replaces the type-of-service field in IPv4.
Hop-by-Hop - The hop-by-hop option is used when the source needs to pass
information to all routers visited by the datagram
Destination Option The destination option is used when the source needs to pass
information to the destination only
Source Routing The source routing extension header combines the concepts of the strict
source route and the loose source route options of IPv4.
Header
Translation Header translation is necessary when the majority of the Internet
has moved to IPv6 but some systems still use IPv4.
The sender wants to use IPv6, but the receiver does not understand IPv6.
Tunneling does not work in this situation because the packet must be in the IPv4
format to be understood by the receiver.
CONNECT WITH US
WEBSITE: www.eduengineering.net
TELEGRAM: @eduengineering
-
INSTAGRAM: @eduengineering