SlideShare a Scribd company logo
1 of 4
Download to read offline
Implementation of Spanning Tree Protocol using ns-3
Naishil Shah (nanshah@ucsc.edu)1 and Sneha Das (sndas@ucsc.edu)2
Abstract— The goal of this project is to implement the
Spanning Tree Protocol (STP) introduced by Radia Perlman.
We use a discrete event network simulator NS3 primarily used
in research and teaching for the implementation of this project.
I. INTRODUCTION
A routing loop is a serious network problem which
happens when a data packet is continually routed through
the same routers over and over. The data packets continue to
be routed within the network in an endless circle. A routing
loop can have a catastrophic impact on a network, and
in some cases, completely disabling the network.A major
portion of the precious bandwidth which is available for
normal user traffic of the affected routers will be consumed
by looping IP datagram packets. Also a major portion of the
processing power of the affected routers is used to process
the looping IP datagram packets.
Routing Loops can happen in large internetworks when
a second topology change emerges before the network is
able to converge on the first change. Convergence is the
term used to describe the condition when all routers in an
internetwork have agreed on a common topology. Link state
protocols tend to converge very quickly, while distance
vector protocols tend to converge slowly.Different methods
are used to avoid routing loops such as using a maximum
hop count, split horizon, route poisoning and hold-down
timers. Layer 2 switching loops can cause serious problem
to network communication. One of the basic functions of a
network switch is to eliminate Layer 2 switching loops.
The Spanning Tree Protocol (STP) is a network protocol
that builds a logical loop-free topology for Ethernet
networks. The basic function of STP is to prevent bridge
loops and the broadcast radiation that results from them.
Spanning tree also allows a network design to include
redundant links to provide automatic backup paths if an
active link fails. This is done without the danger of bridge
loops, or the need for manual enabling or disabling of these
backup links.STP creates a spanning tree within a network
of connected layer-2 bridges, and disables those links that
are not part of the spanning tree, leaving a single active
path between any two network nodes.
Loop prevention in a Layer 2 Ethernet is handled dif-
ferently than it is in Layer 3. A Layer 3 IP header has
a time-to-live (TTL) field that is set by the original host
and is decremented at each router, allowing the router to
prevent looped datagrams by discarding packets that reach
TTL=0. This feature is not available for Layer 2 Ethernet
frames.Therefore, after a Layer 2 frame starts to loop in the
network, it continues looping forever until one of these events
occurs:
• A link is broken.
• One of the bridges is turned off.
• A bridge is rebooted.
Bridging tables that are not configured with STP can be
corrupted by the looping created by a broadcast storm.
II. SPANNING TREE PROTOCOL OPERATION
The Spanning tree protocol calculates the best path
through a switched network that contains redundant paths.
It allows bridges to communicate with each other for the
purpose of discovering physical loops in the network. When
physical loops are found, the protocol specifies an algorithm
that bridges can use to create a loop-free logical topology.
Blocking loops prevents broadcast storms in the network.
The STP algorithm computes a tree structure of loop-free
leaves and branches that spans the entire Layer 2 network.
A. Rules to compute spanning tree
The spanning tree that the bridges compute using the Span-
ning Tree Protocol can be determined using the following
rules.
• Select a root bridge: The root bridge of the spanning
tree is the bridge with the smallest (lowest) bridge ID.
Each bridge has a configurable priority number and a
MAC address; the bridge ID is the concatenation of the
bridge priority and the MAC address.The switch with
the lowest priority of all the switches will be the root.
If there is a tie, then the switch with the lowest priority
and lowest MAC address will be the root.
• Determine the least cost paths to the root bridge: The
computed spanning tree has the property that messages
from any connected device to the root bridge traverse a
least cost path. The cost of traversing a path is the sum
of the costs of the segments on the path.
• Disable all other root paths: Any active port that is not
a root port or a designated port is a blocked port (BP).
In the case of ties, they can be broken by applying one
of the following methods:
• By breaking ties for root ports: When multiple paths
from a bridge are least-cost paths, the chosen path uses
the neighbor bridge with the lower bridge ID.
• When the root bridge has more than one port on a single
LAN segment, the bridge ID is effectively tied, as are
all root path costs. The designated port then becomes
the port on that LAN segment with the lowest port ID.
III. NS-3 NETWORK SIMULATOR
In communication and computer network research,
network simulation is a technique where a program
models the behavior of a network either by calculating
the interaction between the different network entities
(hosts/packets etc.) using mathematical formulas, or actually
capturing and playing back observations from a production
network. The behavior of the network and the various
applications and services it supports can then be observed in
a test lab; various attributes of the environment can also be
modified in a controlled manner to assess how the network
would behave under different conditions.
Among the many network simulators present today, we use
ns-3 as the network simulator for this project. It is a discrete-
event network simulator, targeted primarily for research and
educational use. It helps develop a preferred, open simulation
environment for networking research which is aligned with
the simulation needs of modern networking research. The
ns-3 simulation core supports research on both IP and non-
IP based networks. A large majority of its users however
focuses on wireless/IP simulations which involve models for
Wi-Fi, WiMAX, or LTE for layers 1 and 2 and a variety
of static or dynamic routing protocols such as OLSR and
AODV for IP-based applications.
IV. METHODOLOGY ADOPTED
A. Approach A
We tried an approach to exchange HELLO messages
between all the nodes to implement the spanning tree
protocol. The idea was to start by electing the node with
the lowest MAC id as the root node. This root node would
check its immediate neighbors by exchanging HELLO
messages with them. Each node in the topology has an
array of its previously unvisited neighbors. For every node,
it lists neighbors that are in lower priority. As we traverse
through higher MAC ids, this approach makes sure that
previously visited neighbors are not added into the nodes
array. For each neighbor added to the nodes array, we assign
the respective port to be the root port since it will be the
least cost path taken from the root node. In this process,
we block the remaining unused ports, thereby removing any
loops present in the topology.
This distributed mechanism of implementing the protocol
was unsuccessful during the course of the project due to
two reasons. We could not successfully implement detection
of neighboring nodes using HELLO messages. Once this
problem was resolved, we could not figure out how to assign
root ports and designated ports based on this information.
Without this knowledge, we could not proceed with assigning
blocked ports and hence removal of loops was a problem.
Hence we considered another approach which is discussed
in the next section.
B. Approach 2
The in built examples of network simulator 3 were
used to obtain the desired result. We used the program of
matrix-topology.cc given in the tutorials folder of ns3 and
modified it to given us the required result. We understood
that this file gave an adjacency matrix as an output to any
given network topology. We used Prim’s Algorithm on this
adjacency matrix to obtain a graphical spanning tree of
the network. The final output we obtanined after applying
Prim’s Algorithm, was again converted to a topology by
the mst.cc file. To demonstrate the changes made before
and after the application of the algorithm, we depict the
topology using NetAnim. NetAnim is an offline animator
based on the Qt toolkit to view the output obtained. It
animates the simulation using an XML trace file collected
during simulation.As shown in the images that follow, we
tested it for various topologies and this approcah worked
perfectly well for any given topology.
The Prim’s Algorithm’s Pseudo code is explained below.
Algorithm 1 Pseudo code
1: ReachSet = {0} You can use any node
2: UnReachSet = {1, 2, ...N − 1}
3: SpanningTree = {}
4: while UnReachSet = empty do Find edge e= (x,y)
such that:
5: x ∈ ReachSet
6: y ∈ UnReachSet
7: e(smallestcost)
8: SpanningTree = SpanningTree ∪ {e} Add edge
to Spanning tree
9: ReachSet = ReachSet ∪ {y} Add y to visited set
10: UnReachSet = UnReachSet{y} Remove y from
unreached set
Consider the 6-node topology as shown in 1. We use the
following helper classes available in ns-3 as given below. The
definition of these classes have been taken from the official
documentation of ns-3.
• PointToPointHelper :
It builds a set of PointToPointNetDevice objects.
• NodeContainer :
It keeps track of a set of node pointers.Typically ns-3
helpers operate on more than one node at a time. For
example a device helper may want to install devices
on a large number of similar nodes. The helper Install
methods usually take a NodeContainer as a parameter.
NodeContainers hold the multiple Ptr<Node> which are
used to refer to the nodes.
• InternetStackHelper :
It aggregates IP/TCP/UDP functionality to existing
Nodes. This helper enables pcap and ascii tracing of
events in the internet stack associated with a node.
• Ipv4AddressHelper :
A helper class used to make life easier while doing
Fig. 1. Input 6-node topology using NetAnim
Fig. 2. Minimum Spanning Tree obtained for a 6-node topology using
NetAnim
simple IPv4 address assignment in scripts. This class is
a very simple IPv4 address generator. You can think of
it as a simple local number incrementer.
• MobilityHelper :
A Helper class used to assign positions and mobility
models to nodes. MobilityHelper::Install is the most
important method here.
• PacketSinkHelper :
A helper used to make it easier to instantiate an
ns3::PacketSinkApplication on a set of nodes.
The routing tables for the generated nodes are as shown
in the images below in 3 and 4:
V. CONCLUSIONS
The algorithm presented here maintains a spanning acyclic
subset of a general mesh topology. It requires a very
Fig. 3. Routing Table for Minimum Spanning Tree obtained for a 6-node
topology- Nodes 0-2
Fig. 4. Routing Table for Minimum Spanning Tree obtained for a 6-node
topology- Nodes 2-5
small,bounded amount of memory per node,independent of
the total number of nodes. This algorithm can prevent one-
way links from causing loops.The formed graph is a tree. It
has a unique root and each node other than the root has a
unique predecessor closer to the root.Also, given a particular
physical topology, behavior of the algorithm is completely
predictable.
ACKNOWLEDGMENT
We would like to thank Professor J.J. Garcia Luna Aceves
one of the most enjoyable classes we have taken that most
practically demonstrated how computer networks work, and
for all the math. We also acknowledge our Teaching Assistant
Ali Dabirmoghaddam and our classmates for all the sugges-
tions and help on working out the minor technical difficulties
faced while trying to run the code.
REFERENCES
[1] Perlman, Radia. "An algorithm for distributed computation of a
spanningtree in an extended LAN." ACM SIGCOMM Computer
Communication Review. Vol. 15. No. 4. ACM, 1985.
[2] Perlman, Radia. "A protocol for distributed computation of a spanning
tree in an extended lan." Ninth Data Communications Symposium.
1985.
[3] Marchese, Mario, and Maurizio Mongelli. "Simple protocol enhance-
ments of Rapid Spanning Tree Protocol over ring topologies." Com-
puter Networks 56.4 (2012): 1131-1151.
[4] "TechLibrary." Spanning Tree Protocol Operation - Technical Docu-
mentation - Support - Juniper Networks. N.p., n.d. Web. Dec. 2016.
[5] "Ns-3." Ns3 RSS. N.p., n.d. Web.2016.
[6] "Spanning Tree Protocol STP Tutorial." CCNA Training Â˙z Spanning
Tree Protocol STP Tutorial. N.p., n.d. Web. Dec. 2016.
[7] Perlman, Radia (2000). Interconnections, Second Edition. USA:
Addison-Wesley. ISBN 0-201-63448-1.
[8] Attacking the Spanning Tree Protocol." Cisco
Press. N.p., 4 June 2008. Web. 2 Mar.
2016<http://www.ciscopress.com/articles/article.asp?p=1016582>

More Related Content

Similar to Implementation of Spanning Tree Protocol using ns-3

Traffic Engineering in Metro Ethernet
Traffic Engineering in Metro EthernetTraffic Engineering in Metro Ethernet
Traffic Engineering in Metro EthernetCSCJournals
 
Performance Evaluation of a Layered WSN Using AODV and MCF Protocols in NS-2
Performance Evaluation of a Layered WSN Using AODV and MCF Protocols in NS-2Performance Evaluation of a Layered WSN Using AODV and MCF Protocols in NS-2
Performance Evaluation of a Layered WSN Using AODV and MCF Protocols in NS-2csandit
 
Network layer new
Network layer newNetwork layer new
Network layer newreshmadayma
 
Ballpark Figure Algorithms for Data Broadcast in Wireless Networks
Ballpark Figure Algorithms for Data Broadcast in Wireless NetworksBallpark Figure Algorithms for Data Broadcast in Wireless Networks
Ballpark Figure Algorithms for Data Broadcast in Wireless NetworksEditor IJCATR
 
IRJET- Performance Improvement of Wireless Network using Modern Simulation Tools
IRJET- Performance Improvement of Wireless Network using Modern Simulation ToolsIRJET- Performance Improvement of Wireless Network using Modern Simulation Tools
IRJET- Performance Improvement of Wireless Network using Modern Simulation ToolsIRJET Journal
 
Understanding Network Routing Problem and Study of Routing Algorithms and Heu...
Understanding Network Routing Problem and Study of Routing Algorithms and Heu...Understanding Network Routing Problem and Study of Routing Algorithms and Heu...
Understanding Network Routing Problem and Study of Routing Algorithms and Heu...IRJET Journal
 
TransparentInterconnectionsofLotofLinks
TransparentInterconnectionsofLotofLinksTransparentInterconnectionsofLotofLinks
TransparentInterconnectionsofLotofLinksSwapnil Raut
 
ANALYSIS OF ROUTING PROTOCOLS IN WIRELESS MESH NETWORK
ANALYSIS OF ROUTING PROTOCOLS IN WIRELESS MESH NETWORKANALYSIS OF ROUTING PROTOCOLS IN WIRELESS MESH NETWORK
ANALYSIS OF ROUTING PROTOCOLS IN WIRELESS MESH NETWORKIJCSIT Journal
 
Enhancement of Improved Balanced LEACH for Heterogeneous Wireless Sensor Netw...
Enhancement of Improved Balanced LEACH for Heterogeneous Wireless Sensor Netw...Enhancement of Improved Balanced LEACH for Heterogeneous Wireless Sensor Netw...
Enhancement of Improved Balanced LEACH for Heterogeneous Wireless Sensor Netw...acijjournal
 
Final Report(Routing_Misbehavior)
Final Report(Routing_Misbehavior)Final Report(Routing_Misbehavior)
Final Report(Routing_Misbehavior)Ambreen Zafar
 
Local Restoration in Metro Ethernet Networks for Multiple Link Failures
Local Restoration in Metro Ethernet Networks for Multiple Link FailuresLocal Restoration in Metro Ethernet Networks for Multiple Link Failures
Local Restoration in Metro Ethernet Networks for Multiple Link FailuresEditor IJCATR
 
An Approach to Detect Packets Using Packet Sniffing
An Approach to Detect Packets Using Packet SniffingAn Approach to Detect Packets Using Packet Sniffing
An Approach to Detect Packets Using Packet Sniffingijcses
 
Data Communication and Networking(DCACN)
Data Communication and Networking(DCACN)Data Communication and Networking(DCACN)
Data Communication and Networking(DCACN)Uttam Singh Chaudhary
 
IMPLEMENTATION OF NETWORK DESIGN FOR UNIVERSITIES WITH IOT
IMPLEMENTATION OF NETWORK DESIGN FOR UNIVERSITIES WITH IOTIMPLEMENTATION OF NETWORK DESIGN FOR UNIVERSITIES WITH IOT
IMPLEMENTATION OF NETWORK DESIGN FOR UNIVERSITIES WITH IOTIRJET Journal
 

Similar to Implementation of Spanning Tree Protocol using ns-3 (20)

Traffic Engineering in Metro Ethernet
Traffic Engineering in Metro EthernetTraffic Engineering in Metro Ethernet
Traffic Engineering in Metro Ethernet
 
Network Layer
Network LayerNetwork Layer
Network Layer
 
Performance Evaluation of a Layered WSN Using AODV and MCF Protocols in NS-2
Performance Evaluation of a Layered WSN Using AODV and MCF Protocols in NS-2Performance Evaluation of a Layered WSN Using AODV and MCF Protocols in NS-2
Performance Evaluation of a Layered WSN Using AODV and MCF Protocols in NS-2
 
Network layer new
Network layer newNetwork layer new
Network layer new
 
Ballpark Figure Algorithms for Data Broadcast in Wireless Networks
Ballpark Figure Algorithms for Data Broadcast in Wireless NetworksBallpark Figure Algorithms for Data Broadcast in Wireless Networks
Ballpark Figure Algorithms for Data Broadcast in Wireless Networks
 
Network Layer
Network LayerNetwork Layer
Network Layer
 
IRJET- Performance Improvement of Wireless Network using Modern Simulation Tools
IRJET- Performance Improvement of Wireless Network using Modern Simulation ToolsIRJET- Performance Improvement of Wireless Network using Modern Simulation Tools
IRJET- Performance Improvement of Wireless Network using Modern Simulation Tools
 
Network layer u3
Network  layer u3Network  layer u3
Network layer u3
 
Understanding Network Routing Problem and Study of Routing Algorithms and Heu...
Understanding Network Routing Problem and Study of Routing Algorithms and Heu...Understanding Network Routing Problem and Study of Routing Algorithms and Heu...
Understanding Network Routing Problem and Study of Routing Algorithms and Heu...
 
TransparentInterconnectionsofLotofLinks
TransparentInterconnectionsofLotofLinksTransparentInterconnectionsofLotofLinks
TransparentInterconnectionsofLotofLinks
 
ANALYSIS OF ROUTING PROTOCOLS IN WIRELESS MESH NETWORK
ANALYSIS OF ROUTING PROTOCOLS IN WIRELESS MESH NETWORKANALYSIS OF ROUTING PROTOCOLS IN WIRELESS MESH NETWORK
ANALYSIS OF ROUTING PROTOCOLS IN WIRELESS MESH NETWORK
 
Enhancement of Improved Balanced LEACH for Heterogeneous Wireless Sensor Netw...
Enhancement of Improved Balanced LEACH for Heterogeneous Wireless Sensor Netw...Enhancement of Improved Balanced LEACH for Heterogeneous Wireless Sensor Netw...
Enhancement of Improved Balanced LEACH for Heterogeneous Wireless Sensor Netw...
 
Final Report(Routing_Misbehavior)
Final Report(Routing_Misbehavior)Final Report(Routing_Misbehavior)
Final Report(Routing_Misbehavior)
 
Network layer (Unit 3) part1.pdf
Network  layer (Unit 3) part1.pdfNetwork  layer (Unit 3) part1.pdf
Network layer (Unit 3) part1.pdf
 
Network Layer
Network LayerNetwork Layer
Network Layer
 
H1803064257
H1803064257H1803064257
H1803064257
 
Local Restoration in Metro Ethernet Networks for Multiple Link Failures
Local Restoration in Metro Ethernet Networks for Multiple Link FailuresLocal Restoration in Metro Ethernet Networks for Multiple Link Failures
Local Restoration in Metro Ethernet Networks for Multiple Link Failures
 
An Approach to Detect Packets Using Packet Sniffing
An Approach to Detect Packets Using Packet SniffingAn Approach to Detect Packets Using Packet Sniffing
An Approach to Detect Packets Using Packet Sniffing
 
Data Communication and Networking(DCACN)
Data Communication and Networking(DCACN)Data Communication and Networking(DCACN)
Data Communication and Networking(DCACN)
 
IMPLEMENTATION OF NETWORK DESIGN FOR UNIVERSITIES WITH IOT
IMPLEMENTATION OF NETWORK DESIGN FOR UNIVERSITIES WITH IOTIMPLEMENTATION OF NETWORK DESIGN FOR UNIVERSITIES WITH IOT
IMPLEMENTATION OF NETWORK DESIGN FOR UNIVERSITIES WITH IOT
 

Recently uploaded

Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 

Recently uploaded (20)

Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 

Implementation of Spanning Tree Protocol using ns-3

  • 1. Implementation of Spanning Tree Protocol using ns-3 Naishil Shah (nanshah@ucsc.edu)1 and Sneha Das (sndas@ucsc.edu)2 Abstract— The goal of this project is to implement the Spanning Tree Protocol (STP) introduced by Radia Perlman. We use a discrete event network simulator NS3 primarily used in research and teaching for the implementation of this project. I. INTRODUCTION A routing loop is a serious network problem which happens when a data packet is continually routed through the same routers over and over. The data packets continue to be routed within the network in an endless circle. A routing loop can have a catastrophic impact on a network, and in some cases, completely disabling the network.A major portion of the precious bandwidth which is available for normal user traffic of the affected routers will be consumed by looping IP datagram packets. Also a major portion of the processing power of the affected routers is used to process the looping IP datagram packets. Routing Loops can happen in large internetworks when a second topology change emerges before the network is able to converge on the first change. Convergence is the term used to describe the condition when all routers in an internetwork have agreed on a common topology. Link state protocols tend to converge very quickly, while distance vector protocols tend to converge slowly.Different methods are used to avoid routing loops such as using a maximum hop count, split horizon, route poisoning and hold-down timers. Layer 2 switching loops can cause serious problem to network communication. One of the basic functions of a network switch is to eliminate Layer 2 switching loops. The Spanning Tree Protocol (STP) is a network protocol that builds a logical loop-free topology for Ethernet networks. The basic function of STP is to prevent bridge loops and the broadcast radiation that results from them. Spanning tree also allows a network design to include redundant links to provide automatic backup paths if an active link fails. This is done without the danger of bridge loops, or the need for manual enabling or disabling of these backup links.STP creates a spanning tree within a network of connected layer-2 bridges, and disables those links that are not part of the spanning tree, leaving a single active path between any two network nodes. Loop prevention in a Layer 2 Ethernet is handled dif- ferently than it is in Layer 3. A Layer 3 IP header has a time-to-live (TTL) field that is set by the original host and is decremented at each router, allowing the router to prevent looped datagrams by discarding packets that reach TTL=0. This feature is not available for Layer 2 Ethernet frames.Therefore, after a Layer 2 frame starts to loop in the network, it continues looping forever until one of these events occurs: • A link is broken. • One of the bridges is turned off. • A bridge is rebooted. Bridging tables that are not configured with STP can be corrupted by the looping created by a broadcast storm. II. SPANNING TREE PROTOCOL OPERATION The Spanning tree protocol calculates the best path through a switched network that contains redundant paths. It allows bridges to communicate with each other for the purpose of discovering physical loops in the network. When physical loops are found, the protocol specifies an algorithm that bridges can use to create a loop-free logical topology. Blocking loops prevents broadcast storms in the network. The STP algorithm computes a tree structure of loop-free leaves and branches that spans the entire Layer 2 network. A. Rules to compute spanning tree The spanning tree that the bridges compute using the Span- ning Tree Protocol can be determined using the following rules. • Select a root bridge: The root bridge of the spanning tree is the bridge with the smallest (lowest) bridge ID. Each bridge has a configurable priority number and a MAC address; the bridge ID is the concatenation of the bridge priority and the MAC address.The switch with the lowest priority of all the switches will be the root. If there is a tie, then the switch with the lowest priority and lowest MAC address will be the root. • Determine the least cost paths to the root bridge: The computed spanning tree has the property that messages from any connected device to the root bridge traverse a least cost path. The cost of traversing a path is the sum of the costs of the segments on the path. • Disable all other root paths: Any active port that is not a root port or a designated port is a blocked port (BP). In the case of ties, they can be broken by applying one of the following methods: • By breaking ties for root ports: When multiple paths from a bridge are least-cost paths, the chosen path uses the neighbor bridge with the lower bridge ID. • When the root bridge has more than one port on a single LAN segment, the bridge ID is effectively tied, as are
  • 2. all root path costs. The designated port then becomes the port on that LAN segment with the lowest port ID. III. NS-3 NETWORK SIMULATOR In communication and computer network research, network simulation is a technique where a program models the behavior of a network either by calculating the interaction between the different network entities (hosts/packets etc.) using mathematical formulas, or actually capturing and playing back observations from a production network. The behavior of the network and the various applications and services it supports can then be observed in a test lab; various attributes of the environment can also be modified in a controlled manner to assess how the network would behave under different conditions. Among the many network simulators present today, we use ns-3 as the network simulator for this project. It is a discrete- event network simulator, targeted primarily for research and educational use. It helps develop a preferred, open simulation environment for networking research which is aligned with the simulation needs of modern networking research. The ns-3 simulation core supports research on both IP and non- IP based networks. A large majority of its users however focuses on wireless/IP simulations which involve models for Wi-Fi, WiMAX, or LTE for layers 1 and 2 and a variety of static or dynamic routing protocols such as OLSR and AODV for IP-based applications. IV. METHODOLOGY ADOPTED A. Approach A We tried an approach to exchange HELLO messages between all the nodes to implement the spanning tree protocol. The idea was to start by electing the node with the lowest MAC id as the root node. This root node would check its immediate neighbors by exchanging HELLO messages with them. Each node in the topology has an array of its previously unvisited neighbors. For every node, it lists neighbors that are in lower priority. As we traverse through higher MAC ids, this approach makes sure that previously visited neighbors are not added into the nodes array. For each neighbor added to the nodes array, we assign the respective port to be the root port since it will be the least cost path taken from the root node. In this process, we block the remaining unused ports, thereby removing any loops present in the topology. This distributed mechanism of implementing the protocol was unsuccessful during the course of the project due to two reasons. We could not successfully implement detection of neighboring nodes using HELLO messages. Once this problem was resolved, we could not figure out how to assign root ports and designated ports based on this information. Without this knowledge, we could not proceed with assigning blocked ports and hence removal of loops was a problem. Hence we considered another approach which is discussed in the next section. B. Approach 2 The in built examples of network simulator 3 were used to obtain the desired result. We used the program of matrix-topology.cc given in the tutorials folder of ns3 and modified it to given us the required result. We understood that this file gave an adjacency matrix as an output to any given network topology. We used Prim’s Algorithm on this adjacency matrix to obtain a graphical spanning tree of the network. The final output we obtanined after applying Prim’s Algorithm, was again converted to a topology by the mst.cc file. To demonstrate the changes made before and after the application of the algorithm, we depict the topology using NetAnim. NetAnim is an offline animator based on the Qt toolkit to view the output obtained. It animates the simulation using an XML trace file collected during simulation.As shown in the images that follow, we tested it for various topologies and this approcah worked perfectly well for any given topology. The Prim’s Algorithm’s Pseudo code is explained below. Algorithm 1 Pseudo code 1: ReachSet = {0} You can use any node 2: UnReachSet = {1, 2, ...N − 1} 3: SpanningTree = {} 4: while UnReachSet = empty do Find edge e= (x,y) such that: 5: x ∈ ReachSet 6: y ∈ UnReachSet 7: e(smallestcost) 8: SpanningTree = SpanningTree ∪ {e} Add edge to Spanning tree 9: ReachSet = ReachSet ∪ {y} Add y to visited set 10: UnReachSet = UnReachSet{y} Remove y from unreached set Consider the 6-node topology as shown in 1. We use the following helper classes available in ns-3 as given below. The definition of these classes have been taken from the official documentation of ns-3. • PointToPointHelper : It builds a set of PointToPointNetDevice objects. • NodeContainer : It keeps track of a set of node pointers.Typically ns-3 helpers operate on more than one node at a time. For example a device helper may want to install devices on a large number of similar nodes. The helper Install methods usually take a NodeContainer as a parameter. NodeContainers hold the multiple Ptr<Node> which are used to refer to the nodes. • InternetStackHelper : It aggregates IP/TCP/UDP functionality to existing Nodes. This helper enables pcap and ascii tracing of events in the internet stack associated with a node. • Ipv4AddressHelper : A helper class used to make life easier while doing
  • 3. Fig. 1. Input 6-node topology using NetAnim Fig. 2. Minimum Spanning Tree obtained for a 6-node topology using NetAnim simple IPv4 address assignment in scripts. This class is a very simple IPv4 address generator. You can think of it as a simple local number incrementer. • MobilityHelper : A Helper class used to assign positions and mobility models to nodes. MobilityHelper::Install is the most important method here. • PacketSinkHelper : A helper used to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes. The routing tables for the generated nodes are as shown in the images below in 3 and 4: V. CONCLUSIONS The algorithm presented here maintains a spanning acyclic subset of a general mesh topology. It requires a very Fig. 3. Routing Table for Minimum Spanning Tree obtained for a 6-node topology- Nodes 0-2 Fig. 4. Routing Table for Minimum Spanning Tree obtained for a 6-node topology- Nodes 2-5 small,bounded amount of memory per node,independent of the total number of nodes. This algorithm can prevent one- way links from causing loops.The formed graph is a tree. It has a unique root and each node other than the root has a unique predecessor closer to the root.Also, given a particular physical topology, behavior of the algorithm is completely predictable. ACKNOWLEDGMENT We would like to thank Professor J.J. Garcia Luna Aceves one of the most enjoyable classes we have taken that most practically demonstrated how computer networks work, and for all the math. We also acknowledge our Teaching Assistant Ali Dabirmoghaddam and our classmates for all the sugges-
  • 4. tions and help on working out the minor technical difficulties faced while trying to run the code. REFERENCES [1] Perlman, Radia. "An algorithm for distributed computation of a spanningtree in an extended LAN." ACM SIGCOMM Computer Communication Review. Vol. 15. No. 4. ACM, 1985. [2] Perlman, Radia. "A protocol for distributed computation of a spanning tree in an extended lan." Ninth Data Communications Symposium. 1985. [3] Marchese, Mario, and Maurizio Mongelli. "Simple protocol enhance- ments of Rapid Spanning Tree Protocol over ring topologies." Com- puter Networks 56.4 (2012): 1131-1151. [4] "TechLibrary." Spanning Tree Protocol Operation - Technical Docu- mentation - Support - Juniper Networks. N.p., n.d. Web. Dec. 2016. [5] "Ns-3." Ns3 RSS. N.p., n.d. Web.2016. [6] "Spanning Tree Protocol STP Tutorial." CCNA Training Â˙z Spanning Tree Protocol STP Tutorial. N.p., n.d. Web. Dec. 2016. [7] Perlman, Radia (2000). Interconnections, Second Edition. USA: Addison-Wesley. ISBN 0-201-63448-1. [8] Attacking the Spanning Tree Protocol." Cisco Press. N.p., 4 June 2008. Web. 2 Mar. 2016<http://www.ciscopress.com/articles/article.asp?p=1016582>