0% found this document useful (0 votes)
3 views

CN Module 3

The document covers the concepts and functionalities of the Network Layer in computer networks, including routing algorithms, congestion control, and the role of the network layer in the Internet. It outlines various routing techniques such as shortest path routing, distance vector routing, and link state routing, along with congestion management strategies. Additionally, it discusses IPv4 and its header format, emphasizing the importance of efficient data transmission and network interconnectivity.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

CN Module 3

The document covers the concepts and functionalities of the Network Layer in computer networks, including routing algorithms, congestion control, and the role of the network layer in the Internet. It outlines various routing techniques such as shortest path routing, distance vector routing, and link state routing, along with congestion management strategies. Additionally, it discusses IPv4 and its header format, emphasizing the importance of efficient data transmission and network interconnectivity.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 98

Computer Networks

Unit - 3
Network Layer

Dr. R. Uma Mageswari


Associate Professor
CSE
1
Course Outcomes

CO1: Identify the concepts of OSI and TCP/IP reference models and their
applications.

CO2: Compare different types of network topologies, topologies and their


functionalities

CO3: Utilize various control mechanisms to resolve data transmission problems.

CO4: Examine various subnetting and routing techniques.

CO5: Use appropriate techniques to achieve better Quality of Service.


The Network Layer
➢ Network Layer design issues
➢ Routing Algorithms
• Shortest path routing
• Flooding
• Distance vector routing
• Link state routing
➢ Congestion control algorithms
➢ The network layer in the internet
• IPv4
• Sub-netting
• Super-netting
• CIDR
• NAT
• IPv6

3
Data Link Layer
• The data link layer is responsible for moving frames from
one hop (node) to the next
• Transform the physical layer to a reliable (error-free) link

2-4
Hop-to-Hop Delivery

2-5
Network Layer
• The network layer is responsible for the delivery of
packets from the source host to the destination host

2-6
Network Layer: Duties
• Logical addressing and routing

2-7
• The primary function of the network layer is to enable
different networks to be interconnected.

• It determines the route from the source to the destination and


also manages the traffic problems such as switching, routing
and controls the congestion of data packets.
Network layer design issues

1. Store and forward packet switching


2. Services provided to the transport layer
3. Implementation of connection less service
4. Implementation of connection oriented service
5. Comparison of virtual circuits and datagram subnets
• A host with a packet to send, transmits it to the nearest
router, either on its own LAN or over a point-to-point link
to the carrier.
• The packet is stored there until it has fully arrived so that
the checksum can be verified.
• Then it is forwarded to the next router along the path
until it reaches the destination host, where it is delivered.
• This mechanism is store-and-forward packet switching.
Services provided to the transport layer
• The services should be independent of the router
technology.
• The transport layer should be shielded from the number,
type and topology of the routers present.
• The network addresses made available to the transport
layer should use a uniform numbering plan, even across
LANs and WANs.
• Assume that the message is four times longer than the maximum
packet size, so the network layer has to break it into four packets, 1,
2, 3 and 4 and sends each of them in turn to router A using some
point-to-point protocol.

• For example, PPP. At this point the carrier takes over. Every router
has an internal table telling it where to send packets for each
possible destination. Each table entry is a pair consisting of a
destination and the outgoing line to use for that destination. Only
directly connected lines can be used.
• The idea behind virtual circuits is to avoid choosing a new route for
every packet sent.
• When a connection is established, a route from the source machine
to the destination machine is chosen as a part of the connection
setup and stored in tables inside the routers.
• That route is used for all traffic flowing over the connection, exactly
the same way that the telephone system works.
• When the connection is released, the virtual circuit is also
terminated. With connection – oriented service, each packet carries
an identifier telling which virtual circuit belongs to.
Routing Algorithms

Goal: Determine “good” path (sequence of routers) through


network from source to destination.

Graph abstractions for the routing algorithms.


• Graph nodes are routers
• Graph edges are physical links
• Good path: Typically means minimum cost path
➢ Global:
All routers have complete topology, link cost info
Eg: Link state algorithms.

➢ Decentralized:
Router knows physically – connected neighbors, link costs to
neighbors, Iterative process of computation, exchange of info with
neighbors.
Eg: Distance vector algorithms

➢ Static: Routes are fixed and can change slowly over time.
➢ Dynamic: Routes change more quickly/automatically
• Periodic updates
Routing Algorithms
Network layer functions

• Forwarding: Move packets from routers input to appropriate


router output.
• Routing: Determines the route taken by packets from source to
destination (routing algorithms).
• The algorithms that choose the routes and the data structures
that are used play a major role in network layer design.
• The routing algorithm is the part of the NL software. It is
responsible for deciding which output line an incoming packet
should be transmitted on.
There are two processes inside router:

a) One of them handles each packet as it arrives,


looking up the outgoing line to use for it in the
routing table. This process is forwarding.

a) The other process is responsible for filling in and


updating the routing tables. That is where the
routing algorithm comes into play. This process is
routing.
Properties of routing algorithms:

• Correctness
• Simplicity
• Robustness
• Stability
• Fairness
• Optimality
Routing Algorithms

• Non-adaptive routing algorithms do not change the


selected routing decisions for transferring data
packets from the source to the destination.

• Adaptive routing algorithms make routing


decisions dynamically depending on the network
conditions.
➢ The Optimality principle
➢ Shortest Path Routing (Dijkstra’s Algorithm)
➢ Flooding
➢ Distance Vector Routing
➢ Link State Routing
➢ Hierarchical routing
➢ Broadcast Routing
➢ Multicast Routing
The Optimality Principle

One can make general statement about optimal routes without


regard to network topology or traffic.

The Optimality principle states that if router J is on the optimal


path from router I to router K, Then the optimal path from J to K
also falls along the same route.

The set of optimal routes from all sources to a given destination


form a rooted tree at the destination. Such a tree is called a sink
tree.
Shortest path routing algorithm

• The idea is to build a graph of the subnet, with


each node of the graph representing a router
and each arc of the graph representing a
communication line or link.

• To choose a route between a given pair of


routes, the algorithm just finds the shortest path
between them on the graph.
• Start with the local node (router) as the root of the
tree. Assign a cost of 0 to this node and make it the
first permanent node.
• Examine each neighbor of the node that was the last
permanent node.
• Assign a cumulative cost to each node and make it
tentative.
• Among the list of tentative nodes
a.Find the node with the smallest cost and make
it permanent.
b.If a node can be reached from more than one
route then select the route with the shortest
cumulative cost.
In general case, the labels on the arcs could be
computed as a function of the distance, bandwidth,
average traffic, communication cost, mean queue
length, measured delay and other factors.

By changing the weighting function, the algorithm


would then compute the shortest path measured
according to any one of a number of criteria or to a
combination of criteria.
Flooding

Another static state algorithm is flooding, in which


every incoming packet is sent out on every outgoing
line except the one it arrived on.

Flooding obviously generates vast numbers of


duplicate packets, in fact, an infinite number unless
some measures are taken.
How to stop and eliminate duplicate packets

1. Using a hop counter


• decrement hop counter in each router
• discard packet if counter is 0
2. Sequence number to the packet
• avoid sending the same packet second time
• keep the list of packets that were already seen
in each router
3. Selective flooding
The routers send the incoming packets on only
those lines that are going approximately in the right
direction.
Distance Vector Routing Algorithm

➢ A dynamic routing algorithm


➢ This algorithm operate by having each router maintain
a table (i.e., vector) giving the best-known distance to
each destination and which line to use to get there.
➢ These tables are updated by exchanging information
with the neighbors.
➢ A distance-vector routing (DVR) protocol requires that
a router inform its neighbors of topology changes
periodically. Historically known as the old ARPANET
routing algorithm (or known as Bellman-Ford
algorithm).
• As an example, assume that delay is used as a metric
and that the router knows the delay to each of its
neighbors.

• Once every T msec each router sends to each neighbor


a list of its estimated delays to each destination.

• It also receives a similar list from each neighbor.

• Distance vector routing algorithm is sometimes called


by other names called Bellman - Ford routing algorithm
and Ford - Fulkerson algorithm.
Advantages
1.Distance vector routing protocol is easy to implement
in small networks. Debugging is very easy in the
distance vector routing protocol.

2.This protocol has a very limited redundancy in a small


network.
Disadvantage
1. A broken link between the routers should be updated to every
other router in the network immediately. The distance vector
routing takes a considerable time for the updation. This problem
is also known as count-to-infinity.
2.The time required by every router in a network to produce an
accurate routing table is called convergence time. In the large
and complex network, this time is excessive.
3.Every change in the routing table is propagated to other
neighboring routers periodically which create traffic on the
network.
Count to infinity problem

1.One of the important issue in Distance Vector Routing is County


of Infinity Problem.

2.Counting to infinity is just another name for a routing loop.

3.In distance vector routing, routing loops usually occur when an


interface goes down.

4.It can also occur when two routers send updates to each other
at the same time
Count to infinity problem
Link state routing algorithm
The idea behind linked state routing is simple and can be
stated as five parts. Each router must do the following:

1. Discover its neighbours and learn their network


addresses.
2. Measure the delay or cost to each of its neighbours.
3. Construct a packet telling all it has just learned.
4. Send this packet to all other routers.
5. Compute the shortest path to every other router.
1. Discover its neighbours and learn their network addresses
2. Measure the delay or cost to each of its neighbours

Measuring line cost

ECHO Packet – Send ECHO packet , reply immediately


Round trip time = a+b
Estimate delay = (a+b)/2
3. Construct a packet telling all it has just learned

4. Send this packet to all other routers


5. Compute the shortest path to every other router
Hierarchical routing
• In hierarchical routing, routers are classified in groups
called regions.

• Each router has information about the routers in its own


region and it has no information about routers in other
regions.

• So, routers save one record in their table for every other
region.

• For huge networks, a two-level hierarchy may be


insufficient hence, it may be necessary to group the
regions into clusters, the clusters into zones, the zones
into groups and so on.
Broadcast Routing
Multicast Routing
Congestion Control

• When too many packets are present in the subnet,


performance degrades. This situation is called
congestion.

• Congestion causes packet delay and loss, that


degrades performance.

• Handling congestion is the responsibility of the


network and transport layers working together.
• Congestion results when too much traffic is offered;
performance degrades due to loss/retransmissions.
• Good put= useful packets.
Congestion Control

• General principles of congestion control


• Congestion prevention policies
• Congestion control in virtual circuit subnets
• Congestion control in datagram subnets
• Load shedding
• Jitter control
General principles Congestion Control

• Monitor the system


• Detect when and where congestion occurs
• Pass information to where action can be taken
• Adjust system operation to correct the problem
Approaches to congestion control

Network must do its best with the offered load


• Different approaches at different timescales
• Nodes should also reduce offered load

Time scales of approaches to congestion control


Traffic Aware Routing
Congestion Prevention Policies
Congestion control in virtual subnets circuit
(or) Admission control
Traffic Throttling
• Congested routers signal hosts to slow down traffic.
• ECN (Explicit Congestion Notification) marks packets and
receiver returns signal to sender.
Congestion control in datagram subnets

Warning bit:
• Special bit in packets header.
• As long as warning bits continues to flow in, the source
continued to decrease its transmission rate.

Choke packet:
• When the source host receive choke, it should reduce the
traffic sharply.
• If no choke packet arrives for a period, the host may increase
the flow slowly.
Load shedding
Jitter control
Average arrival rate of packets (or variation in the packet
arrival times) is called jitter.
Traffic Shaping is a mechanism to control the amount and the rate of traffic sent to
the network. Approach of congestion management is called Traffic shaping. Traffic
shaping helps to regulate the rate of data transmission and reduces congestion.

When too many packets are present in the network it causes packet delay and
loss of packet which degrades the performance of the system. This situation is
called congestion.

The network layer and transport layer share the responsibility for handling
congestions.

One of the most effective ways to control congestion is trying to reduce the
load that transport layer is placing on the network.

To maintain this, the network and transport layers have to work together.

There are two types of Congestion control algorithms, which are as follows −
•Leaky Bucket Algorithm
•Token Bucket Algorithm
Leaky Bucket Algorithm
Step 1 − Let us imagine a bucket with a small hole at the
bottom where the rate at which water is poured into the
bucket is not constant and can vary but it leaks from the
bucket at a constant rate.
Step 2 − So (up to water is present in the bucket), the
rate at which the water leaks does not depend on the
rate at which the water is input to the bucket.
Step 3 − If the bucket is full, additional water that enters
into the bucket that spills over the sides and is lost.
Step 4 − Similarly, in networking, a technique called leaky
bucket can smooth out bursty traffic. Bursty chunks are stored
in the bucket and sent out at an average rate.
The network layer in the internet
• IPv4
• Sub-netting
• Super-netting
• CIDR
• NAT
• IPv6
The network layer in the Internet

1. Make sure it works


2. Keep it simple
3. Make clear choices
4. Exploit modularity
5. Expect heterogeneity
6. Avoid static options and parameters
7. Look for a good design; it need not to be perfect
8. Be strict when sending and tolerant when receiving
9. Think about scalability
10. Consider performance and cost
IPv4 header format (32 bit)
Internet Protocol version 4 (IPv4) is the fourth version of the Internet Protocol (IP).
It is one of the core protocols of standards-based internetworking methods in the
Internet and other packet-switched networks. IPv4 was the first version deployed for
production on SATNET in 1982 and on the ARPANET in January 1983.

Fields of IPv4 Header


Version
The first header field in an IP packet is the four-bit version field. For IPv4, this is
always equal to 4.

Internet Header Length (IHL)


The IPv4 header is variable in size due to the optional 14th field (options). The IHL
field contains the size of the IPv4 header; it has 4 bits that specify the number of
32-bit words in the header. The minimum value for this field is 5,[37] which
indicates a length of 5 × 32 bits = 160 bits = 20 bytes. As a 4-bit field, the
maximum value is 15; this means that the maximum size of the IPv4 header is 15
× 32 bits = 480 bits = 60 bytes.
Differentiated services
1. Differentiated Services Code Point (DSCP)
Originally defined as the type of service (ToS), this field specifies differentiated
services (DiffServ) per RFC 2474.[a] Real-time data streaming makes use of the
DSCP field. An example is Voice over IP (VoIP), which is used for interactive voice
services.

2. Explicit Congestion Notification (ECN)


This field is defined in RFC 3168 and allows end-to-end notification of network
congestion without dropping packets. ECN is an optional feature available when
both endpoints support it and effective when also supported by the underlying
network.

Total Length
This 16-bit field defines the entire packet size in bytes, including header and data. The
minimum size is 20 bytes (header without data) and the maximum is 65,535 bytes.
All hosts are required to be able to reassemble datagrams of size up to 576 bytes,
but most modern hosts handle much larger packets. Links may impose further
restrictions on the packet size, in which case datagrams must be fragmented.
Fragmentation in IPv4 is performed in either the sending host or in routers.
Reassembly is performed at the receiving host.
Identification
This field is an identification field and is primarily used for
uniquely identifying the group of fragments of a single IP
datagram. Some experimental work has suggested using
the ID field for other purposes, such as for adding packet-
tracing information to help trace datagrams with spoofed
source addresses,[38] but RFC 6864 now prohibits any
such use.

Flags
A three-bit field follows and is used to control or identify
fragments. They are (in order, from most significant to
least significant):
• bit 0: Reserved; must be zero.[b]
• bit 1: Don't Fragment (DF)
• bit 2: More Fragments (MF)
Fragment offset
This field specifies the offset of a particular fragment relative to the
beginning of the original unfragmented IP datagram in units of
eight-byte blocks. The first fragment has an offset of zero. The 13
bit field allows a maximum offset of (213 – 1) × 8 = 65,528 bytes,
which, with the header length included (65,528 + 20 = 65,548
bytes), supports fragmentation of packets exceeding the maximum
IP length of 65,535 bytes.

Time to live (TTL)


An eight-bit time to live field limits a datagram's lifetime to prevent
network failure in the event of a routing loop. It is specified in
seconds, but time intervals less than 1 second are rounded up to 1.

Protocol
This field defines the protocol used in the data portion of the IP
datagram. IANA maintains a list of IP protocol numbers as directed
by RFC 790.
Header checksum
The 16-bit IPv4 header checksum field is used for error-checking of the header. When a packet
arrives at a router, the router calculates the checksum of the header and compares it to the
checksum field. If the values do not match, the router discards the packet. Errors in the data
field must be handled by the encapsulated protocol. Both UDP and TCP have separate
checksums that apply to their data.

Source address
This field is the IPv4 address of the sender of the packet. Note that this address may be changed in
transit by a network address translation device.

Destination address
This field is the IPv4 address of the receiver of the packet. As with the source address, this may be
changed in transit by a network address translation device.

Options
The options field is not often used. Packets containing some options may be considered as
dangerous by some routers and be blocked. Note that the value in the IHL field must include
enough extra 32-bit words to hold all the options plus any padding needed to ensure that the
header contains an integer number of 32-bit words.
IPv6 (128 bit)
Version (4-bits): Indicates version of Internet Protocol which
contains bit sequence 0110.

Traffic Class (8-bits): The Traffic Class field indicates class or priority
of IPv6 packet which is like Service Field in IPv4 packet. It helps
routers to handle the traffic based on the priority of the packet. If
congestion occurs on the router then packets with the least priority
will be discarded.

As of now, only 4-bits are being used (and the remaining bits are
under research), in which 0 to 7 are assigned to Congestion
controlled traffic and 8 to 15 are assigned to Uncontrolled traffic.
Flow Label (20-bits): Flow Label field is used by a source to label the packets
belonging to the same flow in order to request special handling by
intermediate IPv6 routers, such as non-default quality of service or real-time
service. In order to distinguish the flow, an intermediate router can use the
source address, a destination address, and flow label of the packets

Payload Length (16-bits): It is a 16-bit (unsigned integer) field, indicates the


total size of the payload which tells routers about the amount of
information a particular packet contains in its payload. The payload Length
field includes extension headers(if any) and an upper-layer packet.

Next Header (8-bits): Next Header indicates the type of extension header(if
present) immediately following the IPv6 header. Whereas In some cases it
indicates the protocols contained within upper-layer packets, such as TCP,
UDP.
Hop Limit (8-bits): Hop Limit field is the same as TTL in IPv4 packets. It indicates the
maximum number of intermediate nodes IPv6 packet is allowed to travel. Its value gets
decremented by one, by each node that forwards the packet and the packet is discarded if
the value decrements to 0. This is used to discard the packets that are stuck in an infinite
loop because of some routing error.

Source Address (128-bits): Source Address is the 128-bit IPv6 address of the original
source of the packet.

Destination Address (128-bits): The destination Address field indicates the IPv6 address of
the final destination(in most cases). All the intermediate nodes can use this information in
order to correctly route the packet.

Extension Headers: In order to rectify the limitations of the IPv4 Option Field, Extension
Headers are introduced in IP version 6. The extension header mechanism is a very
important part of the IPv6 architecture. The next Header field of IPv6 fixed header points
to the first Extension Header and this first extension header points to the second
extension header and so on.
IPv4 Vs. IPv6
Subnetting
A subnetting or subnetwork
is a segmented piece of large
network.

When a bigger network is


divided into smaller
networks, to maintain
security, then that is known
as Subnetting.
Class A

Class B

Class C
One node to be
communicated
with another
node. It sends a
broadcast
message.
Broadcasting in a single network which are connected with too many devices
All devices
broad casting
in the network
leads to loss of
that system.

To prevent this
networks, need
to be broken
into smaller
networks
Therefore, IP address
have network portion
and the host portion.

So, networks can be


logically broken down
into smaller networks,
which is known as
subnetting
Super netting
• It is reverse (inverse) of subnetting.

• Combining of multiple networks to single networks.

• Converting network bits to host bits i.e., converting 1’s to 0’s

• It is also known as classless Inter Domain Routing (CIDR)


192.168.0.0/22
CIDR (Classless Inter-Domain Routing)

It also known as super netting -- is a method


of assigning Internet Protocol (IP)
addresses that improves the efficiency of
address distribution and replaces the
previous system based on Class A, Class
B and Class C networks.
NAT
A Network Address Translation (NAT)
is the process of mapping an internet
protocol (IP) address to another by
changing the header of IP packets
while in transit via a router.

This helps to improve security and


decrease the number of IP addresses
an organization needs.

You might also like