Packet forwarding in Ethernet switches (bridges) and IP routers

Download Report

Transcript Packet forwarding in Ethernet switches (bridges) and IP routers

Ethernet switches and IP routers
• Ethernet MAC address: Flat 6-byte addresses
– Full address match for forwarding
– If there is no match, forward on all interfaces as
determined by state (set by spanning tree algorithm)
• IP address: Hierarchical 4-byte addresses
– Longest prefix match
M. Veeraraghavan (originals by J. Liebeherr)
1
Transparent Bridges
• Three aspects of bridge operation:
(1) Forwarding of Frames
(2) Learning of Addresses
(3) Spanning Tree Algorithm
M. Veeraraghavan (originals by J. Liebeherr)
2
Frame Forwarding
• Each bridge maintains a filtering database with entries
< MAC address, port, age>
MAC address: host name or group address
port:
port number of bridge
age:
aging time of entry
with interpretation:
• a machine with MAC address lies in direction of the
port number from the bridge. The entry is age time
units old.
M. Veeraraghavan (originals by J. Liebeherr)
3
Frame Forwarding 2
• Assume a MAC frame arrives on port x.
Port x
Search if MAC address of
destination is listed
for ports A, B, or C.
Bridge 2
Port A
Port C
Port B
Found?
Forward frame on
corresponding port if different
from the port on which the
frame arrived and the port state
allows it
M. Veeraraghavan (originals by J. Liebeherr)
Not
found ?
Flood the frame, i.e.,
send the frame on all
ports except port x if port
states allow it.
4
Forwarding conditions
• Forward a MAC frame if and only if
– The receiving port is in a forwarding state (will learn the
meaning of this term in the routing lecture)
– The transmitting port is in a forwarding state
– Either the filtering database indicates the port number for
the destination MAC address or no such entry is present
(in which case all ports are eligible transmission ports)
– Do not transmit on port on which frame was received
– The maximum service data unit size supported by the LAN
to which the transmitting port is connected is not
exceeded.
M. Veeraraghavan (originals by J. Liebeherr)
5
Address Learning
• In principle, the filtering database could be set statically
(=static routing)
• In the 802.1 bridge, the process is made automatic with a
simple heuristic:
The source address field of a frame that arrives on a
port is used by the bridge to update its filtering
database, which indicates the port through which
each host is reachable.
Port x
host n
Bridge 2
Port A
LAN 3
M. Veeraraghavan (originals by J. Liebeherr)
Port C
Port B
6
Address Learning 2
Algorithm:
• For each frame received, the bridge stores the source
address field in the filtering database together with the port
on which the frame was received.
• All entries are deleted after some time (default is 300
seconds).
Port x
host n
Bridge 2
Port A
LAN 3
M. Veeraraghavan (originals by J. Liebeherr)
Port C
Port B
7
Example
•Consider the following packets:
<Src=A, Dest=F>, <Src=C, Dest=A>, <Src=E, Dest=C>
•What have the bridges learned?
Bridge 1
Port1
Bridge 2
Port2
LAN 1
A
B
M. Veeraraghavan (originals by J. Liebeherr)
Port2
Port1
LAN 2
C
LAN 3
D
E
F
8
Forwarding MAC frames and learning
• Relaying of MAC frames and observation of traffic
Port state
information
Filtering database
Frame
forwarding
Port state
information
Learning
process
Frame
reception
Frame
transmission
Learning process writes Filtering DB
Frame forwarding reads Filtering DB
M. Veeraraghavan (originals by J. Liebeherr)
9
Internet Address Classes
• IP distinguishes 5 classes of addresses.
Class A
Class B
Class C
Class D
0
network id
host
7 bits
24 bits
1 0
network id
host
14 bits
16 bits
1 1 0
1 1 1 0
network id
host
21 bits
8 bits
multicast group id
28 bits
Class E
1 1 1 1 0
(reserved for future use)
27 bits
M. Veeraraghavan (originals by J. Liebeherr)
10
IP Addresses
• The end points of each range are not allowed because all
zeros and all ones are disallowed for netid, subnetid and
hostid (see pg. 42 of text and RFC791).
Class From
To
A
0.0.0.0
B
128.0.0.0 191.255.255.255
C
192.0.0.0 223.255.255.255
D
224.0.0.0 239.255.255.255
E
240.0.0.0 247.255.255.255
M. Veeraraghavan (originals by J. Liebeherr)
127.255.255.255
11
Routing
• There are two parts to the routing problem:
1. How to pass a packet from an input interface to
the output interface of a router (“packet forwarding”) ?
2. How to create routing tables?
• In this lecture, we only discuss the packet forwarding part.
The other function is discussed in the routing protocols
lecture.
M. Veeraraghavan (originals by J. Liebeherr)
12
IP Forwarding
• A packet is typically forwarded to a large number of routers
before reaching the destination host.
• IP forwarding is done on a hop-by-hop basis,
i.e., no one knows the complete route. The goal of forwarding
is to bring the IP datagram closer to the destination.
M. Veeraraghavan (originals by J. Liebeherr)
13
IP Forwarding
• IP forwarding is performed by both hosts and routers.
• The difference between IP forwarding in a host and in a router is that a
host’s IP module does not forward packets received on an interface to
another interface (if it does then it is behaving as a router). In a host, IP
forwarding is from the higher layers to an interface or vice versa
• Both routers and hosts have a routing table. Routing table entries look like
this and is looked up for each datagram:
Destination Specification
IP address of an interface
Whole IP
address or
network ID of
IP address
M. Veeraraghavan (originals by J. Liebeherr)
Interface to which
the datagram is
passed
14
Forwarding Functions at Host
• Forwarding an IP datagram at a host:
DestIP = destination IP address
If (destination is on the same network as host)
Deliver datagram to destination directly;
else
Send datagram to default router;
• Reception of an IP datagram at a host:
Datagram is received on an interface
If (Destination IP address == (my IP address ||
broadcast address))
Deliver datagram to higher layer;
else
Discard the datagram;
M. Veeraraghavan (originals by J. Liebeherr)
15
Forwarding Functions at Router
• Reception of an IP datagram at a router:
Packet is received on an interface
If (Destination IP address != my IP address)
Perform datagram forwarding;
• Forwarding an IP datagram at a router:
DestIP = destination IP address
If (Part of DestIP matches Part of only one
“Destination IP address” in routing table)
Deliver datagram to the outgoing interface specified in the table;
else if (it matches multiple entries)
Use routing data of the “longest-prefix” that
matches
else
deliver packet to default router;
M. Veeraraghavan (originals by J. Liebeherr)
16
Need for Routing
• What do bridges do if
some LANs are
reachable only in
multiple hops ?
• What do bridges do if the
path between two LANs
is not unique ?
LAN 2
d
Bridge 4
Bridge 3
Bridge 1
LAN 5
Bridge 5
LAN 1
Bridge 2
LAN 3
M. Veeraraghavan (originals by J. Liebeherr)
LAN 4
17
Danger of Loops
• Consider the two LANs that are connected
by two bridges.
LAN 2
• Assume host n is transmitting a
frame F with unknown destination.
What is happening?
• Bridges A and B flood the frame
to LAN 2.
• Bridge B sees F on LAN 2 (with
unknown destination), and copies
the frame back to LAN 1
LAN 1
• Bridge A does the same.
• The copying continues
Bridge B
Bridge A
host n
F
Where’s the problem? What’s the solution ?
M. Veeraraghavan (originals by J. Liebeherr)
18
Spanning Trees
• IEEE 802.1 has an algorithm that builds and maintains a
spanning tree in a dynamic environment.
• Bridges exchange messages to configure the bridge
(Configuration Bridge Protocol Data Unit, Configuration
BPDUs) to build the tree.
M. Veeraraghavan (originals by J. Liebeherr)
19
Concept - Bridge ID
• Each bridge has a unique identifier (8 bytes):
Bridge ID = <priority level + MAC address>
Priority level = 2 bytes; Note that a bridge has several MAC addresses
(one for each port), but only one ID using the MAC address of the lowest
numbered bridge port (port 1)
• Each port within a bridge has a unique identifier (port ID).
0:0:1:2:3:5
Bridge
2
3 1
Priority: 0x12:41
51:24:68:1f:3:4
fe:64:96:12:1:3
Example above: Bridge ID = 12:41:fe:64:96:12:1:3
M. Veeraraghavan (originals by J. Liebeherr)
20
Concept - Root bridge of a network
• Root Bridge: The bridge with the lowest identifier is the root
of the spanning tree.
Bridge 3 with ID
0:1:34:1:21:56:19:87
1
LAN A
LAN B
2
1
Bridge 1 with ID=
4:1:21:1:21:56:19:87
M. Veeraraghavan (originals by J. Liebeherr)
1
Bridge 2 with ID=
6:4:55:4:21:56:19:87
Root bridge is bridge 3
since it has the smallest ID
21
Concept - For each bridge
• Root Port: Each bridge has a root port which identifies the
next hop from a bridge to the root.
• Root Path Cost: For each bridge, the cost of the min-cost
path to the root
• Example on previous slide: What is the root port and root path
cost of bridge 1:
– The root port is port 2 since it leads to the root bridge
(bridge 3)
– The root path cost is 1 since bridge 1 is one hop away from
the root bridge (I.e., bridge 3).
• Note: We assume that “cost” of a path is the number of “hops”.
M. Veeraraghavan (originals by J. Liebeherr)
22
Concept - For each LAN
• Designated Bridge, Designated Port: Single bridge on a
LAN that provides the minimal cost path to the root for this
LAN, and the port on this minimal cost path
– if two bridges have the same cost, select the
one with highest priority (lower bridge ID)
– if the min-cost bridge has two or more ports
on the LAN, select the port with the lowest
identifier
• Example on slide 25: for LAN A, the designated bridge is
bridge 3 since it is the root bridge itself; port 1 is the
designated port; for LAN B, the designated bridge is bridge 1
since this is closer to the root bridge than bridge 2. The
designated port is port 1.
M. Veeraraghavan (originals by J. Liebeherr)
23
Concept - Designated bridge/port
• Even though each LAN is the entity that has a designated
bridge/designated port, it is each bridge that determines
whether or not it is the designated bridge for the LAN on each
of its ports.
• Example: Bridge 1 in the example on slide 25 determines
whether it is the designated bridge for LAN A (to which its port
2 is connected) and for LAN B (to which its port 1 is
connected).
– Answer in this case is that bridge 1 is the designated
bridge for LAN B, but it is not the designated bridge for
LAN A
M. Veeraraghavan (originals by J. Liebeherr)
24
Steps of Spanning Tree Algorithm
1. Determine the root bridge of the whole network
2. For all other bridges determine root ports
3. For all bridges, determine which of the bridge ports
are designated ports for their corresponding LANs
• The spanning tree consists of all the root ports and the
designated ports.
• These ports are all set to the “forwarding state,” while all
other ports are in a “blocked state.”
M. Veeraraghavan (originals by J. Liebeherr)
25
What we just did
• We just determined the spanning tree for a network of LANs
and bridges in a “centralized manner.”
– We knew the bridge IDs of all the bridges and the port IDs of all the
ports in all the bridges.
– We determined the root bridge (the bridge with the smallest ID.)
– For each bridge, we determined the shortest path to the root by
counting hops and thus identified the root port.
– For each bridge, we determined which of its ports are designated ports
for each of its LANs
• However, the network of bridges determines the spanning
tree in a “distributed manner” - each with limited knowledge.
– This is done using messages called BPDUs.
M. Veeraraghavan (originals by J. Liebeherr)
26
How do the bridges determine the spanning
tree?
With the help of the BPDUs, bridges can:
• Elect a single bridge as the root bridge.
• Each bridge can determine:
– a root port, the port that gives the best path to the root.
– And the corresponding root path cost
• Each bridge determines whether it is a designated bridge,
for the LANs connected to each of its ports. The designated
bridge will forward packets towards the root bridge.
• Select ports to be included in the spanning tree.
– Root ports and designated ports
M. Veeraraghavan (originals by J. Liebeherr)
27
Short form notation for BPDUs
• Each bridge sends out BPDUs that contain the following
information:
root ID cost bridge ID/port ID
root bridge (what the sender thinks it is)
root path cost for sending bridge
Identifies sending bridge
Identifies port on which this BPDU is
sent
M. Veeraraghavan (originals by J. Liebeherr)
28
Ordering of Messages
• We can order BPDU messages with the following ordering
relation ““:
M1
ID R1
C1
ID B1

ID R2
C2
ID B2
M2
If (R1 < R2)
M1  M2
elseif ((R1 == R2) and (C1 < C2))
M1  M2
elseif ((R1 == R2) and (C1 == C2) and (B1 < B2))
M1  M2
M. Veeraraghavan (originals by J. Liebeherr)
29
Determine the Root Bridge
• Initially, all bridges assume they are the root bridge.
• Each bridge B sends BPDUs of this form on its LANs:
B
0
B
• Each bridge looks at the BPDUs received on all its ports and
its own transmitted BPDUs.
• Root bridge is the smallest received root ID that has been
received so far (Whenever a smaller ID arrives, the root is
updated)
M. Veeraraghavan (originals by J. Liebeherr)
30
Calculate the Root Path Cost
Determine the Root Port
• At this time: A bridge B has a belief of who the root is, say R.
• Bridge B determines the Root Path Cost (Cost) as follows:
• If B = R :
Cost = 0.
• If B R:
Cost = {Smallest Cost in any of BPDUs that were
received from R} + 1
• B’s root port is the port from which B received the lowest
cost path to R (in terms of relation ““).
• Knowing R and Cost, B can generate its BPDU (but will not
necessarily send it out):
R
M. Veeraraghavan (originals by J. Liebeherr)
Cost
B
31
Determine if the bridge is the designated bridge for
any of the LANs connected to its ports
• At this time: B has generated its BPDU
R
Cost
B
• B will send this BPDU on one of its ports, say port x, only if
its BPDU is lower (via relation ““) than any BPDU that B
received from port x.
• In this case, B also assumes that it
is the designated bridge for the
LAN to which the port connects.
Port x
Bridge B
Port A
Port C
Port B
M. Veeraraghavan (originals by J. Liebeherr)
32
Selecting the Ports for the Spanning Tree
• At this time: Bridge B has calculated the root bridge for the
network, its root port, root path cost, and whether it is the
designated bridge for each of its LANs.
• Now B can decide which ports are in the spanning tree:
• B’s root port is part of the spanning tree
• All ports for which B is the designated bridge are part of
the spanning tree.
• B’s ports that are in the spanning tree will forward packets
(=forwarding state)
• B’s ports that are not in the spanning tree will block packets
(=blocking state)
M. Veeraraghavan (originals by J. Liebeherr)
33
Building the Spanning Tree
• Consider the network on the
right.
• Assume that the bridges
have calculated the
designated ports (D) and the
root ports (R) as indicated.
LAN 2
R
Bridge
Bridge
D
R
R
LAN 5
Bridge
R
Bridge
• What is the spanning tree?
D
LAN 1
R
D
LAN 3
M. Veeraraghavan (originals by J. Liebeherr)
Bridge
D
LAN 4
34
Adapting to Changes
• Bridges continually exchange BPDU’s according to the rules
we just discussed.
• This allows the bridges to adapt to changes to the topology.
• Whenever a BPDU arrives on a port, say port x, B bridge
determines:
• Can B become the designated bridge for the LAN that
port x is attached to?
• Can port x become the root port?
M. Veeraraghavan (originals by J. Liebeherr)
35
Example 1
• Assume a Bridge with ID 18 has received the following as
the lowest messages on its 4 ports:
12.93.51
15.31.27
Port 1
Port 4
Bridge 18
Port 2
12.85.47
Port 3
81.0.81
• What is the root?
Root is 12
• What is the Root Path Cost?
85 +1 = 86
•What is the root port?
Port 2
• What is 18’s configuration BPDU?
12.86.18
•For which LAN (port), if any, is B the
designated bridge?
For Ports 1,3, 4
M. Veeraraghavan (originals by J. Liebeherr)
36
Example 2 (Practice - Solution in Exercises)
• Assume a Bridge with ID 3 is receiving the following as the
lowest messages on its five ports:
Bridge 3
Port 5
Port 1
81.0.81
41.13.90
Port 3
Port 2
41.19.125
Port 4
41.12.111
41.12.315
• What is the root?
• What is the Root Path Cost?
• What is the root port ?
• What is 3’s configuration BPDU?
• For which LAN (port), if any, is B the designated bridge ?
M. Veeraraghavan (originals by J. Liebeherr)
37
Network Example (Practice - Solution in
Exercises)
• The attached network shows 5
LANs that are interconnected
by 5 bridges.
• The ID’s of the bridges are
1,2,3,4,5 and the port ID’s are
as indicated in the figure.
• The bridges run the spanning
tree algorithm.
LAN 2
Port
1a
Port
3b
Port 4b
LAN 5
Bridge 1
Port
1b
Port 5a
Bridge 5
Port 5b
LAN 1
• Assume an initial state.
M. Veeraraghavan (originals by J. Liebeherr)
Port 4a
Bridge 4
Bridge 3
• Assume that the root cost path
is the number of hops.
• Show which messages are
exchanged until the tree is
built.
d
Port 3a
Port 2a
Port 2b
LAN 3
Bridge 2
Port 2c
LAN 4
38
Interesting cases
• If two min-cost BPDUs received at a bridge on two different
ports are equal in the root ID, root path cost and sending
bridge ID, and the root ID is the smallest of the root Ids on all
previously received BPDUs, then the designated ports for the
LANs corresponding to the two ports on which the two BPDUs
are received are compared. The smaller one of these (which
will have the higher priority) will be chosen. The port on the
bridge receiving these BPDUs which is on the LAN of this
selected designated port is the root port of the bridge.
• Ref: Section 4.5.3.3 (page 53) of the IEEE 802.1D
specification.
M. Veeraraghavan (originals by J. Liebeherr)
39
Example
• Bridge 2 receives two BPDUs [1,0,1] on both its ports 3 and 4
• The designated port for LAN A is port 1 on bridge 1
• The designated port for LAN B is port 2 on bridge 1
• Since port 1 is lower than port 2, it has higher priority.
• Hence port 4 is the root port.
LAN A
Port 1
Port 4
Bridge 2
Bridge 1
Port 2
Port 3
LAN B
M. Veeraraghavan (originals by J. Liebeherr)
40
Another case
• Furthermore, section 4.5.3.3 of IEEE 802.1D states that if
even the designated ports of the LANs corresponding to the
ports on which a bridge receives the same BPDUs are the
same, then look at the port numbers on the bridge itself at
which these BPDUs are received and select the lower one to
be the root port.
M. Veeraraghavan (originals by J. Liebeherr)
41
Example
• Ports 4 and 2 of bridge 2 are on LAN A. They will both receive
BPDU [1,0,1] from bridge 1. The designated port for LAN A is
port 1 on bridge 1. So even the designated ports are the
same. Hence choose between ports 2 and 4 by selecting the
lower one, which is port 2 as the root port.
LAN A
Port 2
Port 1
Port 4
Bridge 2
Bridge 1
Port 2
Port 3
LAN B
M. Veeraraghavan (originals by J. Liebeherr)
42
Priority
• Finally, see pg 102 of the spec, section 5.2.5. It states that the
”Two bridge identifiers when compared numerically, the lesser
number shall denote the bridge of the higher priority."
M. Veeraraghavan (originals by J. Liebeherr)
43