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

Chapter 10 - Network Layer

Uploaded by

pranavgoryt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Chapter 10 - Network Layer

Uploaded by

pranavgoryt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 37

Network Layer

 The network layer is responsible for delivering packets from the source all the way to
the destination. Getting to the destination may require making many hops at
intermediate routers along the way.

The network layer is the lowest layer that deals with end-to-end transmission.
To achieve its goals, the network layer must know about the topology of the subnet
(i.e., the set of all routers) and choose appropriate paths through it.

It must also take care to choose routes so that overloading some of the
communication lines and keeping others lines idle can be avoided. It is up to the
network layer to deal with the problems that may occur when the source and
destination are in different networks.
Network Layer Design
Issues :
 A host with a packet to send transmits it to the nearest router.
 Router may be, either on its own LAN or on carrier’s network.
 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.
Service Provided to the Transport
Layer
1. The services should be independent of the router technology.
2. The transport layer should be shielded from the number, type, and topology of the routers
present.
3. The network addresses made available to the transport layer should use a uniform
numbering plan, even across LANs and WANs.

 The network layer provides two different types of services to transport layer:
1. Connectionless service
2. Connection-oriented service.
Connectionless Service
 In connectionless service, packets are transmitted into the subnet individually
and routed independently of each other.
 No advance setup is needed.
 The packets are called datagrams.
 The subnet is called a datagram subnet.
How a datagram subnet (Connectionless Service) works?
 Suppose that the process P1 in above figure has a long message for P2.
 The network layer breaks it into four packets, 1, 2, 3, and 4 and sends each of them in turn
to router A. Every router has an internal table telling it where to send packets for each
possible destination.
 In above figure, router A has only two outgoing lines—to B and C—so every incoming
packet must be sent to one of these routers.
 As they arrived at A, packets 1, 2, and 3 were forwarded to C.
 Packet 1 was then forwarded to E and then to F.
 From F, it is sent to H2 over the LAN.
 Packets 2 and 3 follow the same route.
 Packet 4 is sent via different route, through router B.
 The algorithm that manages the tables on routers and makes the routing decisions is called
the routing algorithm.
Connection-Oriented Service
 In connection-oriented service, a path from the source router to the
destination router must be established before data packets are sent.
 This connection is called a VC (virtual circuit).
 The subnet is called a virtual-circuit subnet.
 When a connection is established, a route from the source machine to the
destination machine is chosen as part of the connection setup and stored in
tables inside the routers.
 That route is used for all traffic flowing over the connection.
 It works in the same way as the telephone system works.
 When all packets are transmitted, connection is released and virtual circuit is
also terminated.
 With connection-oriented service, each packet carries an identifier telling
which virtual circuit it belongs to.
How a Virtual-Circuit subnet(Connection-oriented Service) works?

 Host H1 has established connection 1 with host H2.


 It is given connection identifier ‘1’. So, if a packet has
connection identifier 1, it means that packet is from H1.
 Now if H3 also wants to establish a connection to H2, router A
will assign connection identifier 2 to it.
Comparison of Virtual-Circuit and Datagram Subnets

Connectionless Service Connection-Oriented Service


Logical connection between sender and Logical connection between sender and
receiver is not established. receiver is established before transmission.
Packets may follow different routes to reach All packets follow the same route.
up to the destination.
Full destination address is required with Full destination address is not required with
packet. packet.
Error control and flow control is not there. Error control and flow control is there
In connection less fixed path is not Fixed path is established between sender
established and receiver
Packet delivery is not guaranteed Packet delivery is guaranteed
It is not reliable It is reliable
It is similar to postal service. It is similar to telephone service
Routing Algorithms
 The routing algorithm is that part of the network layer software responsible for
deciding which output line an incoming packet should be transmitted on.
 If the subnet uses datagrams internally, path must be decided for every packet.
 If the subnet uses virtual circuits internally, routing decisions are made only when a
new virtual circuit is being set up. After that all packets follow that route. This is called
session routing also.
Desirable properties for a routing algorithm:
1. Correctness
2. Simplicity
3. Robustness
The routing algorithm should be able to handle changes in the topology and traffic
without effecting ongoing transmissions.
4. Stability
5. Fairness
6. Optimality
Average delay time for packets should be less. It should try to maximize total network
throughput.
Two main classes/categories of Routing algorithms:
 Nonadaptive: In Nonadaptive algorithms routing decisions are not based on current traffic on
network and topology of network. The choice of the route packets from I to J is computed in
advance, off-line, and downloaded to the routers when the network is booted. This procedure
is sometimes called static routing.
 Adaptive: In Adaptive algorithms, routing decisions are changed when topology and network
traffic is changed.

The Optimality Principle


If router J is on optimal path from I to K then path from I to J (r1) and path from J to K (r2) are
also optimal.
(a) A subnet (b) A sink tree for router B

 The set of optimal routes from all sources to a given destination form a tree with
destination as the root node. Such a tree is called a sink tree.
 In above figure, a sink tree for router B is shown. This tree shows optimal paths from
all other routers to router B.
 Since a sink tree is indeed a tree, it does not contain any loops, so each packet will be
delivered within a finite and bounded number of hops.
Dijkstra’s shortest path algorithm
Several algorithms for computing the shortest path between two nodes of a graph are
known. This one is due to Dijkstra (1959). Each node is labeled (in parentheses) with its
distance from the source node along the best known path. Initially, no paths are known, so all
nodes are labeled with infinity. As the algorithm proceeds and paths are found, the labels may
change, reflecting better paths. A label may be either tentative or permanent. Initially, all
labels are tentative. When it is discovered that a label represents the shortest possible path
from the source to that node, it is made permanent and never changed thereafter.

 We want to find the shortest path from A to D. We start out by marking node A as
permanent, indicated by a filled-in circle. Then we examine, in turn, each of the nodes
adjacent to A (the working node), relabeling each one with the distance to A.
 We now start at B and examine all nodes adjacent to it. If the sum of the label on B and the
distance from B to the node being considered is less than the label on that node, we have a
shorter path, so the node is relabeled.
 Same procedure is applied to all the nodes.
Example:
How Networks Differ
Networks can differ in many ways.
 These differences make internetworking more difficult than operating within a
single network.
 Some of the differences, such as different modulation techniques or frame formats, are in
the physical and data link layers.
 Networks may differ in following things:
 The type of protocol: IP, IPX, ATM, Apple Talk etc.
 Services provided: Connection less or Connection oriented
 Addressing.: Flat or Hierarchical
 Size of packets: Every network has different maximum packet size.
 Quality of service
 Error Control: Reliable, Ordered and Unordered delivery
 Flow Control
 Security: Different privacy rules, encryption etc.
 Types of topologies.
 Number of users.
 Distance covered by the network
 When packets sent by a source on one network must transit one or more foreign networks
before reaching the destination network (which also may be different from the source
network), many problems can occur at the interfaces between networks.
 When packets from a connection-oriented network must transit a connectionless one, they
may be reordered, something the sender does not expect and the receiver is not prepared to
deal with.
 Protocol conversions will often be needed, which can be difficult if the required
functionality cannot be expressed.
 Address conversions will also be needed, which may require some kind of directory
system. Passing multicast packets through a network that does not support multicasting
requires generating separate packets for each destination.
 The differing maximum packet sizes used by different networks can be a major nuisance.
How do you pass an 8000-byte packet through a network whose maximum size is 1500
bytes?
 Differing qualities of service is an issue when a packet that has real-time delivery
constraints passes through a network that does not offer any real-time guarantees.
 Error, flow, and congestion control often differ among different networks. If the source and
destination both expect all packets to be delivered in sequence without error but an
intermediate network just discards packets whenever it smells congestion on the horizon,
many applications will break.
 Also, if packets can wander around aimlessly for a while and then suddenly emerge and be
delivered, trouble will occur if this behavior was not anticipated and dealt with.
 Different security mechanisms, parameter settings, and accounting rules, and even national
privacy laws also can cause problems.
Repeaters, Hubs, Bridges, Switches, Routers, and Gateways :

These devices operate in different layers.


Repeater:
It is an analog device that is connected to two cable segments. It amplifies a signal
appearing on one cable segment and put out on the other.
Hub:
A hub has a number of input lines that it joins electrically. Frames arriving on any of the
lines are sent out on all the others. Hubs differ from repeaters in that they do not amplify
the incoming signals.
Bridges and switches operate at data link layer.
Bridge:
It is a device which is used to connect two or more similar type of networks.
Switch:
It is Similar to bridges. The main difference is that a switch is used to connect each computer
through separate cable. And so, incoming message is sent only to the outgoing line connected
to the destination machine.
Router:
When a packet comes into a router, the frame header and trailer are stripped off and the packet
located in the frame's payload field is passed to the routing algorithm, which chooses an
output line for that packet.
Gateway:
These connect two computers that use different connection-oriented transport protocols. For
example, suppose a computer using the connection-oriented TCP/IP protocol needs to talk to
a computer using the connection- oriented ATM transport protocol. Gateway can work as
protocol converter.
IP ADDRESS

 Every computer connected to the internet has a unique address. These domain names
provide a systematic way to address computers on the internet and are easier to remember.
 As far as user is concerned, he need not know the details of IP addresses. These IP
addresses are read and managed by computers.
 IP addresses can be compared with telephone number. For example, a telephone number
91-020- 5651683 identifies a unique telephone subscriber (5651683) located in India (91) at
Puna (020). Similarly an IP address is also made of four parts and looks like 202.54.24.230
 Parts of an IP address are separated by periods. Each part is referred to as an octet. Each
octet is basically an 8 bit binary number. Thus an IP address is a 32-bit number. The address
space for IP is 232 or 4,294,967,296 (more than four billion).
Notation:
IP address is made of 4 parts, separated by space or dot. Each part is known as octet. The
notation may be in binary, decimal or hexadecimal

Binary:
In this notation IP address is displayed as 32 bits. Space is inserted between each octet (8
bits).
e.g. 01110101 10010101 00011101 11101010

Dotted-Decimal:
In this notation it is written in decimal form with a dot, separating the bytes. Each octet is
only 8 bits, so each number is between 0 and 255 (28 = 256).
e.g. 128.11.3.31
Classification of Addressing
Classification of Addressing

Generally, IP address 255.255.255.255 is used for broadcasting. And IP address 0.0.0.0


is not used because it is used by each computer at the time of booting. In computer
networking, localhost is a hostname that means this computer. It is used to access the
network services that are running on the host via its loopback network interface.
Using the loopback interface bypasses any local network interface hardware.
The local loopback mechanism is useful for testing software during development,
independently of any networking configurations. For example, if a computer has been
configured to provide a website, directing a locally running web browser to
http://localhost may display its home page.
On most computer systems, localhost resolves to the IP address 127.0.0.1, which is
the most commonly used IPv4 loopback address.
The IP Protocol
An IP datagram (packet) consists of two parts:
1. A header part
2. A text part
The header has a 20-byte fixed part and a variable length optional part.
1. Version field (4 bits): Indicates version of the protocol of the datagram.
2. IHL(Internet Header Length) field (4 bits):
Indicates length of the header. It is of 4 bits, so maximum value of this field is 1111 = 15
lines. Each line is of 4 bytes, so maximum size of header field is 15 x 4 = 60 bytes. The
minimum value is 5 when no options are present, so, minimum size of header field is 5 x 4
= 20 bytes. Thus the maximum length of Options field is 40 bytes
3. Type of service field (8 bits):
It is of 1 byte. First three bits are used to indicate the priority of the packet which can be
from 000 to 111 i.e. [0 to 7]. Next three bits indicates flags. And remaining two bits are
not used.
D T R

D:- Delay
T:- Throughput
R:- Reliability
The three flag bits allowed the host to specify
what it cared most about from Delay, Throughput
4. Total Length (16 bits):
It gives info about total length of datagram including header part and text part. The size is
two bytes. The maximum length is 216 =0-65535 bytes.
5. Identification (16 bits):
A large datagram can be divided into multiple fragments. This field allows the destination
host to determine that current fragment belongs to which datagram. All the fragments of a
datagram contain the same Identification value.
6. An unused bit
7. DF (Don't Fragment) (1 bit):
It is an order to the routers not to fragment the datagram because the destination is
incapable of putting the pieces back together again.
8. MF (More Fragments) (1 bit):
All fragments except the last one have this bit set. If this bit is set in a fragment then it
means that this is the last fragment of the particular datagram and no more fragments are
remaining.
9. Fragment offset (13 bits):
Indicates the position of fragment in current datagram. Its size is 13 bits, so maximum
213 = 8192 fragments of a datagram can be there.
10. Time to live (8 bits):
It is a counter used to limit packet lifetimes. It counts time in seconds. Maximum
lifetime is 255 sec. It must be decremented on each hop and is supposed to be
decremented multiple times when queued for a long time in a router. In practice, it just
counts hops. When it hits zero, the packet is discarded and a warning packet is sent back
to the source host. This feature prevents datagrams from wandering around forever.
11. Protocol (8 bits):
When the network layer has assembled a complete datagram, the Protocol field tells it
which transport process to give it to.
12. Header checksum (16 bits):
Checksum that verifies the header only. Header checksum must be recomputed at each
hop.
13. Source address(32 bits) and Destination address(32 bits):
It indicates the IP address of source and destination.
14. Optional Part.
Optional Part Contains following information:
1) Security:
It specifies the security info of datagram.
2) Strict Source Routing:
It specifies complete path info from source to destination including all routes and
network as a sequence of IP addresses.
3) Loose Source Routing:
It gives info about routers only.
4) Record Router:
It specifies IP addresses of each router between source and destination.
5) Time Stamp:
It is used to debugging routing algorithms. Indicate the network number and host
number.
ARP—The Address Resolution Protocol
 Every machine on the Internet has one (or more) IP addresses.
 But these IP addresses cannot actually be used for sending packets. Because the data
link layer hardware does not understand Internet addresses.
 Hardware understands LAN or Ethernet address, which is the address of network interface
card. This address is provided by the manufacturers of NIC (Network Interface Card).
 So there must be some way to map IP addresses onto data link layer addresses.
 Consider that we have two Ethernets, one with IP address 192.31.65.0 and another with
IP address 192.31.63.0. These are connected by a backbone ring.
 Each machine on an ethernet has a unique Ethernet address, labeled EI through E6, and
each machine on the FDDI (Fiber Distributed Data Interface) ring has an FDDI address,
labeled F1 through F3.
 Let us see how a user on host1(192.31.65.7) sends a packet to a user on host2(192.31.65.5).
 The first step is to find the IP address for host2.
 This lookup is performed by the Domain Name System.
 The DNS returns the IP address for host2 (192.31.65.5).
 The upper layer software on host1 now builds a packet with 192.31.65.5 in the
Destination address field and gives it to the IP software to transmit.
 The IP software can look at the address and see that the destination is on its own network,
but it needs some way to find the destination's Ethernet address.
 Host1 to broadcasts packet onto the Ethernet asking: Who owns IP address 192.31.65.5?
 The broadcast packet will arrive at every machine on Ethernet 192.31.65.0, and each one
will check its IP address.
 Host2 alone will respond with its Ethernet address (E2).
 In this way host1 learns that IP address 192.31.65.5 is on the host with Ethernet address E2.
The protocol used for asking this question and getting the reply is called ARP (Address
Resolution Protocol).
 Almost every machine on the Internet runs it.
 The advantage of using ARP is the simplicity.
RARP—Reverse Address Resolution Protocol

 ARP solves the problem of finding out which Ethernet address corresponds to a given
IP address. Sometimes the reverse problem has to be solved: Given an Ethernet
address, what is the corresponding IP address?
 The solution is to use RARP (Reverse Address Resolution Protocol).
 This protocol allows a newly-booted workstation to broadcast its Ethernet address and
say: My 48-bit Ethernet address is 14.04.05.18.01.25. Does anyone out there know my
IP address?
 The RARP server sees this request, looks up the Ethernet address in its configuration
files, and sends back the corresponding IP address.
Data Delivery by IP

 Delivery refers to the way a packet is handled by the underlying networks under the
control of the network layer.
 The network layer supervises the handling of the packets by the underlying physical
networks.
 This handling is considered as the delivery of a packet.
 The delivery of a packet to its final destination is accomplished by using two different
methods
1. Direct delivery
2. Indirect delivery
Direct Delivery
 Direct delivery occurs when the source and destination of the packet are located on the
same physical network or when the delivery is between the last router and the
destination host.
Indirect Delivery
 If the source and destination both are in different network, the packet is delivered
indirectly.
 In an indirect delivery, the packet goes from router to router until it reaches the
router of the network in which final destination machine is.
 Note also that the last delivery is always a direct delivery so; a delivery always
involves one direct delivery but zero or more indirect deliveries.

You might also like