You are on page 1of 94

1502346 - Computer Communications and

Networks
Dr. Mohamed Saad
Department of Computer Engineering
University of Sharjah

msaad@sharjah.ac.ae

Chapter 5: The Network Layer


M. Saad

The Network Layer

• The network layer is concerned with getting 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.

• This function clearly contrasts with that of the data link layer, which
has the goal of moving frames from one end of a link (e.g., wire) to the
other.

1502346 - Computer Communications & Networks 1


M. Saad

Functions of the Network Layer

• Knowing about the topology of the subnet and choosing the appropriate
paths through it → routing

• Avoiding overloading some of the links while leaving the others idle →
congestion control

• Dealing with the situation when the source and destination are on
different networks → internetworking

1502346 - Computer Communications & Networks 2


M. Saad

Store-and-Forward Packet Switching


Router Carrier's equipment

B D

H1 H2
Process P2
A E F
1

C LAN
Process P1 Packet

• Carrier’s equipment: routers connected by transmission lines (inside shaded oval).


• Customer’s equipment: hosts (outside shaded oval).
• Host H1 is connected to the subnet by a leased line. Host H2 is connected to the
subnet through a LAN and router F that is owned and operated by the customer.
• A host with a packet to send, transmits the packet to the nearest router in the
subnet. The packet is stored , then forwarded from router to router until it reaches the
destination

1502346 - Computer Communications & Networks 3


M. Saad

Services Provided to the Transport Layer

• The network layer may provide two types of services to the transport
layer: connection-oriented service and connectionless service.

• Connectionless service:
– No advance setup is needed.
– Packets are injected into the subnet individually, and routed independently.
– Packets (in this context) are frequently called datagrams.
– The subnet is called datagram subnet.

• Connection-oriented service:
– A path from the source router to the destination router must be established before
any packet is sent.
– This path is called virtual circuit (VC).
– The subnet is known as virtual-circuit subnet.

1502346 - Computer Communications & Networks 4


M. Saad

Connectionless Service
Packet Router Carrier's equipment

B D
4
H1 H2
1 Process P2
A E F
3 2

Process P1 LAN
C

A's table
initially later C's table E's table
A – A – A A A C
B B B B B A B D
C C C C C – C C
D B D B D D D D
E C E B E E E –
F C F B F E F F

Dest. Line
Destination Next Hop

1502346 - Computer Communications & Networks 5


M. Saad

Connectionless Service (contd.)

• Process P1 on host H1 has a long message to send to process P2 on host H2.


• Assume the message is 4 times longer than the maximum packet size → the network
layer of H1 breaks the message into four packets: 1, 2, 3 and 4.
• The packets are sent to router A.
• The packets are stored on A briefly (to verify their checksum), then forwarded to the
next node according to A’s routing table.
• Packets 1, 2 and 3 are routed from A to C to E to F.
• Then A’s routing table changed (perhaps because A learnt of a traffic jam somewhere
along the A-C-E path). Packet 4 is routed along a different route.
• Algorithm that manage the routing tables is known as routing algorithms

1502346 - Computer Communications & Networks 6


M. Saad

Connection-oriented Service

H3 Router Carrier's equipment


Process
P3

B D

H1 H2
1 Process P2
A E F
4
2
3
Process P1 LAN
C

A's table C's table E's table


H1 1 C 1 A 1 E 1 C 1 F 1 VC: H1-A-C-E-F-H2
H3 1 C 2 A 2 E 2 C 2 F 2
VC: H3-A-C-E-F-H2
In Out

1502346 - Computer Communications & Networks 7


M. Saad

Connection-Oriented Service (contd.)

• When a connection is established, a route (virtual circuit) from the source


machine to the destination machine is chosen and stored in tables inside
the routers. All packets of the connection are sent over this route.

• Example:
– Host H1 establishes connection 1 with host H2. This connection is stored in the
first entry of the routing tables.
– The first line is A’s table says that any packet bearing connection identifier 1 comes
from H1, and is to be sent to C, and given connection identifier 1. Similarly, the
first line in C’s table routes the packet to E, also with connection identifier 1.
– Now H3 wants to establish a connection to H2. It chooses connection identifier 1
because it has no other connection. This leads to the second line in the tables. To
avoid a conflict, A assigns a different identifier to the outgoing packets
– Routers need the ability to replace connection identifiers (known as label switching
in some contexts).

1502346 - Computer Communications & Networks 8


M. Saad

Comparison

1502346 - Computer Communications & Networks 9


M. Saad

Routing Algorithms

• Packet forwarding: deciding which outgoing link the packet should be


transmitted on, by looking it up in the routing tables.

• Routing algorithm: responsible for updating the routing tables.

• If virtual circuits are used, a decision has to be made when a new virtual
circuit is set up.

• If datagrams are used, a decision has to be made for every arriving


packet.

1502346 - Computer Communications & Networks 10


M. Saad

Routing Optimality

• Routes are chosen as to optimize a certain objective. Example objectives:


– Minimize mean packet delay
– Maximize network throughput
– Minimize number of hops

• The optimality principle: Consider the optimal path between routers I


and K. Let router J be on this optimal path. Then the optimal path
between J and K lies falls also on the same route.
– Consider the optimal route from I to K. Let r1 denote the part of the route from I
to J, and let r2 denote the part of the route from J to K. If a route better than r2
existed between J and K, it could be concatenated with r1 to obtain a better route
from I to K, contradicting our statement that r1r2 is optimal.

1502346 - Computer Communications & Networks 11


M. Saad

Shortest Path Routing

• The network is represented as a graph , with each node in the


graph representing a router, and each link in the graph representing
a communication line (or link).

• Each link in the graph has a weight that represents its length.

• To find a path between a pair of routers, the algorithm finds the shortest
path between the corresponding nodes in the graph.

1502346 - Computer Communications & Networks 12


M. Saad

Dijkstra Shortest Path Algorithm

B 7 C B (2, A) C (∞, −)
2 3
2 3
E 2 F E (∞, −)
A D A F (∞, −) D (∞, −)
1 2
6 4 2

G H G (6, A) H (∞, −)
(a) (b)

B (2, A) C (9, B) B (2, A) C (9, B)

E (4, B) E (4, B)
A F (∞, −) D (∞,−) A F (6, E) D (∞,1)

G (6, A) H (∞, −) G (5, E) H (∞, −)


(c) (d)

B (2, A) C (9, B) B (2, A) C (9, B)

E (4, B) E (4, B)
A F (6, E) D (∞,−) A F (6,E) D (∞,−)

G (5, E) H (9, G) G (5, E) H (8, F)


(e) (f)

1502346 - Computer Communications & Networks 13


M. Saad

Dijkstra Algorithm
• We want to find the shortest path from A to D. Each node is labeled with the distance
from the source node along the best known path.
• Initially: all labels are tentative , and infinity (because no paths are known yet).
(a) We start by marking the source node A as permanent (indicated by a black circle).
(b) Then we examine each node adjacent to A (nodes B and G). Each node is relabeled
with the distance to A (B is labeled by (2,A) and G by (6,A)). We choose the node
with the smallest tentative label and mark it permanent (B is marked permanent).
This node (here B) becomes the new working node.
(c) We examine each node adjacent to B (nodes C and E). If {label of B + distance
from B to C (respectively E) < current label of C (respectively E)}, we have a
shorter path, and the node is relabeled. C is labeled (9,B) → the distance from A
to C is 9, and the path found so far goes through B. Similarly, E is labeled (4,B).
We choose the node with the smallest tentative label and mark it permanent (E is
marked permanent). This node (here E) becomes the new working node.
(d) Step (c) is repeated until all nodes are permanently labeled. The labels will give us
the shortest path from source to destination (A to D) and its length.

1502346 - Computer Communications & Networks 14


M. Saad

Variations

• If the weight of each link is 1, then the Dijkstra algorithm will provide
the path with the smallest number of hops.

• If the weight of each link is the packet delay over the link, then Dijkstra
algorithm will provide the path with the smallest delay (fastest path).

1502346 - Computer Communications & Networks 15


M. Saad

Distance Vector Routing

• Distance vector routing is a dynamic routing algorithm.

• Each router maintains a table (i.e., a vector) giving the best known path
to each destination, and which outgoing link to use to get there.

• These tables are updated by exchanging information with the neighbors.

• It was the original ARPANET routing algorithm, and it was also used in
the Internet.

1502346 - Computer Communications & Networks 16


M. Saad

Distance Metric

• The routing table of router A has an entry or each destination in the network.
• This entry has 2 parts: the preferred outgoing link to the destination, and an estimate
of the distance to the destination.
• The distance metric used may be the number of hops, the time delay (in milliseconds),
the total number of packets queued along the link, . . . etc.
• Each router knows the distance to its neighbors.
– If the metric used is hops, the distance to each neighbor is 1.
– If the metric used is delay, the router sends to each neighbor a special ECHO
packet. Neighbors send the ECHO packet back to the sender as fast as possible. By
measuring the round-trip time and dividing it by 2, the sending router can get an
estimate of the delay to its neighbors.

1502346 - Computer Communications & Networks 17


M. Saad

The Algorithm
• Once every T msec each router sends to each neighbor a list of estimated
delays to each destination. It also receives a similar list from each
neighbor.

• Imagine that one of these tables has just come in from neighbor X to
router Y , with Xi being the estimated delay from router X to router
i. Router Y knows that its delay to router X is m (msec). It can thus
compute that it can reach router i via X in Xi + m (msec).

• By performing this calculation for every neighbor, router Y can find out
the best distance to every destination, and updates its routing table
accordingly.

• The following example clarifies the algorithm.

1502346 - Computer Communications & Networks 18


M. Saad

Example

New estimated
Router delay from J
A B C D To A I H K Line
A 0 24 20 21 8 A
B 12 36 31 28 20 A
C 25 18 19 36 28 I
F G D 40 27 8 24 20 H
E H
E 14 7 30 22 17 I
F 23 20 19 40 30 I
G 18 31 6 31 18 H
H 17 20 0 19 12 H
I J K L
I21 0 14 22 10 I
J 9 11 7 10 0 −
K 24 22 22 0 6 K
L 29 33 9 9 15 K
JA JI JH JK
delay delay delay delay New
is is is is routing
8 10 12 6 table
for J
Vectors received from
J's four neighbors
(a) (b)

1502346 - Computer Communications & Networks 19


M. Saad

Example (contd.)

• Consider router J.
• The neighbors of J are: A, I, H and K.
• J measures the delay to neighbors A, I, H and K as 8, 10, 12 and 6, msec respectively.
• The first 4 columns of part (b) show the delay vectors received from the neighbors of
J. In particular, A claims to have a 12 msec delay to B, a 25 msec delay to C, a 40
msec delay to D, . . . etc.
• Consider how J computes its new route to G. J knows that it can reach A in 8 msec,
and A claims that it can reach G in 18 msec, so J finds out that it can reach G in
8 + 18 = 26 msec via router A. Similarly, it computes the delay to G via I, H and K
as 41 (31+10), 18 (6+12) and 37 (31+6), respectively.
• The best of these values is 18. So router J makes an entry in its new routing table that
the delay to G is 18, and the route to use is via H.
• The same calculation is done for all the other destinations, and the new routing table
is shown in the last column of the figure.

1502346 - Computer Communications & Networks 20


M. Saad

Link State Routing

• Distance vector routing was used in the ARPANET until 1979, then it
was replaced by link state routing. One reason, is that distance vector
routing took too long to converge.

• The idea behind link state routing can be stated as 5 parts. Each router
must do the following:
1. Discover its neighbors and learn their network address.
2. Measure the delay or cost to each of its neighbors.
3. Construct a packet containing the delays to all neighbors.
4. Send this packet to all other routers in the network.
5. Compute the shortest path to every other router.

1502346 - Computer Communications & Networks 21


M. Saad

Learning about the Neighbors

• When a router is booted, it sends a HELLO packet on each outgoing


link.

• The router on the other side of the link sends a reply packet containing
its network address.

1502346 - Computer Communications & Networks 22


M. Saad

Measuring Link Costs

• Every router sends to each neighbor a special ECHO packet.

• Neighbors send the ECHO packet back to the sender as fast as possible.

• By measuring the round-trip time and dividing it by 2, the sending router


can get an estimate of the delay to its neighbors.

1502346 - Computer Communications & Networks 23


M. Saad

Building Link State Packets

B 2 C Link State Packets


A B C D E F
4 3 Seq. Seq. Seq. Seq. Seq. Seq.
A D Age Age Age Age Age Age
1 6 B 4 A 4 B 2 C 3 A 5 B 6
5 7
E 5 C 2 D 3 F 7 C 1 D 7
E 8 F F 6 E 1 F 8 E 8

(a) (b)

• Each router builds a link state packet at regular intervals or when a


significant event (such as a network failure) occurs.

1502346 - Computer Communications & Networks 24


M. Saad

Distributing the Link State Packets

• Flooding is used to send the link state packets to all routers in the network.
• Each link state packet contains a Sequence Number that is incremented for each new
link state packet sent.
• When a router receives a link state packet, it compares its Sequence Number against
packets already seen. If it is new, the link state packet is forwarded on all outgoing
links except the link it came from. If it is duplicate, the packet is discarded.
• Link state packets contain an Age field. The Age is set to a certain value when the
link state packet is created. The age is decremented by each router that forwards the
packet during the flooding process. When the Age hits zero, the packet is discarded
(to prevent link state packets from traveling in the network indefinitely).
• Eventually, every router receives a link state packet from every other router.

1502346 - Computer Communications & Networks 25


M. Saad

Computing the Shortest Paths

• Once a router has received all link state packets it can construct the
entire graph of the network (it has complete topology information).

• A Dijkstra algorithm is used to compute the shortest path to every


destination.

• Routing tables are updated accordingly.

1502346 - Computer Communications & Networks 26


M. Saad

Congestion Control
Perfect

Maximum carrying
capacity of subnet

Packets delivered
Desirable

Congested

Packets sent

• When the number of packets injected to the subnet is within its capacity, they are all
delivered (except the few that have transmission errors).
• As traffic increases beyond the network capacity, the routers are no longer able to cope
and they begin losing packets.
• At very high traffic, performance collapses completely, and almost no packets are
delivered.

1502346 - Computer Communications & Networks 27


M. Saad

Congestion Control vs. Flow Control

• Congestion control: makes sure the communication links are not


overloaded with traffic, and that the subnet is able to carry the offered
traffic.
– Congestion control is a global issue involving all hosts and routers.

• Flow control: makes sure a fast sender does not transmit data faster
than a receiver is able to absorb it (makes sure a fast transmitter does
not overwhelm a slow receiver with traffic).
– Flow control relates to the point-to-point traffic between a given sender and a given
receiver.

1502346 - Computer Communications & Networks 28


M. Saad

Congestion Prevention Policies


• These techniques attempt to prevent congestion, rather than letting it
happen and reacting after the fact.
– At the data link layer: a router that uses the go-back-N retransmission strategy will
retransmit all packets in its buffer, possibly causing congestion ⇒ selective repeat is
better than go-back-N in the context of congestion (it retransmits only the packet
with errors).
– At the network layer: the choice between using virtual circuits and datagrams affects
congestion since congestion control is easier in virtual-circuit subnets.
– At the network layer: a good routing algorithm can help avoid congestion by
balancing the traffic over all links, rather than sending the traffic over links that are
already congested.
– At the network layer: Packet lifetime (age) management affects congestion; if it is
too long, lost packets may congest the network, and if it is too short, packets may
be discarded before they reach their destinations, thus casuing retransmissions and
more congestion.

1502346 - Computer Communications & Networks 29


M. Saad

Congestion Control in Virtual-Circuit Subnets

• Techniques that can be used to dynamically control congestion in virtual-


circuit subnets:
1. Admission control
2. Carefully route new virtual circuits around congested areas
3. Resource reservation

• Admission control:
– Once congestion has been reported, no more virtual circuits are set up until the
problem has been solved (this approach is crude, but simple).
– Attempts to set up new transport layer connections fail.
– In the telephone system, when a switch gets overloaded, it also practices admission
control by not giving dial tones.

1502346 - Computer Communications & Networks 30


M. Saad

Carefully Routing Virtual Circuits

Congestion A
A

B
B
Virtual
circuit

Congestion

(a) (b)

• Router A wants to establish a new virtual circuit with router B.


• Normally, this connection would pass through one of 2 congested routers.
• We redraw the subnet, as shown in (b), omitting the congested routers.
• The dashed line shows a possible route for the virtual circuit that avoids the congested
routers.

1502346 - Computer Communications & Networks 31


M. Saad

Resource Reservation for Virtual Circuits

• The host negotiates an agreement with the subnet when a virtual circuit is set up.
• The agreement specifies the data rate, quality-of-service (QoS) requirements and other
parameters.
• The subnets typically reserves resources (e.g., bandwidth and buffer space) along the
path when the virtual circuit is set up.
• In this case, congestion is unlikely to occur because all the necessary resources are
guaranteed to be available.
• Resource reservation can be done all the time, or when the subnet is congested.
– Disadvantage of resource reservation all the time is the waste of resources.
– If 6 virtual circuits (that are reserved 1 Mbps each) pass through the same 6
Mbps-line, the line is marked as full, even though it may rarely happen that the 6
virtual circuits transmit at full rate.

1502346 - Computer Communications & Networks 32


M. Saad

Congestion Control in Datagram Subnets

• Routers can monitor the utilization of its outgoing links.

• When the utilization of one of the outgoing links moves above a certain
threshold, the link enters a “warning” state.

• The outgoing link of a newly arrived packet is in warning state, one of


these actions can be taken:
– The warning bit
– Choke packets
– Hop-by-Hop choke packets

1502346 - Computer Communications & Networks 33


M. Saad

The Warning Bit

• Routers set a special bit in the header of the packets.

• When the packet reaches the destination, the warning bit is copied in
the next acknowledgement sent back to the source.

• The source responds by reducing its data rate.

• Since every router along the path could set the warning bit, the source
increases the traffic only when no router is in trouble.

1502346 - Computer Communications & Networks 34


M. Saad

Choke Packets

• When a router forwards a packet along a congested link, it sends a special choke packet
directly back to the source, identifying the destination of the packet.
• The original packet is tagged (a header bit is set) so that the packet will not generate
any more choke packets along its path.
• When the source gets the choke packet, it reduces the traffic sent by X percent.
• Since other packets aimed at the same destination are probably under way and will
generate yet more choke packets, the source will ignore choke packets referring to the
same destination for a fixed time interval.
• After that period has expired, the source listens for more choke packets for another
interval. If one arrives, the source reduces the traffic even more because there is still a
congested link.
• If no choke packets arrive during the listening period, the source may increase the
traffic flow again.

1502346 - Computer Communications & Networks 35


M. Saad

Choke Packets Example


B C B C

A D A D

Heavy flow
E F E F

ke

ke
o

o
Ch

Ch
Choke Choke
Reduced
flow

Ch

Ch
ok

ok
e

e
Reduced
flow

Flow is still
at maximum rate

Flow is
reduced

(a) (b)

1502346 - Computer Communications & Networks 36


M. Saad

Hop-by-Hop Choke Packets

• At high speeds or over long distances, sending a choke packet to the source does not
work well because the reaction is slow (as seen in part (a) of the previous figure).
• Another approach is to have the choke packet take effect at every hop it passes through,
as shown in part (b) of the previous figure.
• Here D sends a choke packet. As soon as the choke packet reaches F, it is required to
reduce the traffic.
• Doing so, F will need to allocate more buffer space to the flow, since the source is still
sending at high rate. D, however, gets an immediate relief from congestion.
• In the next step, the choke packet reaches E, which reduces the traffic and increases
the buffer space allocated to the flow (to relief F).
• Finally, the choke packet reaches A and the flow genuinely slows down.

→ the net effect is giving quick relief to the point of congestion at the cost of
using up more buffer space.

1502346 - Computer Communications & Networks 37


M. Saad

Random Early Detection

• Introduced by Floyd and Jacobsen in 1993.


• Routers maintain a running average of their queue length.
• When the average queue length exceeds a threshold, the link is said to be congested
and an action is taken.
• Router action: Since the router cannot tell which source is causing the congestion, it
selects a packet at random and drops it.
• Source action: The source will eventually notice the lack of acknowledgement. Since the
source known that lost packets are generally caused by congestion (in wired networks),
it will slow down the transmission rate.
• In fact, some transport protocols (e.g., TCP) respond to a lost packet by slowing down
transmission.

1502346 - Computer Communications & Networks 38


M. Saad

Quality of Service

• We have studies techniques that reduce network congestion and improve


the network performance.

• With the growth of multimedia applications, often these techniques are


not enough.

• Serious attempts to guarantee Quality of Service (QoS) are needed.

1502346 - Computer Communications & Networks 39


M. Saad

Quality of Service Requirements

• A stream of packets from a source to a destination is called a flow.

• A flow can have 4 primary QoS requirements:


1. Reliability (packets will be delivered with no errors)
2. Delay
3. Jitter (the variation/standard deviation in packet delays)
4. Bandwidth

• Different applications have different QoS requirements.

1502346 - Computer Communications & Networks 40


M. Saad

Application QoS Requirements

• E-mail, file transfer, web access and remote login have stringent requirements on
reliability (error control codes must be used).
• Audio/video applications can tolerate errors.
• File transfer applications (e.g., e-mail, audio on demand (from a server) and video on
demand (from a server)) are not delay-sensitive.
• Interactive applications (e.g., web access and remote login) are somewhat delay sensitive.
• Real-time applications (e.g., telephony and videoconferencing) have strict delay
requirements.
• Video applications have strict bandwidth requirements.
• Audio and video applications are extremely sensitive to jitter.

1502346 - Computer Communications & Networks 41


M. Saad

Application QoS Requirements (contd.)

1502346 - Computer Communications & Networks 42


M. Saad

Techniques for Achieving Good QoS

• No single technique provides efficient QoS in an optimal way.

• A variety of techniques have been developed, with practical solutions


often combining multiple techniques.

• QoS techniques can be summarized as:


– Overprovisioning
– Buffering
– Traffic shaping
– Resource reservation
– Admission control
– Multipath routing
– Packet scheduling

1502346 - Computer Communications & Networks 43


M. Saad

Overprovisioning

• Provide more router capacity, buffer space and bandwidth than the traffic
needs.

• As a result, packets will just fly through easily.

• Disadvantage → expensive.

• Problem → how much more capacity/buffer space/bandwidth is enough?


(not easy)

• The telephone system is overprovisioned, it is rare to pick up the phone


and not get a dial tone instantly.

1502346 - Computer Communications & Networks 44


M. Saad

Buffering
• Packets can be buffered at the receiving end before they are delivered.
• Buffering does not affect reliability or bandwidth, it increases the delay, but it reduces
the jitter.
• Jitter is the main problem in audio and video on demand applications, so this technique
is very useful.

Packet departs source 1 2 3 4 5 6 7 8

Packet arrives at buffer 1 2 3 4 5 6 7 8

Time in buffer
Packet removed from buffer 1 2 3 4 5 6 7 8
Gap in playback
0 5 10 15 20
Time (sec)

• Packets 1-6 are buffered.


• Playback of the packets begins at t = 10 sec → packets 1-6 are removed from the
buffer at uniform intervals for smooth play.

1502346 - Computer Communications & Networks 45


M. Saad

Traffic Shaping

• Buffering is used to smooth the flow of packets at the receiver (client)


side.

• Buffering is not always possible, e.g., in videoconferencing.

• Traffic shaping is used to smooth the flow of traffic at the sender (server)
side.

1502346 - Computer Communications & Networks 46


M. Saad

The Leaky Bucket Traffic Shaping Algorithm


Faucet
Host
computer

Packet

Unregulated
flow
Leaky
bucket The bucket
Water Interface holds
containing packets
a leaky bucket
Regulated
flow
Water drips out of the
hole at a constant rate

Network

(a) (b)

• The leaky bucket algorithm can be implemented using a finite size queue (buffer) with
a constant service rate.
• An arriving packet enters the queue if there is room in the queue; an arriving packet is
discarded if the queue is full.
• Packets leave the queue at a constant rate.

1502346 - Computer Communications & Networks 47


M. Saad

Quality of Service (contd.)

• QoS techniques can be summarized as:


– Overprovisioning
– Buffering
– Traffic shaping

– Resource reservation
– Admission control
– Multipath routing
– Packet scheduling

1502346 - Computer Communications & Networks 48


M. Saad

Resource Reservation

• Being able to regulate the shape of the offered traffic (using, e.g., a leaky
bucket shaper) is a good start to guaranteeing QoS.

• Traffic shaping, however, is not enough to guarantee QoS, especially that


packets may take different routes.

• Solution: combine traffic shaping with the use of virtual circuits, and
resource reservation.

• Resource reservation: reserve the necessary resources along the route of


a flow.

1502346 - Computer Communications & Networks 49


M. Saad

Resource Reservation (contd.)


• 3 different kinds of resources can be reserved:
– Bandwidth
– Buffer space
– CPU cycles

• Reserve the necessary bandwidth on each link of the flow’s route, such
that each flow gets the bandwidth it requires, and the links are not
oversubscribed.

• For good quality of service, some buffer space can be reserved for a
specific flow so that packets will not be discarded.

• It takes a router CPU time to process a packet. Reserving CPU cycles


for a flow ensures the timely processing of each packet.

1502346 - Computer Communications & Networks 50


M. Saad

Admission Control

• Now, the offered traffic of each flow is well-shaped, the packets follow
a single route (virtual circuit), and the necessary resources are reserved
along the route.


• Future flows may have to be rejected because there are not enough
network resources.


• Traffic shaping/resource reservation has to be combined with admission
control.

1502346 - Computer Communications & Networks 51


M. Saad

Multipath Routing

• Most routing algorithms (e.g., link state routing) try to find the best
path to each destination, and send all traffic to that destination over the
best path.

• Congestion can be reduced, and QoS improved if the traffic for each
destination is split among multiple paths.

• Simple, but non-optimal technique:


– Routers compute multiple paths to every destination using locally available
information.
– Traffic is divided equally, or in proportion to the outgoing links.

1502346 - Computer Communications & Networks 52


M. Saad

Packet Scheduling

• If a router is handling multiple flows, there is danger that one flow will capture too
much of the router capacity, and starve all other flows.
• If packets are processed in the order of their arrival, an aggressive sender can capture
most of the router’s capacity, reducing the QoS for other users.
• Possible solution → fair queuing (Nagle, 1987)
– Routers have separate queues for each flow (and for each outgoing link).
– When an outgoing link becomes idle, the router scans the queues round robin taking
the first packet on the next queue.
– In this way, when n flows compete for a given outgoing link, each flow gets to send
a packet out of every n packets.
• Weighted fair queuing: similar to fair queuing, but gives more bandwidth to some flows
than the others. For example, video servers are given a higher priority than regular file
servers. This can be implemented by sending 2 or more packets of the high priority
flow for every packet sent for a regular flow.

1502346 - Computer Communications & Networks 53


M. Saad

QoS in the Internet

• The IETF (Internet Engineering Task Force) has proposed 2 techniques


to provide QoS: Integrated Services (IntServ) and Differentiated Services
(DiffServ).

• IntServ uses a combination of admission control, resource reservation


and packet scheduling to provide per-flow QoS.

• Advantage of IntServ: can guarantee good QoS for every flow.

• Disadvantage of IntServ: requires an advance setup for every flow,


something that does not scale well when there are thousands or millions
of flows. Also routers must maintain internal per-flow state information.

1502346 - Computer Communications & Networks 54


M. Saad

Differentiated Services

• DiffServ defines a set of service classes , e.g., best-effort service and


possibly more than one QoS (e,g., premium) service.

• Each service class has a corresponding forwarding rule.

• Packets belonging to a QoS class have a higher pririty to be forwarded


than packets belonging to the best-effort class.

1502346 - Computer Communications & Networks 55


M. Saad

Example: Regular vs. Expedited Forwarding

• Let packets be classified into 2 classes: regular forwarding and expedited forwarding.
• The majority of traffic is expected to be regular, but a small fraction of traffic is
expected to be expedited.
• The expedited packets should be able to transit the subnet, as if regular packets are
not present.
• This can be done by reserving bandwidth for the expedited service class.

Expedited packets

Regular packets

1502346 - Computer Communications & Networks 56


M. Saad

Regular vs. Expedited Forwarding (contd.)

• This reservation can be implemented by programming routers to have 2


separate queues for each outgoing links: one for regular packets and one
for expedited packets.

• When a packet arrives, it is queued accordingly.

• To dedicate 20% of the bandwidth for expedited packets and 80% of


the bandwidth for regular packets, an expedited packet is transmitted for
every 4 regular packets.

• In this way, it is hoped that expedited packets will see an unloaded


subnet, even when there is, in fact, a heavy load.

1502346 - Computer Communications & Networks 57


M. Saad

Advantages and Disadvantages of DiffServ

• Advantages:
– No need for advance setup.
– Routers need not to maintain per-flow state information.
– Technique scales well when there are thousands or millions of flows.
– The technique is simple.

• Disadvantages:
– Priority is given to the QoS traffic classes, but there are no guarantees.

1502346 - Computer Communications & Networks 58


M. Saad

The Network Layer in the Internet


Leased lines Leased A European backbone
to Asia A U.S. backbone transatlantic
line

Regional
C IP router
network
National
network
SNA
network

Tunnel
D Host
B
A 1 2

IP Ethernet IP Ethernet
LAN IP token ring LAN LAN

• The Internet can be viewed as a collection of subnetworks or Autonomous Systems


(ASes) that are interconnected.
• Several major backbones exist. These backbones consist of fast routers and high-
bandwidth lines. Attached to the routers are regional networks, and attached to the
regional networks are LANs (at universities, companies and Internet service providers).

1502346 - Computer Communications & Networks 59


M. Saad

The Internet Protocol (IP)


• The glue that holds the Internet together is the network layer protocol IP (Internet
Protocol).
• The IP protocol provides a best-effort way to transport datagrams from source to
destination.
• The IP header:
32 Bits

Version IHL Type of service Total length


D M
Identification F F Fragment offset

Time to live Protocol Header checksum

Source address

Destination address

Options (0 or more words)

1502346 - Computer Communications & Networks 60


M. Saad

The IP Header
• The IP header has a 20-byte fixed part, and a variable length optional part.
• Version: Currently, a transition between is IPv4 and IPv6 is going on, it is not known
if this transition will really happen.
• IHL: Since the header length is not constant, IHL is used to tell how long the header is,
in 32-bit (4-byte) words. The minimum value is 5, which applies when no options are
present. The maximum value is 15, which limits the header to 60 bytes (the options
field is thus limited to 40 bytes).
• Type of service: Used to distinguish between different classes of service. In practice,
most routers ignore the Type of Service field.
• Total length: Gives the total packet length, header and data. The maximum length is
65,535 bytes.
• Identification: Allows the destination host to determine which datagram a newly arrived
fragment belongs to. All the fragments of a datagram contain the same Identification
value. (Note that a packet/datagram may be fragmented into smaller pieces when it
travels through an interconnection of networks).

1502346 - Computer Communications & Networks 61


M. Saad

The IP Header (contd.)


• DF:Stands for Don’t Fragment. It is an order for routers not to fragment the datagram
because the destination is not capable of putting the fragments together again.
• MF: Stands for More Fragments. All fragments except the last one have this bit set. It
is needed to know when all fragments of a datagram have arrived.
• Fragment offset: Tells where in the current datagram this fragment belongs.
• Time to live: Is a counter that limits the packet lifetime (age). The maximum lifetime
is 255. In practice, this field is decremented every hop the packet travels. When it
hits zero, the packet is discarded and a warning packet is sent back to the source.
This feature prevents the packet from wandering around forever (which may happen if
routing tables have errors).
• Protocol: Tells the destination network layer which transport protocol to give the
datagram to (e.g., TCP or UDP).
• Header checksum: Used to detect errors that may occur in the header.
• Source address and destination address: Specifies the network addresses of the source
host and the destination host.

1502346 - Computer Communications & Networks 62


M. Saad

The Options Field

• Originally 5 options were specified as follows:

1502346 - Computer Communications & Networks 63


M. Saad

IP Address
• Every host on the Internet has a unique IP address that specifies network number and
host number.
• The IP address actually refers to a network interface, not the host itself (if the host is
connected to 2 different networks, it must have 2 different IP addresses).
• Classes of IP addresses:
32 Bits

Range of host
Class addresses
1.0.0.0 to
A 0 Network Host 127.255.255.255

128.0.0.0 to
B 10 Network Host
191.255.255.255
192.0.0.0 to
C 110 Network Host 223.255.255.255
224.0.0.0 to
D 1110 Multicast address 239.255.255.255
240.0.0.0 to
E 1111 Reserved for future use 255.255.255.255

• IP addresses are 32 bits (4 bytes) long. Each of the 4 bytes is written in decimal from
0 to 255 ⇒ the lowest IP addresses is 0.0.0.0 and the highest is 255.255.255.255.

1502346 - Computer Communications & Networks 64


M. Saad

IP Address (contd.)
• Class A allows for up to 27 = 128 networks with 224 ≈ 16 million hosts each.
• Class B allows for up to 214 = 16, 384 networks with 216 ≈ 64K hosts each.
• Class C allows for up to 221 ≈ 2 million networks with 28 = 256 hosts each.
• IP supports multicast, i.e., sending a packet to multiple destinations.
• Addresses beginning with 111 are reserved for future use.

• As we will see in the next slide, addresses consisting of all 0’s and all 1’s are reserved for
special IP addresses. Therefore, a class B address actually allows for 214 −2 = 16, 382
networks and 216 − 2 = 65, 534 hosts. (What is the actual number of networks and
hosts allowed by a class A or class C address?)

• IP addresses are managed by a nonprofit corporation called ICANN (Internet Corporation


for Assigned Names and Numbers) to avoid conflict. ICANN has delegated parts of
the address space to regional authorities, which in turn delegate IP addresses to service
providers and other companies.

1502346 - Computer Communications & Networks 65


M. Saad

Special IP Addresses
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 This host

0 0 ... 0 0 Host A host on this network

Broadcast on the
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
local network
Broadcast on a
Network 1111 ... 1111
distant network

127 (Anything) Loopback

• The IP address 0.0.0.0 is used by hosts when they are booted.


• IP addresses with 0 as network number refer to a host on the local network. This allows
machines to refer to their own network without knowing its number (but they have to
know its class! Why?)
• The address consisting of all 1’s allows broadcasting to all hosts on the local network.
• The address with a proper network number and all 1’s in the host field allows
broadcasting to all hosts on a distant network.
• Addresses of the form 127.xx.yy .zz are reserved for loopback testing. These packets
are processed locally and treated as incoming packets.

1502346 - Computer Communications & Networks 66


M. Saad

Subnets

• All hosts in a network must have the same network number.


• This causes a problem as the network grows → the network runs out of IP addresses
for its host.
• Example:
– A university wants to connect the computers of its Computer Science department
to the Internet ⇒ it uses one class B (network) address.
– Now, the university wants to connect the computers of its Electrical Engineering
department, then many other departments to the Internet ⇒ it builds separate
LAN’s for the different departments because it may not be possible to connect all
computers on a single LAN.
– The university must obtain additional network addresses because a single (class A,
B or C) IP address refers to a single network and not a collection of networks.
– This is inefficient because the university had already enough addresses for over
60,000 hosts.
• Solution → subnets and subnet mask.

1502346 - Computer Communications & Networks 67


M. Saad

Subnets (contd.)

• The solution is to allow the network to split into several subnets for internal use, but
still act like one network to the outside world.
• A typical campus network consists of a main router connected to the Internet Service
Provider (ISP), and numerous LAN’s spread across the campus.

Router PC
To
ISP
Art CS

English EE

French Main Math


router

Music Physics
Ethernet

1502346 - Computer Communications & Networks 68


M. Saad

Subnet Mask

• Instead of using a separate class B network address for each LAN, only one class B
address is used.
• The 16-bit host number is divided into a subnet number (e.g., 6 bits), and a host
number (e.g., 10 bits).
• This allows for up to 64 subnets, with a maximum of 1022 hosts each (all o’s and all
1’s are reserved for special addresses).
• To implement the subnetting, the main router needs a subnet mask that indicates the
split between subnet number and host number. For example, the following subnet mask
can be written as 255.255.252.0:

32 Bits

10 Network Subnet Host


Subnet
mask 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0

1502346 - Computer Communications & Networks 69


M. Saad

Advantages of Using Subnets and Subnet Masks

• No need to obtain a new network address when new LANs are created (this saves IP
address space).
• Outside the network, the subnetting is not visible, so allocating a new subnet does not
require contacting ICANN or changing any external databases.
• The main router needs not to keep a routing-table entry for every host in the network,
it keeps only an entry for every subnet.
– A packet arrives into the main router. The destination of the packet is host 3 on
subnet 6.
– The packet destination address is ANDed with the subnet mask to obtain only the
network address and subnet address. This address is looked up in the routing table,
and the packet is forwarded to subnet 6.
– The packet will be routed internally in subnet 6 to the correct destination host.

⇒ considerable reduction in the size of routing tables.

1502346 - Computer Communications & Networks 70


M. Saad

Example

A packet arriving at the main router of a university network is addressed


to destination host 130.50.15.6. The subnet mask used is 255.255.252.0.

• What is the IP address class of the network?

• What is the IP address the main router looks up in its routing table?

• How many subnets can be supported by your network?

• How many hosts can be supported by each subnet?

1502346 - Computer Communications & Networks 71


M. Saad

Classless Addressing

• Counterpart of subnetting, also called supernetting, or more often


Classless Interdomain Routing (CIDR).

• Gets rid of the address classes.

• Allows the grouping of several class C network addresses into a single


supernet (assigned to an organization).

• Example: organization with 256 hosts


– too many hosts for class C
256
– too few hosts for class B ( 65,535 = 0.39% utilization of IP addresses)
– ⇒ Solution → assign several contiguous class C networks

1502346 - Computer Communications & Networks 72


M. Saad

Classless Addressing: Simple Example


• Suppose we assign the class C network numbers from 192.4.16 to 192.4.31 to the
organization (these are 16 class C network numbers).
• This corresponds to the IP address range from 192.4.16.0 to 192.4.31.256, i.e., from
192.4.0001 0000.0000 0000 to 192.4.0001 1111.1111 1111
• The above address range has 20 fixed bits.
• Usually, the first address is the network address, and the last address in the range is
the broadcast address.
• IP address consists of fixed prefix (representing a network) plus suffix (representing a
host).
• Here: prefix length = 20
• Network address → 192.4.16.0/20 (first address / prefix length)
• Subnet mask → 255.255.240.0 (20 ones and 12 zeros)
• As if we have created a class with 20 bits network number and 12 bits host number.
• Bitwise logical AND between any address in the range (like 192.4.16.128) with the
subnet mask = network number 192.4.16.0.

1502346 - Computer Communications & Networks 73


M. Saad

IP Prefix and Subnet Mask

An IP prefix and a subnet mask.

1502346 - Computer Communications & Networks 74


M. Saad

Classless Subnetting

• Example (P. 3-68): An organization has been assigned the prefix


212.1.1.0/24, and wants to form subnets for four departments:
– A (75 hosts)
– B (35 hosts)
– C (20 hosts)
– D (18 hosts)
(a) Give the possible arrangements of subnet masks to make this possible.
(b) For each subnet, specify the first addresss and the last address in its
range.

• Refer to in-class illustration.

1502346 - Computer Communications & Networks 75


M. Saad

Rules for Classless Subnetting

• Each subnet gets a contiguous block of IP addresses.

• Block size is an integer power of 2.

• First address in the block has all zeros in the suffix (network address).

• Last address in the block has all ones in the suffix (broadcast address).

1502346 - Computer Communications & Networks 76


M. Saad

Internet Control Protocols: The Internet Control


Message Protocol (ICMP)
• The operation of the Internet is monitored closely by routers.
• When something unexpected occurs, the event is reported by the ICMP (Internet
Control Message Protocol).
• The most important ICMP Messages are as follows:

1502346 - Computer Communications & Networks 77


M. Saad

ICMP (contd.)

• Destination Unreachable message is sent when the subnet or a router cannot locate
the destination, or when a packet with DF = 1 cannot be delivered because a
“small-packet” network stands in the way.
• Time Exceeded message is sent when a packet is dropped because the TTL counter hit
zero.
• Parameter Problem message is sent when an illegal value has been detected in a header
filed.
• Source Quench message is the Choke packet. This was formerly used to ask hosts to
slow down transmission when there is congestion. It is rarely used nowadays; congestion
control in the Internet is now largely done at the transport layer (Chapter 6).
• Redirect message is sent when a router notices that a packet seems to be routed wrong.
It is used to tell the sending host about the possible error.
• Echo, Echo Reply, Timestamp Request, and Timestamp Reply as described in the table.

1502346 - Computer Communications & Networks 78


M. Saad

ARP–The Address Resolution Protocol

• Every machine on the Internet has one (or more) IP address.

• Most hosts at companies and universities are connected to a LAN by


an interface board that only understands LAN addresses. For example,
every Ethernet board manufactured comes with a unique 48-bit Ethernet
address. These boards send and receive frames based on the 48-bit
Ethernet addresses, but they no nothing about the 32-bit IP addresses.

• Mapping of IP addresses to data link layer (e.g.,Ethernet) addresses →


ARP (Address Resolution Protocol)

1502346 - Computer Communications & Networks 79


M. Saad

ARP (contd.)

Two switched Ethernet LANs joined by a router.

1502346 - Computer Communications & Networks 80


M. Saad

ARP (contd.)

• Small university with several class C networks: two Ethernets with IP


addresses 192.32.63.0 and 192.32.65.0, interconnected by a router.

• Assume a user on host 1 sends a packet to user mary@eagle.cs.uni.edu


on host 2. The first step is to find the IP address of host 2, known as
eagle.cs.uni.edu. This lookup is performed by the Domain Name System
(DNS) → host 1 will know that the IP address of host 2 is 192.32.65.5.

1502346 - Computer Communications & Networks 81


M. Saad

ARP (contd.)

• The upper layer S/W on host 1 builds a packet with 192.32.65.5 in the Destination
Address field and gives it to the IP S/W for transmission. The IP S/W recognizes
that the destination is on its own network, but needs to find the destination’s Ethernet
address →
– Host 1 sends a broadcast packet onto the Ethernet asking: Who owns IP address
192.32.65.5? The broadcast will arrive at every machine on Ethernet 192.32.65.0,
and each one will check its IP address. Host 2 alone will respond with its Ethernet
address E2 (the broadcast and getting the reply is known as the ARP protocol).
• The IP S/W on host 1 builds an Ethernet frame addressed to E2, puts the IP packet
(addressed to 192.32.65.5) in the payload field, and sends it over the Ethernet.
• The Ethernet board of host 2 detects the frame, the Ethernet driver extracts the IP
packet from the payload and passes it to the IP S/W, which sees it correctly addressed
and processes it.

1502346 - Computer Communications & Networks 82


M. Saad

ARP (contd.)

• Possible optimizations:
– Once a machine runs ARP, it caches the result in case it needs to
contact the same destination shortly.
– Host 1 will include its IP-to-Ethernet mapping in its ARP packet.
When the broadcast arrives ar host 2, the pair (192.32.65.7, E1) will
enter host 2’s cache for future use (especially for sending replies to
host 1).
– Every machine may broadcast its mapping when it boots.
– To allow mappings to change (e.g., when an Ethernet board breaks
and is replaced with a new one, with a new Ethernet address), entries
in the ARP cache should time out after a few minutes.

1502346 - Computer Communications & Networks 83


M. Saad

ARP (contd.)

• Similar scenario for sending a packet from host 1 to host 4 (on a different
network).
– Host 1 realizes that the destination (192.32.63.8) is on a distant
network (the EE network). It encapsulates the packet (with destination
IP address 192.32.63.8) in an Ethernet frame addressed to E3 (the
default machine handling packets to external networks, this may be
known by all hosts).
– The router encapsulates the packet in a new frame using E6 as the
destination MAC address. The packet will now reach the destination
host.
– ARP can be used in each of these two transmissions, if the destination
MAC address in not known.

1502346 - Computer Communications & Networks 84


M. Saad

IPv6

• In its early years, the Internet was mainly used by universities and high-tech industry.
• The explosion of interest in the Internet began in the mid 1990s.
• With the convergence of the computer, communication and entertainment industries,
it may not be long before every telephone and TV set in the world becomes an Internet
node ⇒ with IPv4 (32-bit IP addresses) we may run out of IP addresses.
• Solution → IPv6.
• In 1990, the IETF (Internet Engineering Task Force) started work on a new version of
IP, one which would never run out of addresses. IETF issued a call for proposals and
discussion.

1502346 - Computer Communications & Networks 85


M. Saad

Some Major Goals of IPv6


1. Support billions of hosts, even with an inefficient address space allocation.
2. Reduce the size of routing tables.
3. Simplify the protocol, to allow routers to process packets faster.
4. Provide better security.
5. Pay more attention to type of service.
6. Allow the protocol to evolve in the future.
7. Permit the old and new protocols to coexist for years.

• Improvements in IPv6:
– Longer IP addresses.
– Simpler header, which allows for faster packet processing, and thus improve
throughput and delay.
– Better support for options.
– Security.
– More attention to QoS.

1502346 - Computer Communications & Networks 86


M. Saad

The Main IPv6 Header


32 Bits

Version Traffic class Flow label

Payload length Next header Hop limit

Source address
(16 bytes)

Destination address
(16 bytes)

1502346 - Computer Communications & Networks 87


M. Saad

The Main IPv6 header (contd.)

• Version: contains always 6 for IPv6.


• Traffic class: to distinguish between packets with different real-time (QoS) requirements.
• Flow label: is still experimental, will allow a source-destination pair to set up a pseudo-
connection with particular requirements. When a packet with nonzero Flow label shows
up, routers can check their internal tables to see what kind of special treatment it
requires → flexibility of datagrams and guarantees of VCs.
• Payload length: length of the data that follow the 40-byte header (maximum data size
= 64KBytes).
• Next header: tells which of the (currently) six possible extension headers follows the
main one. In the last header, this filed tells which transport protocol (TCP or UDP)
the packet should be passed to.
• Hop limit: same as Time to live in IPv4.

1502346 - Computer Communications & Networks 88


M. Saad

The Main IPv6 header (contd.)

• Source address and Destination address: 16-byte IP addresses of the source and
destination.
– 16 bytes = 128 bits ⇒ 2128 different IP addresses. If the entire earth, land and
water, were covered with computers, IPv6 would allow 7 × 1023 IP addresses per
square meters.
• Notice that the Checksum field is not present in IPv6. It is argued that enough error
control is done at the data link and transport layers. Another checksum at the network
layer seems unnecessary ⇒ faster packet processing.
• Fragmentation information is moved to the optional headers. Notice that in IPv6, only
the source is allowed to fragment (by dynamically determining the packet/fragment
sizes). (What are the advantages and disadvantages?)

1502346 - Computer Communications & Networks 89


M. Saad

Extension Headers

1502346 - Computer Communications & Networks 90


M. Saad

Extension Headers (contd.)

• Example: extension header for routing

Header extension Routing type


Next header Segments left
length

Type-specific data

– Type-specific data: contains a list of IP addresses the packet must not miss.
– Segments left: keeps track of how many addresses in the list have not yet been
visited. It is decremented every time one is visited. When it hits 0, the packet is
free to take any path to the destination.

1502346 - Computer Communications & Networks 91


M. Saad

Some Controversies

• Is 16 bytes for IP addresses too much, or too little.

• Is 8 bits for Hop limit enough?

• Is 64KB enough as the maximum packet size?

• Should a header checksum be included, or excluded?

1502346 - Computer Communications & Networks 92


M. Saad

Thanks

1502346 - Computer Communications & Networks 93

You might also like