CN Unit 3 ppt
CN Unit 3 ppt
NETWORK LAYER
Need For Network Layer
F
LAN F LAN
F 2
1
1
WAN
F LAN
F 3 F
LAN F
2 1
2
ROUTING
When independent network or link are connected to create
internetwork or a large network, the connecting devices(router
or switch) routes the packet to their final destination.
Network layer functions
• transport packet from sending to
receiving hosts
application
►Routers.
B
D
A E F
Host H1 LAN H2
C
Packet
?? ?
• preservation of inter-packet circuit
or
timing (no jitter)? datagram
• loss-free delivery? ?
• in-order delivery?
• congestion feedback to
sender?
Virtual circuits
“source-to-dest path behaves much like telephone
circuit”
–performance-wise
–network actions along source-to-dest path
call setup, teardown for each call before data can flow
each packet carries VC identifier (not destination host ID)
every router on source-dest path maintains “state” for each
passing connection
–(in contrast, transport-layer connection only involved two end systems)
link, router resources (bandwidth, buffers) may be allocated to VC
–to get circuit-like performance
Virtual circuits: signaling protocols
• used to set up, maintain, and tear down
VC
• used in ATM, frame-relay, X.25
• not used in today’s Internet
application
6. Receive data
transport
5. Data flow begins
4. Call connected application
networ 3. Accept call transport
networ
k data 1. Initiate call 2. incoming
call k data
link
link
physica
physica
l
l
Datagram networks: the Internet
model
• no call setup at network layer
• routers: no state about end-to-end connections
– no network-level concept of “connection”
• packets typically routed using destination host ID
– packets between same source-dest pair may take
different paths
applicatio
applicatio
n
n
transport
1. Send 2. Receive transport
network
data data network
data link
data link
physical
physical
What’s in a Routing Table?
Des Next
t Hop
B
B B
C
C C A
D
D C
E
E E
F F F G
G F
IMPLEMENTATION OF
CONNECTIONLESS SERVICE
► Packets are injected into the network individually and routed
independently of each other.
► Any advance setup is not required.
► Packets are called datagrams in this context (in analogy with
telegrams).
► The network is called a datagram network.
FIGURE: Routing within a datagram
network.
IMPLEMENTATION OF CONNECTION-
ORIENTED SERVICE
► We require a virtual-circuit (VC) network.
► The idea behind VCs is to avoid having to choose a
new route for every packet sent.
► When a connection is established a route between
source and destination is chosen and stored within
the tables inside the routers.
► That route is used for all traffic flowing over the
connection.
► This is exactly similar to the telephone system.
► When the connection is released, VC is also
terminated.
► With connection-oriented service, each packet
carries an identifier telling which virtual circuit it
belongs to.
FIGURE: Routing within a virtual-circuit
network.
Routing
Routing
protocol
Goal: determine “good” 5
path (sequence of 3
routers) thru network B C 5
2
from source to dest. A 2
3
1 F
Graph abstraction for 1 2
D 1 E
routing algorithms:
• graph nodes are
• “good” path:
routers – typically means minimum cost
• graph edges are path
– other definitions possible
physical links
– link cost: delay, $ cost, or
congestion level
Routing Algorithm
• In order to transfer the packets from source to the destination,
the network layer must determine the best route through which
packets can be transmitted.
• Whether the network layer provides datagram service or virtual
circuit service, the main job of the network layer is to provide
the best route. The routing protocol provides this job.
• The routing protocol is a routing algorithm that provides the
best path from the source to the destination. The best path is
the path that has the "least-cost path" from source to the
destination.
• Routing is the process of forwarding the packets from source to
the destination but the best route to send the packets is
determined by the routing algorithm.
Desirable properties of a routing
algorithm:
1. Correctness
2. Simplicity
3. Robustness
4. Stability
5. Fairness
6. Efficiency.
Classification of a Routing algorithm
The Routing algorithm is divided into two categories:
Adaptive Routing algorithm
Non-adaptive Routing algorithm
Adaptive Routing algorithm
An adaptive routing algorithm is also known as dynamic
routing algorithm.
This algorithm makes the routing decisions based on the
topology and network traffic.
The main parameters related to this algorithm are hop count,
distance and estimated transit time
Takes into account both the topology and the load (But still
static.)
Assumes:
1.Traffic flows remain constant over time.
2.We can estimate the flow between all pairs of routers.
3.We know the topology of the network and the capacity of each
link
4.Given the line capacity and the flow, we can determine the
delay. From that, we can calculate the delay for the whole subnet,
and between any two nodes.
Non-Adaptive
Flow Based Routing
Algorithms Algorithm
(a) (b
)
FIGURE: ((a) A network. (b) The link state packets for this
network.
Adaptive
Hierarchical Routing
Algorithms Algorithm
Divide the network into regions, with a router only knowing the
details of how to route to other routers in its region.
a) In particular, a router does not know about the internal
topology of other regions.
b) Gateway is a router that knows about other regions.
FIGURE: (a) A network. (b) A spanning tree for the leftmost router .
When a process send a multicast packet to a group the first
router examine its spanning tree and remove all lines that
do not lead to host that are members of the group.
Multicast Routing Adaptive
Algorithms Algorithm
FIGURE: (c) A multicast tree for group 1. (d) A multicast tree for
group 2.
62
Reserved IP Network Numbers
Network number Subnet mask IP address range
10.0.0.0 255.0.0.0 10.0.0.1-10.255.255.255
172.16.0.0-172.31.0.0 255.255.0.0 172.16.0.1-172.31.255.255
192.168.0.0 255.255.255.0 192.168.0.1-192.168.255.255
Example
Find the class of each address.
a. 00000001 00001011 00001011 11101111
b. 11000001 10000011 00011011 11111111
c. 14.23.120.8
d. 252.5.15.111
Solution
a. The first bit is 0. This is a class A address.
b. The first 2 bits are 1; the third bit is 0. This is a class C address
c. The first byte is 14; the class is A.
d. The first byte is 252; the class is E.
Subnet Mask
Solution
The binary representation of the given address is
11001101 00010000 00100101 00100111
If we set 32−28 rightmost bits to 0, we get
11001101 00010000 00100101 0010000
or
205.16.37.32.
19.71
Figure A network configuration for the block
205.16.37.32/28
Example
What is the subnetwork address if the destination address is
200.45.34.56 and the subnet mask is 255.255.240.0?
Solution
19.73
Subnetwork
A subnetwork or subnet is a logical subdivision of an IP
network. The practice of dividing a network into two or
more networks is called subnetting.
Subnet Host Count
The number of subnetworks available and the number of
possible hosts in a network may be readily calculated. For
instance, the 192.168.5.0/24 network may be subdivided into
the following four /26 subnets. The highlighted two address
bits become part of the network number in this process.
Network Network (binary) Broadcast address
Given the following Host IP Address, Network Mask and Subnet mask find
the following information:
Subnet Information
Subnet Address
Broadcast Address
Subnetting – Example
Other Subnet Information
Total number of subnets
Step 2:
Determine the Network (or Subnet) where this Host
address lives:
1.Draw a line under the mask
2.Perform a bit-wise AND operation on the IP Address and the
Subnet
Mask
Note: 1 AND 1 results in a 1, 0 AND anything results in a 0
3.Express the result in Dotted Decimal Notation
4.The result is the Subnet Address of this Subnet or “Wire”
which is
138.101.114.192
Step 3: Subnet Range / Host Range
G.D. S.D.
Step 3:
Determine which bits in the address contain Network
(subnet)
information and which contain Host information:
Use the Network Mask: 255.255.0.0 and divide (Great
Divide) the subnet from the hosts between the last “1” and the
first “0” in the subnet mask.
Step 4: First Host / Last Host
G.D. S.D.
11 111010
11 000000
IP Address 10001010 01100101 01110010 000000
11
Mask 11111111 11111111 11111111 host
Network 10001010 01100101 01110010
countin g
subnet
range
counting range
11 000001
First Host Last 193
10001010 01100101 01110010
11 111110
138 101 114
Host Broadcast 254
10001010 01100101 01110010
11 111111
138 101 114
255
1
Last Host: all 1’s and a
0
Broadcast: all 1’s
Step 5: Total Number of Subnets
G.D. S.D.
01110010 11 111010
IP Address 10001010 01100101 11111111 11 000000
Mask 11111111 11111111 01110010 11
Network 10001010 01100101 000000
subnet host
counting range counting
First Host 10001010 01100101 01110010 11 000001
range
138 101 114 193
Total number10001010
Last Host
of hosts 01100101
per subnet
01110010 11 111110
Number138of host bits 101 6 114 254
26Broadcast
= 64 10001010 01100101 01110010 11 111111
138 101 114 255
64 host per subnets
Subtract one for the subnet address
Subtract one for the broadcast address
62 hosts per subnet
Subnet Host Count
The remaining bits after the subnet bits are used for
addressing hosts within the subnet. In the above example,
the subnet mask consists of 26 bits, making it
255.255.255.192, leaving 6 bits for the host identifier. This
allows for 62 host combinations (26−2).
19.85
Solution
Group 1
For this group, each customer needs 256 addresses. This means
that 8 (log2 256) bits are needed to define each host. The prefix
length is then 32 − 8 = 24. The addresses are
Solution
Group 2
For this group, each customer needs 128 addresses. This means
that 7 (log2 128) bits are needed to define each host. The prefix
length is then 32 − 7 = 25. The addresses are
Solution
Group 3
For this group, each customer needs 64 addresses. This means
that 6 (log264) bits are needed to each host. The prefix length
is then 32 − 6 = 26. The addresses are
Solution:
No. of subnet must be power of 2 therefore we design 8 subnets
No.of subnet bits=Log2(8)=3 bits
⚫ QOS Issues
– Multiple methods available
– Non-uniformity across network boundaries
⚫ Security
– No uniformity, myriad methods
– Multitude of methods for “hackers” to attack networks
⚫ Mobility
– Increasing number of wireless/mobile devices
accessing Internet services
– Inadequate support for IP mobility in devices (moving
seamlessly from one network to another)
– 3G & 4G initiatives, 802.11x, Bluetooth, UWB moving
connectivity from wireline to wireless
Why is IPv6 Here :
⚫ IPv6 provides a platform for new Internet functionality
that will be needed in the immediate future, and
provide flexibility for further growth and expansion.
Features of IPv6 :
⚫ Addressing
⚫ Header
⚫ Security
⚫ Privacy
⚫ Auto configuration
⚫ Routing
⚫ Quality of Service
⚫ Cost savings
Continue
⚫ Expanded addressing and routing capabilities
– 128-bit addresses
– Multicast routing is now scalable with “scope” field
– Defined usage of “Any cast” addressing
⚫ Simplified header format
– Some IPv4 fields dropped or made optional
– IPv6 packet header only twice the size of v4 header, even though address is four
times a v4 address
⚫ Extension headers
– “Options” are now placed in separate headers
– “Options” are now any length
– Router doesn’t have to look at most “Options”*
⚫ Auto-configuration
– Self-configuring nodes for local links
– Auto-configuration for site links
– Stateless uses “Router Advertisement”
Continue
⚫ Centralized management
⚫ New “v6” features
⚫ Source Routing
–Support for Source Demand Routing Protocol (SDRP)
–Sender can specify packet route
–Destination can return packet via same route
⚫ Route Aggregation
–Address Hierarchy
–Deployed in “Groups”
IPv6 versus IPv4 :
⚫ No Broadcast in IPv6
– Replaced by Multicast
– Multicast scope provides flexibility
⚫ Uncontrolled fragmentation in IPv4
– Only a source node can fragment IPv6
– Limits packet size to minimum MTU in path
(Maximum Transmission Unit)
⚫ Other features inherent to IPv6
- Security encryption
- Header encryption
- Sender authentication
- Privacy
Congestion
►ifthe load on the network i.e.the number of packets sent to the
network is greater than the capacity of the network or the
number of packets a network can handle.
►Too many packets present in (a part of) the network causes
packet delay and loss that degrades performance.
►This situation is called congestion.
►The network and transport layers share the responsibility for
handling congestion.
►Since congestion occurs within the network, it is the network
layer that directly experiences it and must ultimately
determine what to do with the excess packets.
Congestion
►However, the most effective way to control congestion is to
reduce the load that the transport layer is placing on the
network.
►This requires the network and transport layers to work
together.
Causes of Congestion
• Congestion occurs when a router receives data faster
than it can send it
– Insufficient bandwidth
– Slow hosts
– Data simultaneously arriving from multiple lines
destined for the same outgoing line.
• The system is not balanced
– Correcting the problem at one router will probably
just move the bottleneck to another router.
Congestion Causes More Congestion
– Incoming messages must be placed in queues
• The queues have a finite size
– Overflowing queues will cause packets to be dropped
– Long queue delays will cause packets to be resent
– Dropped packets will cause packets to be resent
• Senders that are trying to transmit to a congested
destination also become congested
– They must continually resend packets that have been
dropped or that have timed-out
– They must continue to hold utgoing/unacknowledged
messages in memory.
Congestion Control
• Congestion control refers to techniques and mechanisms that
can either prevent congestion, before it happens, or remove
congestion, after it has happened.
Open-Loop Congestion Control
In open-loop congestion control, policies are applied to prevent
congestion before it happens. In these mechanisms, congestion
control is handled by either the source or the destination.
Retransmission Policy :
Retransmission is sometimes unavoidable.
If the sender feels that a sent packet is lost or corrupted, the
packet needs to be retransmitted. Retransmission in general may
increase congestion in the network.
So good retransmission policy can prevent congestion. So the
retransmission policy and the retransmission timers must be
designed to optimize efficiency and at the same time prevent
congestion.
Window Policy :
The type of window at the sender may also affect congestion.
The Selective Repeat window is better than the Go-Back-N
window for congestion control.
Acknowledge Policy :
If the receiver does not acknowledge every packet it receives, it
may slow down the sender and help prevent congestion.
A receiver may send an acknowledgment only if it has a packet
to be sent or a special timer expires.
A receiver may decide to acknowledge only N packets at a time.
Window Policy :
The type of window at the sender may also affect congestion.
The Selective Repeat window is better than the Go-Back-N
window for congestion control.
Acknowledge Policy :
If the receiver does not acknowledge every packet it receives, it
may slow down the sender and help prevent congestion.
A receiver may send an acknowledgment only if it has a packet
to be sent or a special timer expires.
A receiver may decide to acknowledge only N packets at a time.
Closed-Loop Congestion Control
Closed-loop congestion control mechanisms try to alleviate
congestion after it happens. Several mechanisms have been
used by different protocols.
Backpressure :
in which a congested node stops receiving data from the
immediate upstream node or nodes.
This may cause the upstream node or nodes to become
congested, and they, in turn, reject data from their upstream
nodes or nodes.
Continue
Node III in the figure has more input data than it can handle. It
drops some packets in its input buffer and informs node II to
slow down.
Node II, in turn, may be congested because it is slowing down
the output flow of data. If node II is congested, it informs node
I to slow down, which in turn may create congestion.
If so, node I inform the source of data to slow down. This, in
time, alleviates the congestion.
Choke Packet :
A choke packet is a packet sent by a node to the source to
inform it of congestion.
In the choke packet method, the warning is from the router,
which has encountered congestion, to the source station
directly.
Continue.
Node III in the figure has more input data than it can handle. It
drops some packets in its input buffer and informs node II to slow
down.
Node II, in turn, may be congested because it is slowing down the
output flow of data. If node II is congested, it informs node I to
slow down, which in turn may create congestion.
If so, node I inform the source of data to slow down. This, in time,
alleviates the congestion.
Choke Packet :
A choke packet is a packet sent by a node to the source to inform
it of congestion.
In the choke packet method, the warning is from the router,
which has encountered congestion, to the source station directly.
Implicit Signaling :
In implicit signaling, there is no communication between the
congested node or nodes and the source.
The source guesses that there is congestion somewhere in the
network from other symptoms.
For example, when a source sends several packets and there is
no acknowledgment for a while, one assumption is that the
network is congested so the source should slow down.
Exmplicit Signaling :
The node that experiences congestion can explicitly send a
signal to the source or destination.
The signal is included in the packets that carry data. Explicit
signaling, in Frame Relay congestion control, can occur in either
the forward or the backward direction.
• (i) Backward Signaling
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.
(Ii) Forward Signaling
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.
Open-Loop Control
• Network performance is guaranteed to all traffic flows that
have been admitted into the network
• Initially for connection-oriented networks
• Key Mechanisms
– Admission Control
– Policing
– Traffic Shaping
– Traffic Scheduling
Admission Control
• Flows negotiate contract
with network
Peak rate • Specify requirements:
– Peak, Avg., Min Bit rate
– Maximum burst size
Average rate – Delay, Loss requirement
• Network computes
resources needed
– “Effective” bandwidth
• If flow accepted, network
allocates resources to
Time ensure QoS delivered as
Typical bit rate demanded by a long as source conforms to
variable bit rate information contract
source
Policing
• Network monitors traffic flows continuously to ensure they
meet their traffic contract
• When a packet violates the contract, network can discard or
tag the packet giving it lower priority
• If congestion occurs, tagged packets are discarded first
• Leaky Bucket Algorithm is the most commonly used policing
mechanism
– Bucket has specified leak rate for average contracted rate
– Bucket has specified depth to accommodate variations in arrival
rate
– Arriving packet is conforming if it does not result in overflow
Traffic Shaping
• Another method of congestion control is to “shape” the
traffic before it enters the network.
• Traffic shaping controls the rate at which packets are sent
(not just how many). Used in ATM and Integrated Services
networks.
• At connection set-up time, the sender and carrier negotiate
a traffic pattern (shape).
• Two traffic shaping algorithms are:
– Leaky Bucket
– Token Bucket
116
The Leaky Bucket Algorithm
• The Leaky Bucket Algorithm used to control rate in a
network. It is implemented as a single-server queue with
constant service time. If the bucket (buffer) overflows then
packets are discarded.
• The leaky bucket enforces a constant output rate (average
rate) regardless of the burstiness of the input. Does nothing
when input is idle.
• The host injects one packet per clock tick onto the network.
• This results in a uniform flow of packets, smoothing out
bursts and reducing congestion.
117
The Leaky Bucket Algorithm
(a) A leaky bucket with water. (b) a leaky bucket with packets.
118
• When packets are the same size (as in ATM cells), the one
packet per tick is okay. For variable length packets
though, it is better to allow a fixed number of bytes per
tick. E.g. 1024 bytes per tick will allow one 1024-byte
packet or two 512-byte packets or four 256-byte packets
on 1 tick.
119
Leaky Bucket Traffic Shaper
Size
Incoming traffic N Shaped traffic
Ser
ver
Packet
32
The Token Bucket Algorithm
5-
34
Packet
•Token rate regulates transfer of packets
•If sufficient tokens available, packets enter network without delay
•K determines how much burstiness allowed into the network
Leaky Bucket vs Token Bucket
125
Load Shedding
• When buffers become full, routers simply discard packets.
• Which packet is chosen to be the victim depends on the
application and on the error strategy used in the data link
layer.
• For a file transfer, for, e.g. cannot discard older packets
since this will cause a gap in the received data.
•For real-time voice or video it is probably better to throw
away old data and keep new packets.
• Get the application to mark packets with discard priority.
126
IP Address
IP was designed as a best-effort delivery protocol, but it lacks
some features such as flow control and error control. It is a
host-to-host protocol using logical addressing.
To make IP more responsive to some requirements in today's
internetworking, we need the help of other protocols.
We need protocols to create a mapping between physical and
logical addresses.(ARP)
IP packets use logical (host-to-host) addresses. These packets,
however, need to be encapsulated in a frame, which needs
physical addresses (node-to-node).
sometimes need reverse mapping-mapping a physical address to
a logical address. (RARP) Lack of flow and error control in the
Internet Protocol has resulted in another protocol, ICMP, that
provides alerts. It reports congestion and some types of
errorsin the network or destination host.
Address Mapping
An internet is made of a combination of physical networks
connected by internetworking devices such as routers.
A packet starting from a source host may pass through several
different physical networks before finally reaching the
destination host.
The hosts and routers are recognized at the network level by
their logical (IP) addresses. However, packets pass through
physical networks to reach these hosts and routers. At the
physical level, the hosts and routers are recognized by their
physical addresses.
A physical address is a local address. Its jurisdiction is a local
network. It must be unique locally, but is not necessarily
unique universally. It is called a physical address because it is
implemented in hardware.
Address Mapping
The physical address and the logical address are two different identifiers. We need both.
Delivery of a packet to a host or a router requires two levels of addressing: logical and
physical. We need to be able to map a logical address to its corresponding physical
address and vice versa.
These can be done by using either static or dynamic mapping.
Static mapping involves in the creation of a table that associates a logical address with a
physical address. This table is stored in each machine on the network.
Each machine that knows, for example, the IP address of another machine but not its
physical address can look it up in the table.
Static mapping as several limitation as physical address may change due to change in
network card or physical network
To implement these changes, a static mapping table must be updated periodically. This
overhead could affect network performance.
Mapping Logical to Physical
Address: ARP
Anytime a host or a router has an IP datagram to send to another
host or router, it has the logical (IP) address of the receiver. The
logical (IP) address is obtained from the DNS if the sender is the
host or it is found in a routing table the sender is a router.
But the IP datagram must be encapsulated in a frame to be able
to pass through the physical network. This means that the
sender needs the physical address of the receiver. The host or
the router sends an ARP query packet.
The packet includes the physical and IP addresses of the sender
and the IP address of the receiver.
Because the sender does not know the physical address of the
receiver, the query is broadcast over the network.
ARP operation
Continue
Every host or router on the network receives and processes the
ARP query packet, but only the intended recipient recognizes
its IP address and sends back an ARP response packet.
The response packet contains the recipient's IP and physical
addresses. The packet is unicast directly to the inquirer by
using the physical address received in the query packet.
Cache Memory
Using ARP is inefficient if system A needs to broadcast an ARP
request for each IP packet it needs to send to system B. It
could have broadcast the IP packet itself.
ARP can be useful if the ARP reply is cached (kept in cache
memory for a while) because a system normally sends several
packets to the same destination. A system that receives an ARP
reply stores the mapping in the cache memory and keeps it for
20 to 30 minutes unless the space in the cache is exhausted.
Before sending an ARP request, the system first checks its
ARP packet
Continue
o Hardware type. This is a 16-bit field defining the type of the
network on which ARP is running. Each LAN has been assigned
an integer based on its type. For example, Ethernet is given
type 1. ARP can be used on any physical network.
o Protocol type. This is a 16-bit field defining the protocol. For
example, the value of this field for the IPv4 protocol is 080016,
ARP can be used with any higher-level protocol.
o Hardware length. This is an 8-bit field defining the length of the
physical address in bytes. For example, for Ethernet the value
is 6.
o Protocol length. This is an 8-bit field defining the length of the
Continue
o Sender hardware address. This is a variable-length field defining the
physical address of the sender.
For example, for Ethernet this field is 6 bytes long.
o Sender protocol address. This is a variable-length field defining the
logical (for example, IP) address of the sender. For the IP protocol, this
field is 4 bytes long.
o Target hardware address. This is a variable-length field defining the
physical address of the target. For example, for Ethernet this field is 6
bytes long. For an ARP request message, this field is alI 0s because the
sender does not know the physical address of the target.
o Target protocol address. This is a variable-length field defining the
logical (for example, IP) address of the target. For the IPv4 protocol,
this field is 4 bytes long.
Encapsulation
An ARP packet is encapsulated directly into a
data link frame.