Vous êtes sur la page 1sur 74

Data Communication and

Networking
Dr. –Ing. Vo Que Son
Email: sonvq@hcmut.edu.vn

Telecomm. Dept. DCN


1
Faculty of EEE HCMUT
Content
Chapter 3: Data Link Layer Protocols
Flow Control
Error Control
Connection Management
Data link layer Protocols
Chapter 4: Telecommunication Networks
802.x standard and TCP/IP Model
Ethernet, Token Pass, Token Ring
IP Addressing: Classless and VLSM
Network devices
Switching and Routing
STP, VLAN
Telecomm. Dept. DCN
2
Faculty of EEE HCMUT
Local Area Network
 A local area network (LAN) is a computer network that
interconnects computers in a limited area such as a home,
school, computer laboratory, or office building using network
media
 Medium:
 Coaxial cable
 Twisted-pair line

Telecomm. Dept. DCN


3
Faculty of EEE HCMUT
Wide Area Network
 A wide area network (WAN) is a network that covers a broad
area (i.e., any telecommunications network that links across
metropolitan, regional, or national boundaries) using private
or public network transports

Telecomm. Dept. DCN


4
Faculty of EEE HCMUT
Physical Topology

Bus Extended Star

Ring
Hierarchical

Star Mesh

Telecomm. Dept. DCN


5
Faculty of EEE HCMUT
Project 802
 IEEE 802 refers to a family of IEEE standards dealing with local
area networks and metropolitan area networks
 The services and protocols specified in IEEE 802 map to the
lower two layers (Data Link and Physical) of the seven-layer
OSI networking reference model. In fact, IEEE 802 splits the
OSI Data Link Layer into two sub-layers named Logical Link
Control (LLC) and Media Access Control (MAC), so that the
layers can be listed like this:
Data link layer
• LLC Sublayer:
• MAC Sublayer
Physical layer

Telecomm. Dept. DCN


6
Faculty of EEE HCMUT
Project 802
 Modules in Project 802
 LLC: based on HDLC protocol
 Multiplexing protocols
transmitted over the MAC
layer (when transmitting) and
decoding them (when
receiving).
 Providing node-to-node flow
and error control
 MAC: provides addressing and
channel access control
mechanisms that make it possible
for several terminals or network
nodes to communicate within a
multiple access network that
incorporates a shared medium
Telecomm. Dept. DCN
7
Faculty of EEE HCMUT
LLC Frame formats
LLC PDU:
DSAP: Destination
Service Access Point
SSAP: Source Service
Access Point
Control field:
HDLC format

Telecomm. Dept. DCN


8
Faculty of EEE HCMUT
Ethernet
 Topology: bus, star, ring
 Media Access Control: Deterministic, Non-deterministic
 Addressing:
Every computer has a unique way of identifying itself :
MAC address or physical address.
The physical address is located on the Network Interface
Card (NIC).
MAC addresses have no structure, and are considered flat
address spaces. MAC addresses are sometimes referred to
as burned-in addresses (BIAs) because they are burned
into read-only memory (ROM) and are copied into
random-access memory (RAM) when the NIC initializes.
• 0000.0c12.3456 or 00-00-0c-12-34-56
• If MAC is all bits 1: broadcast address

Telecomm. Dept. DCN


9
Faculty of EEE HCMUT
IEEE 802.3: frame format
 Preamble: 10101010 (7 bytes)
 The Start Frame field (10101011) tells other devices on the network that a
frame is coming down the wire.
 The Address field stores the source and destination MAC addresses.
 Source address is unicast, Destination address can be unicast, multicast or broadcast
 The Type/Length field is an optional field
 Exact length of frame, or Layer 3 protocol making the sending request, or Not used
 The Data field is the actual information being sent by the upper layer
protocols. Therefore, it will be all upper layer data.
 CRC: 4 bytes, error checking

Telecomm. Dept. DCN


10
Faculty of EEE HCMUT
Ethernet: 802.3
 10Base-2: 50Ω Thin cable, 185m.
 10Base-5: 50Ω Thick cable, 500m.
 10Base-T: 100Ω UTP cable, 100m.
 10Base-F: Fiber optic cable, 1000m.
 100Base-TX: 100Ω UTP/STP cable, 100m.
 100Base-T4: 100Ω UTP (4p) cable, 100m.
 100Base-FX: Fiber optic cable, 400m.
 1000Base-T: 100Ω UTP/STP cable, 100m.

Telecomm. Dept. DCN


11
Faculty of EEE HCMUT
Ethernet: 10BASE-5
 NIC: Network Interface Card
 MAU: Medium Attachment Unit
 Thick Ethernet (thicknet)
 50Ω Thick cable, 500m

Telecomm. Dept. DCN


12
Faculty of EEE HCMUT
Ethernet: 10BASE-2
 Thin Ethernet
 50Ω Thin cable, 185m.

Telecomm. Dept. DCN


13
Faculty of EEE HCMUT
Ethernet: 10BASE-T
 Twisted-pair cable
 100Ω UTP cable, 100m.
 Data rate: 10 Mbps

Telecomm. Dept. DCN


14
Faculty of EEE HCMUT
Ethernet Operation
Specified by the technology
being used.
Determine who can transmit
and when.
Two types:
Deterministic: “Let’s take
turns”.
• Token-Ring, FDDI.
Non-deterministic: “First come,
first serve”.
• Ethernet : CSMA/CD.

Carrier Sense Multiple Access with Collision


Detection (CSMA/CD).
Telecomm. Dept. DCN
15
Faculty of EEE HCMUT
Three common layer 2 technologies
Ethernet: logical
broadcast topology

Token Ring: logical


token ring topology

FDDI: logical token ring


topology

Telecomm. Dept. DCN


16
Faculty of EEE HCMUT
Ethernet MAC
Ethernet is a shared-media broadcast
technology. The access method CSMA/CD
used in Ethernet performs three functions:
Transmitting and receiving data packets
Decoding data packets and checking them for
valid addresses before passing them to the upper
layers of the OSI model
Detecting errors within data packets or on the
network

Telecomm. Dept. DCN


17
Faculty of EEE HCMUT
CSMA/CD Process

Telecomm. Dept. DCN


18
Faculty of EEE HCMUT
Fast Ethernet
 Speed: 100 Mbps
 Distance: <250m
 Backward compatible with Ethernet
10 Mbps
 Uses Twisted-pair or Fiber

Telecomm. Dept. DCN


19
Faculty of EEE HCMUT
Gigabit Ethernet
 >1 Gbps
 Using Fiber optic
 Deployed as backbone
network, connecting Fast
Ethernet networks

Telecomm. Dept. DCN


20
Faculty of EEE HCMUT
Token Ring
 Token ring LAN technology was a
protocol which resided at the data link
layer (DLL) of the OSI model. It used a
special three-byte frame called a token
that travels around the ring. Token-
possession grants the possessor
permission to transmit on the medium.
Token ring frames travel completely
around the loop.
 Initially used only in IBM computers, it
was eventually standardized with
protocol IEEE 802.5.
 Physical ring topology
Telecomm. Dept. DCN
21
Faculty of EEE HCMUT
Token Ring
 The data transmission process goes as follows:
 Empty information frames are continuously circulated
on the ring.
 When a computer has a message to send, it seizes the
token. The computer will then be able to send the
frame.
 The frame is then examined by each successive
workstation. The workstation that identifies itself to
be the destination for the message copies it from the
frame and changes the token back to 0.
 When the frame gets back to the originator, it sees
that the token has been changed to 0 and that the
message has been copied and received. It removes
the message from the frame.
 The frame continues to circulate as an "empty"
frame, ready to be taken by a workstation when it has
a message to send.
 Issues:
 Who generates token?
 If the node keeping token is dead, what happens?

Telecomm. Dept. DCN


22
Faculty of EEE HCMUT
Token Bus
 Also use token as Token Ring
 Physical Bus topology
 Token bus was standardized by IEEE standard 802.4. It is
mainly used for industrial applications
 Due to difficulties handling device failures and adding new
stations to a network, token bus gained a reputation for being
unreliable and difficult to upgrade

Telecomm. Dept. DCN


23
Faculty of EEE HCMUT
IP Addressing: IPv4
 An IPv4 address is 32 bits
long.
 The IPv4 addresses are
unique and universal.
 Network address + Host
address: Hierarchical
Addressing Schemes.

Telecomm. Dept. DCN


24
Faculty of EEE HCMUT
IP Header
IP protocol version 32 bits total datagram
number
header length length (bytes)
ver head. type of length
(bytes) len service for
“type” of data fragment fragmentation/
16-bit identifier Flags
offset reassembly
max number time to upper header
remaining hops live layer checksum
(decremented at
32 bit source IP address
each router)
32 bit destination IP address
upper layer protocol
to deliver payload to Options (if any) E.g. timestamp,
record route
how much overhead with data taken, specify
TCP? (variable length, list of routers
 20 bytes of TCP
typically a TCP to visit.
 20 bytes of IP
or UDP segment)
 = 40 bytes + app layer
overhead
Telecomm. Dept. DCN
25
Faculty of EEE HCMUT
Classful IP addressing
 In classful addressing, the address space is divided into five
classes: A, B, C, D, and E.
 In classful addressing, a large part of the available addresses
were wasted.

Telecomm. Dept. DCN


26
Faculty of EEE HCMUT
Classful IP addressing
 Network Bits:
 Provided by Internet
Network Information
Center
 Define the network
the remote device
wants to connect to
 Defined by subnet-
mask
 Host Bits:
 Managed by Network
Administrator Class C Network address: 192.168.10.100/255.255.255.0 (or /24)
 Define the device IP Addr 11000000. 101010000. 00001010. 01100100
address in the N . N . N . H
network that the
AND operation
remote device wants
to connect to Default 11111111. 11111111. 11111111. 00000000
subnet
 All bits are 0: no use Mask
 All bits are 1:
Network 11000000. 101010000. 00001010. 00000000
broadcast address addr

Telecomm. Dept. DCN


27
Faculty of EEE HCMUT
Classful IP addressing
 In classful addressing, a large part of the available addresses
were wasted.

Telecomm. Dept. DCN


28
Faculty of EEE HCMUT
Classful IP addressing: 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.
Telecomm. Dept. DCN
29
Faculty of EEE HCMUT
Subnetting
Network administrators sometimes need to divide
networks, especially large ones, into smaller
networks:
Reduce the size of a broadcast domain.
Improve network security.
Implement the hierarchical managements.
So we need more network addresses for your
network. But I want the outside networks see our
network as a single network.

Telecomm. Dept. DCN


30
Faculty of EEE HCMUT
Subnetting
 Non-subnetted
network

 Subnetted network into


separate smaller
networks

Telecomm. Dept. DCN


31
Faculty of EEE HCMUT
Subnetting
 To create a subnet address, a network administrator “borrows” bits from
the original host portion and designates them as the subnet field.
 “Borrows” bits is always the leftmost host bit, the one closest to the last
network octet.
 Subnet addresses include the Class A, Class B, or Class C network portion,
plus a subnet field and a host field.
 Subnet addresses are assigned locally, usually by a network administrator.
 How many bits can we borrow?
 All of subnet bits are:
 0 : reserved for network address.
 1 : reserved for broadcast address.
 The minimum bits you can borrow is: 2 bits.
 The maximum bits you can borrow is:
 A: 22 bits ~ 222 - 2 = 4.194.302 subnets.
 B: 14 bits ~ 214 - 2 = 16.382 subnets.
 C: 06 bits ~ 206 - 2 = 62 subnets.

Telecomm. Dept. DCN


32
Faculty of EEE HCMUT
Subnetting Example
 Given network 172.16.0.0: We need 6 usable subnets and up
to 8100 hosts on each subnet.
 Define class: class B, 255.255.0.0
 6 usable subnets: borrow 3 bits
 Determine the subnets from 3 borrowed bits from the host
portion (last 2 bytes):
 0 subnet: .00000000.00000000
 1st subnet: .00100000.00000000(32=25)
 2nd subnet: .01000000.00000000
 3rd subnet: .0110000.00000000
 4th subnet: .10000000.00000000
 5th subnet: .10100000.00000000
 6th subnet: .11000000.00000000(6x25)
 subnet: .11100000.00000000

Telecomm. Dept. DCN


33
Faculty of EEE HCMUT
Subnetting Example
Sub-network Broadcast Use
No Possible host address
address address ?

0 172.16.0.0 .0.1 – .31.254 .31.255 N


1 172.16.32.0 .32.1 – .63.254 .63.255 Y
2 172.16.64.0 .64.1 –.95.254 .95.255 Y
3 172.16.96.0 .96.1 –.127.254 .127.255 Y
4 172.16.128.0 .128.1 –.159.254 .159.255 Y

5 172.16.160.0 .160.1 –.191.254 .191.255 Y


6 172.16.192.0 .192.1 –.223.254 .223.255 Y
7 172.16.224.0 .224.1 –.255.254 .255.255 N

Telecomm. Dept. DCN


34
Faculty of EEE HCMUT
Subnetting
Addresses are loose by subnetting.
Network administrator must strike a balance
between the number of subnets required, the hosts
per subnet that is acceptable, and the resulting
waste of addresses.

Telecomm. Dept. DCN


35
Faculty of EEE HCMUT
IP Address Problems
 In the 1990, two problems became apparent
 IP addresses were being exhausted
 IP routing tables were growing very large
 IP Address Exhaustion
 Class A, B, and C address structure inefficient
 Class B too large for most organizations, but future proof
 Class C too small
 Rate of class B allocation implied exhaustion by 1994
 IP routing table size
 Growth in number of networks in Internet reflected in # of table entries
• From 1991 to 1995, routing tables doubled in size every 10 months
• Stress on router processing power and memory allocation
 Short-term solution:
 Classless Interdomain Routing (CIDR), RFC 1518
 New allocation policy (RFC 2050)
 Private IP Addresses set aside for intranets
 Long-term solution: IPv6 with much bigger address space

Telecomm. Dept. DCN


36
Faculty of EEE HCMUT
Supernetting
Summarize a contiguous group of class C addresses
using variable-length mask
Example: 150.158.16.0/20
IP Address (150.158.16.0) & mask length (20)
IP add = 10010110 10011110 00010000 00000000
Mask = 11111111 11111111 11110000 00000000
Contains 16 Class C blocks:
From 10010110 10011110 00010000 00000000
• i.e. 150.158.16.0
Up to 10010110 10011110 00011111 00000000
• i.e. 150.158.31.0

Telecomm. Dept. DCN


37
Faculty of EEE HCMUT
Summarizing Within an Octet

Telecomm. Dept. DCN


38
Faculty of EEE HCMUT
Subnetting: Example 1
 For example, consider a relatively small company with a Class C
network, 201.45.222.0/24. They have six subnetworks in their
network. The first four subnets (S1, S2, S3 and S4) are relatively
small, containing only 10 hosts each. However, one of them (S5) is
for their production floor and has 50 hosts, and the last (S6) is their
development and engineering group, which has 100 hosts.
 The total number of hosts needed is thus 196. Without subnetting,
we have enough hosts in our Class C network to handle them all.
However, when we try to subnet, we have a big problem. In order
to have six subnets we need to use 3 bits for the subnet ID. This
leaves only 5 bits for the host ID, which means every subnet has the
identical capacity of 30 hosts. This is enough for the smaller subnets
but not enough for the larger ones. The only solution with
conventional subnetting, other than shuffling the physical subnets,
is to get another Class C block for the two big subnets and use the
original for the four small ones. But this is expensive, and means
wasting hundreds of IP addresses!

Telecomm. Dept. DCN


39
Faculty of EEE HCMUT
Subnetting Example 2
For example, consider the subnet address
172.16.32.0/20 and a network needing ten host
addresses.

With this subnet address, there are over 4000 (212 – 2


= 4094) host addresses, most of which will be wasted.

Need Variable Length Subnet Mask (VLSM)

Telecomm. Dept. DCN


40
Faculty of EEE HCMUT
VLSM Example
Given the Class C network of 204.15.5.0/24, subnet
the network in order to create the network in the
figure below, with the host requirements shown:
 NetA: 14 hosts
 NetB: 28 hosts
 NetC: 2 hosts
 NetD: 7 hosts
 NetE: 28 hosts
Solution?
Classful subnetting?
VLSM?
What do we benefit when using VLSM?
Telecomm. Dept. DCN
41
Faculty of EEE HCMUT
VLSM Example
Solution: Classful subnetting
• netA: 204.15.5.32/27 host address range 33 to 62
• netB: 204.15.5.64/27 host address range 65 to 94
• netC: 204.15.5.96/27 host address range 97 to 126
• netD: 204.15.5.128/27 host address range 129 to 158
• netE: 204.15.5.160/27 host address range 161 to 190

Solution: VSLM
• netA: requires a /28 (255.255.255.240) mask to support 14 hosts
• netB: requires a /27 (255.255.255.224) mask to support 28 hosts
• netC: requires a /30 (255.255.255.252) mask to support 2 hosts
• netD*: requires a /28 (255.255.255.240) mask to support 7 hosts
• netE: requires a /27 (255.255.255.224) mask to support 28 hosts

* a /29 (255.255.255.248) would only allow 6 usable host addresses


therefore netD requires a /28 mask

Telecomm. Dept. DCN


42
Faculty of EEE HCMUT
VLSM Example
Solution: VSLM assign the largest first
•netB: 204.15.5.0/27 host address range 1 to 30
•netE: 204.15.5.32/27 host address range 33 to 62
•netA: 204.15.5.64/28 host address range 65 to 78
•netD: 204.15.5.80/28 host address range 81 to 94
•netC: 204.15.5.96/30 host address range 97 to 98

NetB: 28 hosts (using a block of 32)


NetE: 28 hosts (using a block of 32)
NetA: 14 hosts (using a block of (16)
NetD: 7 hosts (using a block of (16)
NetC: 2 hosts (using a block of 4)
Telecomm. Dept. DCN
43
Faculty of EEE HCMUT
A Working VLSM Example
Subnetting without VLSM:
8 networks
What is the reason?

Telecomm. Dept. DCN


44
Faculty of EEE HCMUT
A Working VLSM Example
VLSM solution

Telecomm. Dept. DCN


45
Faculty of EEE HCMUT
A Working VLSM Example

Telecomm. Dept. DCN


46
Faculty of EEE HCMUT
A Working VLSM Example

Telecomm. Dept. DCN


47
Faculty of EEE HCMUT
Summarizing Within an Octet
Route summary: reduce routing traffic

Telecomm. Dept. DCN


48
Faculty of EEE HCMUT
Network Devices
 Hub/Repeater
 Switch/Bridge
 Router/3-layer switch
 Gateway

Telecomm. Dept. DCN


49
Faculty of EEE HCMUT
Network Devices
Hub/Repeater
 Propagate signals from
one port to others
 Layer 1 devices: connects
segments of a LAN.
 Extending a network with
a repeater or a hub,
results in a larger
collision domain.
 Collision Domains are the
area where collisions occur.
All of layer 1
interconnections are part of
the collision domain.

Telecomm. Dept. DCN


50
Faculty of EEE HCMUT
Network Devices
Switch
A multi port bridge
Support full duplex
Hardware switching
Dynamically builds and
maintains a Content-
Addressable Memory
(CAM) table
 Segmenting Collision
Domain
 Can not prevent layer 2
broadcast domain

Telecomm. Dept. DCN


51
Faculty of EEE HCMUT
Network Devices
Router:
Layer 3 device
Routing packets to
destination based on
destination IP address
Running routing
protocol
Split layer 2 broadcast
domain

Telecomm. Dept. DCN


52
Faculty of EEE HCMUT
Network Devices
Gateway:
Operate at Application layer in OSI model
Convert data between networks with different protocols

Telecomm. Dept. DCN


53
Faculty of EEE HCMUT
Switching
 link-layer device: smarter
than hubs, take active role
 store, forward Ethernet
frames
 examine incoming frame’s
MAC address, selectively
forward frame to one-or-
more outgoing links when
frame is to be forwarded on
segment, uses CSMA/CD to
access segment
 transparent
 hosts are unaware of
presence of switches
 plug-and-play, self-
learning
 switches do not need to be
configured

Telecomm. Dept. DCN


54
Faculty of EEE HCMUT
Switching
 allows multiple simultaneous A
transmissions
 hosts have dedicated, direct C’ B
connection to switch
 switches buffer packets 1 2
6 3
 Ethernet protocol used on each
5 4
incoming link, but no collisions;
full duplex
C
 each link is its own collision
domain
B’ A’
 switching: A-to-A’ and B-to-B’
simultaneously, without switch with six interfaces
collisions (1,2,3,4,5,6)
 not possible with dumb hub

Telecomm. Dept. DCN


55
Faculty of EEE HCMUT
Switching
 Q: how does switch know that A
A’ reachable via interface 4, B’
reachable via interface 5? C’ B
 A: each switch has a switch
table, each entry: 1 2
6 3
 (MAC address of host, interface to 4
5
reach host, time stamp)
 looks like a routing table! C
 Q: how are entries created,
B’ A’
maintained in switch table?
 something like a routing protocol? switch with six interfaces
(1,2,3,4,5,6)

Telecomm. Dept. DCN


56
Faculty of EEE HCMUT
Switch: self-learning Source: A
Dest: A’
 switch learns which hosts A A A’
can be reached through
which interfaces C’ B
 when frame received,
switch “learns” location of 1 2
sender: incoming LAN 6 3
segment 5 4
 records sender/location pair
in switch table C

B’ A’
MAC addr interface TTL

A 1 60 Switch table
(initially empty)

Telecomm. Dept. DCN


57
Faculty of EEE HCMUT
Self-learning, forwarding: example
 frame destination A A A’
unknown: flood Source: A
 destination A location C’ B Dest: A’
known: selective send
1 2
 How does self-learning A6A’ 3
work if switches can be 5 4
connected together?
C
A’ A
B’ A’
MAC addr interface TTL
A 1 60
A’ 4 60 Switch table
(initially empty)

Telecomm. Dept. DCN


58
Faculty of EEE HCMUT
Loop problem in learning MAC addresses

Telecomm. Dept. DCN


59
Faculty of EEE HCMUT
Routing
 Router receives packets and
forwards them to the
destination (based on
destination IP)
 How does router work?
 Check the header of IP
packet
 Look up the routing table Control Plane
 Determine the output port
Next Hop + Port
 Forward the packet to the Forwarding
Table
output port Routing
Output
Packets
Packets
Packet Output
Queuing and
Classification Queue
Schedule rules

Input
Packets

Header payload
User Plane

Telecomm. Dept. DCN


60
Faculty of EEE HCMUT
Routing
Each router needs running a routing protocol to
update the its routing table
Delay of packets
Queuing delay
Processing delay
Propagation delay

Telecomm. Dept. DCN


61
Faculty of EEE HCMUT
Routing Protocols: Classification
 Global or decentralized information?
 Global:
• all routers have complete topology, link cost info
• “link state” algorithms
 Decentralized:
• router knows physically-connected neighbors, link costs to neighbors
• iterative process of computation, exchange of info with neighbors
• “distance vector” algorithms
 Static or dynamic?
 Static:
• routes change slowly over time
 Dynamic:
• routes change more quickly
• periodic update
• in response to link cost changes

Telecomm. Dept. DCN


62
Faculty of EEE HCMUT
Routing Algorithms: Link State
Dijkstra’s algorithm Notation:
 net topology, link costs  c(x,y): link cost from node x
known to all nodes to y; = ∞ if not direct
 accomplished via “link state neighbors
broadcast”
 D(v): current value of cost of
 all nodes have same info
path from source to dest. v
 computes least cost paths
from one node (‘source”) to  p(v): predecessor node along
path from source to v
all other nodes
 gives forwarding table for that  N': set of nodes whose least
node cost path definitively known
 iterative: after k iterations,
know least cost path to k
dest.’s

Telecomm. Dept. DCN


63
Faculty of EEE HCMUT
Dijkstra’s algorithm: example
Step N' D(v),p(v) D(w),p(w) D(x),p(x) D(y),p(y) D(z),p(z)
0 u 2,u 5,u 1,u ∞ ∞
1 u,x 2,u 4,x 2,x ∞
2 u,x,y 2,u 3,y 4,y
3 u,x,y,v 3,y 4,y
4 u,x,y,v,w 4,y
5 u,x,y,v,w,z
5
3
v w 5
2
u 2 1 z
3
1 2
x 1
y

Telecomm. Dept. DCN


64
Faculty of EEE HCMUT
Dijkstra’s algorithm: example
Resulting shortest-path tree from u:
v w
u z
x y
Resulting forwarding table in u:
destination link
v (u,v)
x (u,x)
y (u,x)
w (u,x)
z (u,x)

Telecomm. Dept. DCN


65
Faculty of EEE HCMUT
Dijkstra’s algorithm, discussion
 Algorithm complexity: n nodes
 each iteration: need to check all nodes, w, not in N
 n(n+1)/2 comparisons: O(n2)
 more efficient implementations possible: O(nlogn) Dijkstra selects vertex
 Do not work with negative link costs: 3 immediately after 0.
But shortest path from
 Oscillations possible: 0 to 3 is 0-1-2-3.

 e.g., link cost = amount of carried traffic

1 A A A A
1+e 2+e 0 0 2+e 2+e 0
D 0 0 B D B D B D B
1+e 1 0 0 1+e 1
0 e 0 0 1 1+e 0 e
1
C C C C
1
e
… recompute … recompute … recompute
initially
routing
Telecomm. Dept. DCN
66
Faculty of EEE HCMUT
Distance Vector Algorithm
Bellman-Ford Equation (dynamic programming)
Define:
dx(y) := cost of least-cost path from x to y
Then
dx(y) = min {c(x,v) + dv(y) }

where min is taken over all neighbors v of x

Telecomm. Dept. DCN


67
Faculty of EEE HCMUT
Bellman-Ford example
5
Clearly, dv(z) = 5, dx(z) = 3, dw(z) = 3
3
v w 5 B-F equation says:
2
u 2 1 z du(z) = min { c(u,v) + dv(z),
3
1 2 c(u,x) + dx(z),
x 1
y
c(u,w) + dw(z) }
= min {2 + 5,
1 + 3,
5 + 3} = 4

Node that achieves minimum is next


hop in shortest path ➜ forwarding table

Telecomm. Dept. DCN


68
Faculty of EEE HCMUT
Distance Vector Algorithm
Dx(y) = estimate of least cost from x to y
Node x knows cost to each neighbor v:
c(x,v)
Node x maintains distance vector
Dx = [Dx(y): y є N ]
Node x also maintains its neighbors’ distance vectors
For each neighbor v, x maintains
Dv = [Dv(y): y є N ]

Telecomm. Dept. DCN


69
Faculty of EEE HCMUT
Distance Vector Algorithm
Basic idea:
From time-to-time, each node sends its own distance
vector estimate to neighbors
Asynchronous
When a node x receives new DV estimate from neighbor, it
updates its own DV using B-F equation:
Dx(y) ← minv{c(x,v) + Dv(y)} for each node y ∊ N

Under minor, natural conditions, the estimate Dx(y)


converge to the actual least cost dx(y)

Telecomm. Dept. DCN


70
Faculty of EEE HCMUT
Distance Vector Algorithm
Iterative, asynchronous: each Each node:
local iteration caused by:
 local link cost change
 DV update message from wait for (change in local link
neighbor cost or msg from neighbor)

Distributed:
 each node notifies neighbors recompute estimates
only when its DV changes
 neighbors then notify their
neighbors if necessary if DV to any dest has changed,
notify neighbors

Telecomm. Dept. DCN


71
Faculty of EEE HCMUT
Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)} Dx(z) = min{c(x,y) +
= min{2+0 , 7+1} = 2 Dy(z), c(x,z) + Dz(z)}
node x table = min{2+1 , 7+0} = 3
cost to cost to
x y z x y z
x 0 2 7 x 0 2 3
from

from
y ∞∞ ∞ y 2 0 1
z ∞∞ ∞ z 7 1 0
node y table
cost to
x y z y
2 1
x ∞ ∞ ∞
x z
from

y 2 0 1 7
z ∞∞ ∞
node z table
cost to
x y z
x ∞∞ ∞
from

y ∞∞ ∞
z 7 1 0 Network Layer time

Telecomm. Dept. DCN


72
Faculty of EEE HCMUT
Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)} Dx(z) = min{c(x,y) +
= min{2+0 , 7+1} = 2 Dy(z), c(x,z) + Dz(z)}
node x table = min{2+1 , 7+0} = 3
cost to cost to cost to
x y z x y z x y z
x 0 2 7 x 0 2 3 x 0 2 3
from

from

from
y ∞∞ ∞ y 2 0 1 y 2 0 1
z ∞∞ ∞ z 7 1 0 z 3 1 0
node y table
cost to cost to cost to
x y z x y z x y z y
2 1
x ∞ ∞ ∞ x 0 2 7 x 0 2 3 x z
from

from
from

y 2 0 1 y 2 0 1 y 2 0 1 7
z ∞∞ ∞ z 7 1 0 z 3 1 0
node z table
cost to cost to cost to
x y z x y z x y z

x ∞∞ ∞ x 0 2 7 x 0 2 3
from
from
from

y ∞∞ ∞ y 2 0 1 y 2 0 1
z 7 1 0 z 3 1 0 z 3 1 0
time
Telecomm. Dept. DCN
73
Faculty of EEE HCMUT
Distance Vector: link cost changes
Link cost changes:
 node detects local link cost change 1
y
 updates routing info, recalculates 4 1
distance vector x z
50
 if DV changes, notify neighbors

At time t0, y detects the link-cost change, updates its DV,


“good and informs its neighbors.

news At time t1, z receives the update from y and updates its table.
It computes a new least cost to x and sends its neighbors its DV.
travels
At time t2, y receives z’s update and updates its distance table.
fast” y’s least costs do not change and hence y does not send any
message to z.

Telecomm. Dept. DCN


74
Faculty of EEE HCMUT

Vous aimerez peut-être aussi