Download Spanning Tree Protocol for Bridges/Switches

Document related concepts

Parallel port wikipedia , lookup

Wake-on-LAN wikipedia , lookup

Cracking of wireless networks wikipedia , lookup

Spanning Tree Protocol wikipedia , lookup

Transcript
Spanning Tree Protocol for
Bridges/Switches
8-1
Bridge = Switch
• Bridge/switches are layer-2 switching device (look
at the Ethernet destination address to decide how
to forward a frame)
• Used to separate collision domains (segment)
– Reduce collision probability
– Increase aggregate bandwidth
– Extend LAN’s length
• Can form a large and complicated network
topology.
8- 2
Bridge ≠ Router
• Routers are layer-3 switching device. (Look at the
IP destination address to decide how to forward a
packet)
• Routers use a routing protocol (RIP or OSPF) to
explicitly exchange routing information.
– Bridges/switches do not use a protocol to exchange
routing information.
– Instead, bridges/switches implicitly learn how to
forward packets.
• Bridge/switches are transparent to layer 3.
8- 3
A Topology Example
Bridge/switch
Router
Same subnet
8- 4
Bridge’s Features
•
•
•
•
Listen promiscuously
Store and forward packets (not cut-through)
Learn where a packet should be forwarded to
Use spanning tree algorithm to avoid loops
8- 5
Simplest Bridge
• Promiscuously listen to every packet transmitted
• Forward a received packet to all of other segments
• Does not increase the total bandwidth, though. 8- 6
Desired Improvements
• If the source and destination hosts are on
the same segment (port), the bridge need
not forward a received packet to all of other
segments (ports).
• If the source and destination hosts are on
different segments (ports) and the
destination host is on port i, the received
packet should be forwarded to port i only,
rather than all of other ports.
8- 7
Simple Method 1
• Humane type in addresses for each port and this
database is keep at the bridge.
8- 8
Simple Method 2
• Place stations so that each LAN has only stations
whose addresses were within a certain range.
8- 9
Simple Method 3
• Let layer 2 addresses embed layer-3
addresses (LAN).
8- 10
Management headache
• All these simple methods cause management
headache.
– In method 1 and 2, the manager needs to key in many
layer-2 address or range.
– In method 2, the hosts need to be placed in a particular
way.
– In method 3, the hosts need to be able to configure its
own layer-2 address. This may generate the same layer2 addresses by error.
• The best method is that a bridge can learn which
host is on which port itself.
8- 11
Learning Bridge
• Listen promiscuously to every packet.
• Store the layer-2 source address of the received packet
with the port on which it is received in a cache. (learn)
• Check the layer-2 destination address of the received
packet in the cache:
– If not found, forward this packet to all ports except the one
from which it was received.
– If found (support port i), forward the packet only onto port i.
• If port i is the port from which this packet is received, the received
packet is dropped. (filtered)
• The bridge ages each entry in the cache and delete it
after a period of time.
8- 12
Example 1
8- 13
Example 1
8- 14
Example 1
8- 15
Example 1
The bridge concludes that Q and A are on the same segment,
therefore the Q to A packet can be discarded.
8- 16
Example 2
Bridge B1 cannot distinguish between hosts that are on
LAN 2 and LAN 3 because B2 connect LAN 2 and LAN
3 transparently.
8- 17
Example 2
• After every host has transmitted some packets, B1
and B2 know which host resides on which port.
8- 18
Example 2
From B1’s point of view, the network topology looks
like this.
8- 19
Example 2
From B2’s point of view, the network topology looks
like this.
The learning bridge concept works for any tree topology!
8- 20
Learning Bridges Will Fail under Loops
• When there are loops in the topology, packets will
spawn themselves and loop indefinitely.
8- 21
A Possible Scenario
1. On LAN 1, A sends a packet to R. So far,
because B1, B2, and B1 do not know which
LAN R is on, they forward the received packet to
LAN 2. At the same time, B1, B2, and B3 note
that A is on LAN 1.
2. Suppose that the packet forwarded by B3 reaches
B1 and B2, B1 and B1 and B2 will note that A
now moves from LAN1 to LAN2. (very strange!)
3. Suppose that B2 forwards the packet received in
step 1 onto LAN2, then this packet will reach B1
and B3. B1 and B3 will note that now A is no
LAN1. (very strange!)
8- 22
Spawn and Loop Problems
• From the above example, we see that when
there is a loop in the network topology,
packet will loop forever -- wasting network
bandwidth.
• Worst of all, a packet will spawn itself
many time whenever it is forwarded by a
bridge -- drastically wasting network
bandwidth!
8- 23
The Bridge’s Problem is Worse than
That of the Router
• If there is a loop among routers, packet will be
trapped in the loop.
• However, since a router only forwards a packet to
one specific router, packets will not spawn
themselves.
• In addition, the TTL field in the IP header limits the
maximum number of transmissions that a packet can
have.
– However, in the layer-2 header, there is no such field.
• So, the lesson is that we should never let loops occur
even if we need to sacrifice some performance. 8- 24
What Can We Do?
• Decide that using bridges is a bad idea ?
– But clearly it has many advantages.
• Document that when using bridges, the network
topology must be a tree.
– However, when the network becomes large and complicated,
it is hard to know if adding a link will cause a loop.
– Also, for fault tolerance concerns, loops are good.
• Design bridges so that they can detect the existence of
loops and issue people a warning.
– Better than nothing.
• Design bridges so that they can prune the topology into a
tree.
– The best.
8- 25
A Spanning Tree Algorithm Is Needed
• Bridges will need
to use a
distributed
spanning tree
algorithm to shut
off some ports so
that the resulting
topology is a
loop-free tree.
8- 26
The Way Spanning Tree Works
• Bridges transmit special messages (called
configuration message) to each other.
• A bridge will be elected as the root bridge.
• Every bridge calculates the distance of the shortest
path from itself to the root bridge.
• For each LAN, select a designated bridge among the
bridges residing on the LAN.
• For each bridge, choose a port (root port) that lead to
the root bridge.
• Ports to be included in a spanning tree are the root
ports and the ports on which self has been elected as
designated bridge.
8- 27
Configuration Message
8- 28
Configuration Message
• A configuration message is transmitted by a
bridge onto a port. It is received by all the other
bridges on the LAN attached to the port. It is not
forwarded outside the LAN.
• Root ID: ID of the bridge assumed to be the root.
• Bridge ID: ID of the bridge transmitting this
configuration message.
• Cost: Cost of the shortest path from the
transmitting bridge to the root bridge.
• Port ID: ID of the port from which the
configuration message is transmitted.
8- 29
Configuration Message
• A bridge initially assume itself to be to root and
transmits configuration messages on each of its
ports with its ID as root and as transmitting bridge
and 0 as cost.
• A bridge continuously receives configuration
messages on each of its ports and save the best
configuration messages from each port.
• The bridge determines the “best” configuration
message by comparing not only the configuration
messages received from a particular port but also
the configuration message that the bridge would
transmit on that port.
8- 30
Compare Two Configuration
Messages C1 and C2
• C1 is better than C2 if the root ID in C1 is lower
than that in C2.
• If the root IDs are equal, then C1 is better than C2
if the cost in C1 is lower than that in C2.
• If the root ID and cost are equal, then C1 is better
than C2 if its transmitting ID is lower than that in
C2.
• If the root ID, cost, and transmitting IDs are equal,
then then C1 is better than C2 if its port ID is
lower than that in C2.
8- 31
Compare Two Configuration
Messages C1 and C2
• In the above three cases, C1 is better than C2.
• If a bridge receives a better configuration message
on a LAN than it would transmit, it no longer
transmits configuration messages on that LAN.
8- 32
Calculation Root ID and Cost to the Root
• Each bridge independently determines the
ID of root bridge. It is the minimum of the
received root IDs and the ID of the bridge.
• Assume the ID of the bridge B is 18 and the
following is the received messages:
8- 33
Calculation Root ID and Cost to the Root
• The best configuration message is from port 2.
• Therefore, the best root heard about by B is 12.
• And, the distance to the root bridge from B is 85 + 1 =
86.
• And, the root port (and port leading to the root bridge)
is port 2.
• B’s own configuration message now is 12.86.18. It is
better than those received from port 1, 3, and 4.
• B now is the designated bridge on port 1, 3, and 4 and
transmit its configuration message onto port 1, 3, and 4.
8- 34
Select Spanning Tree Ports
• For bridge B, the following ports are selected for
inclusion into the spanning tree:
– B’s root port (port 2).
– All ports for which B is the designated bridge. (port 1, 3,
and 4)
• Selected ports are placed in the forwarding state,
meaning that B will forward packets to and from
those ports.
• All other ports are placed in the blocking state,
meaning that B will NOT forward packet to and
from them.
8- 35
Spanning Tree Example
• The best known root is 41 and the best cost
to 41 is 12+1 = 13.
• The root port selected is port 4 because 111
< 315.
8- 36
Spanning Tree Example
• The configuration message (CM) that bridge 92
will transmit is 41.13.92.
• It is better than those received from port 1 and 2.
Therefore, B92 is the designated bridge on port 1
and 2 and B92 transmits its CM onto port 1 and 2.8- 37
Spanning Tree Example
• Because B92’s CM (41.13.92) is not better than
41.13.90, B92 is not designated bridge on port 5
and will not transmit its CM onto port 5.
• Port 1, 2, and 4 will be included in the spanning
tree. Port 3 and 5 will be shut off.
8- 38
Detect Bridge Failure
• We need to handle the case when a bridge fails or
is shut down. Because at that time, a new spanning
tree should be constructed.
• The stored configuration message for each port
contains a message age field, which is
incremented after each unit of time. If the message
reaches a certain threshold (maxage), the CM is
discarded and the bridge recalculates as if it had
never received a CM from that port.
– This is to detect if designated bridge on a port is dead
or not.
8- 39
Refresh the Configuration Messages
• The root bridge periodically transmits
configuration message (every hello time)
down the spanning tree. The message age
field is set to 0.
• Every bridge on the spanning tree transmits
the received configuration messages down the
spanning tree. The message age is set to 0.
8- 40
Example
• Port 4’s CM times out.
• The root port switches to port 3.
• B92 is still the designated bridge on port 1 and 2.
8- 41
Example
• Assume that the CM on port 3 also times out.
• B92 will choose port 5 as the root port and send its
new CM 41.14.92 onto port 1 and 2.
8- 42
Recalculation Spanning tree
• Receipt of a configuration message on port
X.
– The bridge then compare the received CM with
the stored CM . If the received CM is better, the
bridge recalculates its own CM.
• Timer tick
– If a CM expires, the bridge discards the CM
and recalculate its own CM.
8- 43
Avoiding Temporary Loops
• After a topology change, the news will take
sometime to spread to all part of the network.
Until then, the spanning tree algorithm will
operate on inconsistent data. This will have two
possible outcomes:
– Temporary loss of connectivity
– Temporary loops
• Because loops may cause disaster in a bridged
network, the spanning tree algorithm prefers loss
of connectivity to loops.
8- 44
Avoiding Temporary Loops
• To prevent loops from happening, we can require a
bridge to wait some time before allowing a bridge
port that was in the blocking state to transition to the
the forwarding state.
• The timer should be at least twice the maximum
transmit time across the networks (forward delay) so
that the topology change news can spread over all
parts of the network.
• Basically, the idea is that transition ports from the
forwarding state to the blocking state should be done
ASAP. However, transition ports from the blocking
state to the forwarding state should be deferred by
some time so that no temporary loop will form. 8- 45
Why Do We Need Port ID?
• To select a unique path to the root bridge.
8- 46
Host Cache Timeout Value
• Bridges learn and cache the location of
hosts. Because a host may move, it is
important for a bridge to “forget” host
locations unless its is frequently reassured
that the learned information is correct.
• This is done by timing out entries that have
not been recently verified.
• However, choosing a suitable timeout value
is difficult:
8- 47
Host Cache Timeout Value
• If the chosen timeout value is too long and a host
has moved to other place, traffic may not be
correctly delivered to the host at the new place.
Rather, traffic for that host is still delivered to the
old place. (This is bad for roaming over multiple
wireless access points.)
• If the chosen timeout value is too short (i.e., a
cache entry be deleted) and a host has not moved,
then the bridge unnecessarily needs to forward a
received packet destined for that host to all other
ports, which wastes a lot of network bandwidth.
8- 48
Host Cache Timeout Value
• A long value (e.g., 15 seconds) is used in the usual
case to reduce wasted network bandwidth.
– Usually, hosts do not move.
• A shorter value (e.g., forward delay) is used
following a reconfiguration of the spanning tree
algorithm.
– When a spanning tree reconfigures, it may change which
bridge should serve which LAN (the hosts on that LAN).
– For this case, the timeout value should be short. Otherwise,
hosts that change their designated bridge may not receive
traffic for them for a long time.
– Hosts may feel strange why every now and then, their
network paths are broken without any reason.
8- 49
Detecting and Informing Topology Change
• We need a reliable way of informing bridges that the
network topology has changed and they should use the
shorter timeout value.
• The bridge that detects a topology change will send a
message to its parent. This message will in turn be
forwarded to the root bridge.
• The root bridge then set the topology change flag bit in
its configuration messages that are sent (every hello
time) downstream the spanning tree for a period that is
forward delay plus max age long.
• The bridges that receive this type of messages use the
shorter timeout value for their caches until the flag is
no longer set.
8- 50
Network Parameters
• Bridge priority: the most significant portion of a bridge ID.
Used to influence the choice of root bridge.
• Port priority: used to influence the choice of port when a
bridge has twos connected in a loop.
• Hello time: The time between successive generation of
configuration messages by a bridge that assumes itself to
be the root.
• Max age: the message age value at which a stored CM is
discarded.
• Forward delay: a parameter that temporarily prevents a
bridge from starting to forward data packets to and from a
link until news of topology change has spread to all parts
of a bridged network.
8- 51
Performance Requirement for Bridges
• The spanning tree algorithm has two properties that
make performance critical:
– Lack of receipt of messages causes bridges to add
connectivity. E.g., if a bridge does not receive any CM on
some port, it will take over as the designated bridge on
that port.
• Extra connectivity (loops) is potentially disastrous.
• Therefore, bridges should be designed to transmit
CM correctly and quickly during congestion.
otherwise, loops will results and cause more severe
congestion, which in turn may make bridges unable
to recover from congestion.
8- 52
Bridges May Not be Transparent
• Packet dropping due to buffer overflow.
• Delay may increase due to MAC or queuing delay.
• Error rate may increase. We want to keep the original CRC
to catch errors made inside the bridge. However, when
packets are forwarded between different kinds of LANs,
CRC needs to be regenerated.
• Packet misordering may becomes possible when spanning
tree changes.
• Packet duplication may becomes possible. E.g., a repeater
just comes up that connects two LAN which were
previously separated in the spanning tree.
8- 53
Broadcast Storm
• Will cause a flurry of messages which waste
network bandwidth and may never end.
• Mainly observed with the IP protocol.
• One implementation decision with BSD cause this
problem.
– An end host will try to forward to a packet that it
mysteriously receives with a network layer address of a
different host.
– Suppose that one IP host is incorrectly configured so that
it thinks that its layer-2 address is all 1’s – the broadcast
address.
– What will happen when some host wants to send a packet
to that host?
8- 54