Professional Documents
Culture Documents
4 Net
4 Net
Networks
Dr. Mohamed Saad
Department of Computer Engineering
University of Sharjah
msaad@sharjah.ac.ae
• The network layer is concerned with getting packets from the source all
the way to the destination.
• 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.
• 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
B D
H1 H2
Process P2
A E F
1
C LAN
Process P1 Packet
• 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.
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
Connection-oriented Service
B D
H1 H2
1 Process P2
A E F
4
2
3
Process P1 LAN
C
• 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).
Comparison
Routing Algorithms
• If virtual circuits are used, a decision has to be made when a new virtual
circuit is set up.
Routing Optimality
• 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.
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)
E (4, B) E (4, B)
A F (∞, −) D (∞,−) A F (6, E) D (∞,1)
E (4, B) E (4, B)
A F (6, E) D (∞,−) A F (6,E) D (∞,−)
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.
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).
• 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.
• It was the original ARPANET routing algorithm, and it was also used in
the Internet.
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.
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.
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)
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.
• 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.
• The router on the other side of the link sends a reply packet containing
its network address.
• Neighbors send the ECHO packet back to the sender as fast as possible.
(a) (b)
• 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.
• Once a router has received all link state packets it can construct the
entire graph of the network (it has complete topology information).
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.
• 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.
• 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.
Congestion A
A
B
B
Virtual
circuit
Congestion
(a) (b)
• 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.
• When the utilization of one of the outgoing links moves above a certain
threshold, the link enters a “warning” state.
• When the packet reaches the destination, the warning bit is copied in
the next acknowledgement sent back to the source.
• Since every router along the path could set the warning bit, the source
increases the traffic only when no router is in trouble.
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.
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)
• 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.
Quality of Service
• 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.
Overprovisioning
• Provide more router capacity, buffer space and bandwidth than the traffic
needs.
• Disadvantage → expensive.
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.
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)
Traffic Shaping
• Traffic shaping is used to smooth the flow of traffic at the sender (server)
side.
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.
– Resource reservation
– Admission control
– Multipath routing
– Packet scheduling
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.
• Solution: combine traffic shaping with the use of virtual circuits, and
resource reservation.
• 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.
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.
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.
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.
Differentiated Services
• 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
• 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.
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
Source address
Destination address
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).
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.
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?)
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
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
Subnets
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
Music Physics
Ethernet
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
• 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.
Example
• What is the IP address the main router looks up in its routing table?
Classless Addressing
Classless Subnetting
• 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).
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.
ARP (contd.)
ARP (contd.)
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.
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.
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.
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.
• 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.
Source address
(16 bytes)
Destination address
(16 bytes)
• 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?)
Extension Headers
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.
Some Controversies
Thanks