Unit 4 - Computer Networks - WWW - Rgpvnotes.in
Unit 4 - Computer Networks - WWW - Rgpvnotes.in
Tech
Subject Name: Computer Networks
Subject Code: CS-602
Semester: 6th
Downloaded from www.rgpvnotes.in
Syllabus: Network Layer: Need, Services Provided , Design issues, Routing algorithms: Least
CostRouting algorithm, Dijkstra's algorithm, Bellman-ford algorithm, Hierarchical Routing,Broadcast
Routing, Multicast Routing. IP Addresses, Header format, Packet forwarding,Fragmentation and
reassembly, ICMP, Comparative study of IPv4 & IPv6.
There are two types of service that can be provided by the network layer:
1. An unreliable connectionless service.
2. A connection-oriented, reliable or unreliable, service.
Network Layer: Design issues
a) Store-and-Forward Packet Switching
b) Services Provided to the Transport Layer
c) Implementation of Connectionless Service
d) Implementation of Connection-Oriented Service
a) Store-and-Forward Packet Switching
A host with a packet to send transmits it to the nearest router, either on its own LAN or over a point-to-
pointlink to the carrier. The packet is stored there until it has fully arrived so 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.
1. Establishment Phase.
2. Data transfer Phase.
3. Connection release Phase.
2. Non-Adaptive Routing Algorithm: These algorithms do not base their routing decisions on
measurements and estimates of the current traffic and topology. Instead the route to be taken in going
from one node to the other is computed in advance, off-line, and downloaded to the routers when the
network is booted. This is also known as static routing. This can be further classified as:
1. Flooding: Flooding adapts the technique in which every incoming packet is sent on every
outgoing line except the one on which it arrived. One problem with this method is that packets may go in a
loop. As a result of this a node may receive several copies of a particular packet which is undesirable. Some
techniques adapted to overcome these problems are as follows:
a. Sequence Numbers: Every packet is given a sequence number. When a node receives the packet
it sees its source address and sequence number. If the node finds that it has sent the same packet earlier
then it will not transmit the packet and will just discard it.
b. Hop Count: Every packet has a hop count associated with it. This is decremented (or
incremented) by one by each node which sees it. When the hop count becomes zero (or a maximum
possible value) the packet is dropped.
c. Spanning Tree: The packet is sent only on those links that lead to the destination by constructing
a spanning tree routed at the source. This avoids loops in transmission but is possible only when all the
intermediate nodes have knowledge of the network topology.
Flooding is not practical for general kinds of applications. But in cases where high degree of robustness
is desired such as in military applications, flooding is of great help.
2. Random Walk: In this method a packet is sent by the node to one of its neighbours randomly.
This algorithm is highly robust. When the network is highly interconnected, this algorithm has the property
of making excellent use of alternative routes. It is usually implemented by sending the packet onto the
least queued link.
1. Dijkstra's algorithm:
1. Compute the least cost path from one node to all other nodes in the network.
2. Iterative algorithm - After the kth iteration, the least cost paths for k destination nodes are found.
3. D(v): cost of the least cost path from source node to destination v
4. p(v): previous node of v along the least-cost path from source.
5. N’: set of nodes to which the least-cost path is found.
Bellman-ford algorithm:
Following are the detailed steps.
Input: Graph and a source vertex src
Output: Shortest distance to all vertices from src. If there is a negative weight cycle, then shortest distances
are not calculated, negative weight cycle is reported.
1) This step initializes distances from source to all vertices as infinite and distance to source itself as 0.
Create an array dist[] of size |V| with all values as infinite except dist[src] where src is source vertex.
2) This step calculates shortest distances. Do following |V|-1 times where |V| is the number of vertices in
given graph.
a) Do following for each edge u-v
If dist[v] >dist[u] + weight of edge uv, then update dist[v]
dist[v] = dist[u] + weight of edge uv
3) This step reports if there is a negative weight cycle in graph. Do following for each edge u-v
If dist[v] >dist[u] + weight of edge uv, then “Graph contains negative weight cycle”
The idea of step 3 is, step 2 guarantees shortest distances if graph doesn’t contain negative weight cycle. If
we iterate through all edges one more time and get a shorter path for any vertex, then there is a negative
weight cycle
How does this work? Like other Dynamic Programming Problems, the algorithm calculates shortest paths
in bottom-up manner. It first calculates the shortest distances which have at-most one edge in the path.
Then, it calculates shortest paths with at-most 2 edges, and so on. After the i-th iteration of outer loop, the
shortest paths with at most i edges are calculated. There can be maximum |V| – 1 edge in any simple path
that is why the outer loop runs |v| – 1 times. The idea is, assuming that there is no negative weight cycle, if
we have calculated shortest paths with at most i edges, then an iteration over all edges guarantees to give
shortest path with at-most (i+1) edges
Example
let us understand the algorithm with following example graph. The images are taken from this source.
Let the given source vertex be 0. Initialize all distances as infinite, except the distance to source itself. Total
number of vertices in the graph is 5, so all edges must be processed 4 times.
Hierarchical Routing:
1. As the number of routers becomes large, the overhead involved in maintaining routing information
becomes prohibitive.
2. Internet providers want to manage their network as they wish, while still being able to connect to other
networks.
3. Organizing routers into autonomous systems (ASs) solve these problems.
4. Routers within the same AS all run the same routing algorithm (e.g., Dijkstrar DV).Intra-AS routing
protocol
5. One or more routers in an AS are responsible to forward packets to destinations outside AS.
6. How to route packets outside an AS?
7. Inter-AS routing protocol: – Obtain reachability information from neighbouring ASs, and Propagate the
reachability information to all routers in AS.
8. In the Internet, all ASs run the same inter-AS routing protocol: BGP (Border Gateway Protocol)–Uses a
DV-like algorithm.
This method consumes lots of bandwidth and router must destination address of each node.
Secondly, when router receives a packet that is to be broadcasted, it simply floods those packets
out of all interfaces. All routers are configured in the same way.
Multicast Routing:
Multicast routing is special case of broadcast routing with significance difference and challenges. In
broadcast routing, packets are sent to all nodes even if they do not want it. But in Multicast routing, the
data is sent to only nodes which wants to receive the packets.
If the timeout interval is too short, extra packets will be sent unnecessarily. If it is too long, congestion
will be reduced but the response time will suffer whenever a packet is lost.
to become congested, and they, in turn, reject data from their upstream nodes or nodes. And so on.
Backpressure is a node-to-node congestion control that starts with a node and propagates, in the opposite
direction of data flow, to the source. The backpressure technique can be applied only to virtual circuit
networks, in which each node knows the upstream node from which a flow of data is corning.
A bit can be set in a packet moving in the direction opposite to the congestion. This bit can warn the source
that there is congestion and that it needs to slow down to avoid the discarding of packets.
Forward Signalling
A bit can be set in a packet moving in the direction of the congestion. This bit can warn the destination that
there is congestion. The receiver in this case can use policies, such as slowing down the acknowledgments,
to alleviate the congestion.
Fig 4.17Functioning of choke packets, (a) Heavy traffic between nodes P and Q, (b) Node Q sends the
Choke packet to P, (c) Choke packet reaches P, (d) P reduces the flow and sends a reduced flow out, (e)
Reduced flow reaches node Q.
Problem: It does not work well if the choke packet travels a long distance to reach the source because
reduction of flow starts from source node rather than intermediate node. This problem can be solved by
hop-by-hop approach.
Fig 4.18Functioning of Hop-by-Hop choke packets, (a) Heavy traffic between nodes P and Q, (b) Node Q
sends the Choke packet to P, (c) Choke packet reaches R, and the flow between R and Q is decreased, (d)
Choke packer reaches P, and P reduces the flow out.
IP protocol:
Internet Protocol (IP) is the principal set (or communications protocol) of digital message formats and rules
for exchanging messages between computers across a single network or a series of interconnected
networks, using the Internet Protocol Suite (often referred to as TCP/IP). Messages are exchanged as
datagrams, also known as data packets or just packets.
IP is the primary protocol in the Internet Layer of the Internet Protocol Suite, which is a set of
communications protocols consisting of four abstraction layers: link layer (lowest), Internet layer, transport
layer and application layer (highest).
The main purpose and task of IP is the delivery of datagrams from the source host (source computer) to
the destination host (receiving computer) based on their addresses. To achieve this, IP includes methods
and structures for putting tags (address information, which is part of metadata) within datagrams. The
process of putting these tags on datagrams is called encapsulation.
Think of an analogy with the postal system. IP is similar to the U.S. Postal System in that it allows a package
(a datagram) to be addressed (encapsulation) and put into the system (the Internet) by the sender (source
host). However, there is no direct link between sender and receiver.
The package (datagram) is almost always divided into pieces, but each piece contains the address of the
receiver (destination host). Eventually, each piece arrives at the receiver, often by different routes and at
different times. These routes and times are also determined by the Postal System, which is the IP.
However, the Postal System (in the transport and application layers) puts all the pieces back together
before delivery to the receiver (destination host).
Note: IP is actually a connectionless protocol, meaning that the circuit to the receiver (destination host)
does not need be set up before transmission (by the source host). Continuing the analogy, there does not
need to be a direct connection between the physical return address on the letter/package and the
recipient address before the letter/package is sent.
When format and rules were applied to allow connections, the connection-oriented Transmission Control
Protocol was created. The two together forms the Internet Protocol Suite, often referred to as TCP/IP.
Internet Protocol version 4 (IPv4) was the first major version of IP. This is the dominant protocol of the
Internet. However, iPv6 is active and in use, and its deployment is increasing all over the world.
Addressing and routing are the most complex aspects of IP. However, intelligence in the network is located
at nodes (network interconnection points) in the form of routers which forward datagrams to the next
known gateway on the route to the final destination. The routers use interior gateway protocols (IGPs) or
external gateway protocols (EGPs) to help with making forwarding route decisions. Routes are determined
by the routing prefix within the datagrams. The routing process can therefore become complex. But at the
speed of light (or nearly so) the routing intelligence determines the best route, and the datagram pieces
and datagram all eventually arrive at their destination.
IP Address
An Internet Protocol address (IP address) is a logical numeric address that is assigned to every single
computer, printer, switch, router or any other device that is part of a TCP/IP-based network.
The IP address is the core component on which the networking architecture is built; no network exists
without it. An IP address is a logical address that is used to uniquely identify every node in the network.
Because IP addresses are logical, they can change. They are similar to addresses in a town or city because
the IP address gives the network node an address so that it can communicate with other nodes or
networks, just like mail is sent to friends and relatives.
The numerals in an IP address are divided into 2 parts:
The network part specifies which networks this address belongs to and
The host part further pinpoints the exact location.
An IP address is the most significant and important component in the networking phenomena that binds
the World Wide Web together. The IP address is a numeric address assigned to every unique instance that
is connected to any computer communication network using the TCP/IP communication protocols.
Network nodes are assigned IP addresses by the Dynamic Host Configuration Protocol server as soon as the
nodes connect to a network. DHCP assigns IP addresses using a pool of available addresses which are part
of the whole addressing scheme. Though DHCP only provides addresses that are not static, many machines
reserve static IP addresses that are assigned to that entity forever and cannot be used again.
IP addresses falls into two types:
Classfull IP addressing is a legacy scheme which divides the whole IP address pools into 5 distinct
classes—A, B, C, D and E.
Classless IP addressing has an arbitrary length of the prefixes.
Header format of IPv4:
strict requirements on routing performance but lax memory requirements may choose a larger cache
setting.
Fig:4. 22 Fragmentations
**Reassembly is the reverse of segmentation. Protocol Data Units are put back together in the correct
order to reassemble a stream of data in its original form.**
ICMP:
ICMP (Internet Control Message Protocol) is an error-reporting protocol network devices like routers use
to generate error messages to the source IP address when network problems prevent delivery of IP
packets. ICMP creates and sends messages to the source IP address indicating that a gateway to the
Internet that a router, service or host cannot be reached for packet delivery. Any IP network device has the
capability to send, receive or process ICMP messages.
ICMP is not a transport protocol that sends data between systems.
While ICMP is not used regularly in end-user applications, it is used by network administrators to
troubleshoot Internet connections in diagnostic utilities including ping and tracer route.
One of the main protocols of the IP suite, ICMP is used by routers, intermediary devices or hosts to
communicate error information or updates to other routers, intermediary devices or hosts. The widely
used IPv4 (Internet Protocol version 4) and the newerIPv6 use similar versions of the ICMP protocol
(ICMPv4 and ICMPv6, respectively).
ICMP messages are transmitted as datagram’s and consist of an IP header that encapsulates the ICMP
data. ICMP packets are IP packets with ICMP in the IP data portion. ICMP messages also contain the entire
IP header from the original message, so the end system knows which packet failed
The ICMP header appears after the IPv4 or IPv6 packet header and is identified as IP protocol number 1.
The complex protocol contains three fields:
The major type that identifies the ICMP message;
The minor code that contains more information about the type field; and
The checksum that helps detect errors introduced during transmission.
Following the three fields is the ICMP data and the original IP header to identify which packets actually
failed.
ICMP has been used to execute denial-of-services attacks (also called the ping of death) by sending an IP
packet larger than the number of bytes allowed by the IP protocol.