|
INET Framework for OMNeT++/OMNEST
|
Implements the Rapid Spanning Tree Protocol.
More...
#include <Rstp.h>
|
| virtual void | initialize (int stage) override |
| |
| virtual void | finish () override |
| |
| virtual void | initInterfacedata (unsigned int portNum) |
| |
| virtual void | start () override |
| |
| virtual void | stop () override |
| |
| virtual void | initPorts () |
| | initialize RSTP dynamic information More...
|
| |
| virtual int | getBestAlternate () |
| | Gets the best alternate port. More...
|
| |
| virtual void | sendBPDUs () |
| | Sends BPDUs through all ports, if they are required. More...
|
| |
| virtual void | sendBPDU (int interfaceId) |
| | Sends BPDU through a port. More...
|
| |
| virtual void | handleMessageWhenUp (cMessage *msg) override |
| | General processing. More...
|
| |
| virtual void | handleIncomingFrame (Packet *packet) |
| | BPDU processing. More...
|
| |
| virtual void | processBPDU (const Ptr< const BpduCfg > &frame, unsigned int arrivalInterfaceId) |
| |
| virtual bool | processBetterSource (const Ptr< const BpduCfg > &frame, unsigned int arrivalInterfaceId) |
| |
| virtual bool | processSameSource (const Ptr< const BpduCfg > &frame, unsigned int arrivalInterfaceId) |
| |
| virtual void | printState () |
| | Prints current data base info. More...
|
| |
| virtual void | updateInterfacedata (const Ptr< const BpduCfg > &frame, unsigned int interfaceId) |
| | Update Interfacedata with the content of the BPDU frame. More...
|
| |
| virtual CompareResult | contestInterfacedata (const Ptr< const BpduCfg > &msg, unsigned int interfaceId) |
| | Compares the BPDU frame with the BPDU this module would send through that port. More...
|
| |
| virtual CompareResult | contestInterfacedata (unsigned int interfaceId) |
| | Compares the port's best BPDU with the BPDU this module would send through that port. More...
|
| |
| virtual CompareResult | compareInterfacedata (unsigned int interfaceId, const Ptr< const BpduCfg > &msg, int linkCost) |
| | Compares a port's best BPDU with a BPDU frame. More...
|
| |
| virtual CompareResult | compareRSTPData (int rootPriority1, int rootPriority2, MacAddress rootAddress1, MacAddress rootAddress2, int rootPathCost1, int rootPathCost2, int bridgePriority1, int bridgePriority2, MacAddress bridgeAddress1, MacAddress bridgeAddress2, int portPriority1, int portPriority2, int portNum1, int portNum2) |
| | Compares two RSTP data. More...
|
| |
| virtual void | sendTCNtoRoot () |
| | If root TCWhile has not expired, sends a BPDU to the Root with TCFlag=true. More...
|
| |
| virtual void | handleHelloTime (cMessage *) |
| | HelloTime event handling. More...
|
| |
| virtual void | handleUpgrade (cMessage *) |
| | Upgrade event handling. More...
|
| |
| virtual void | checkTC (const Ptr< const BpduCfg > &frame, int arrivalInterfaceId) |
| | Checks the frame TC flag. More...
|
| |
| virtual void | handleBackup (const Ptr< const BpduCfg > &frame, unsigned int arrivalInterfaceId) |
| | Handles the switch to backup in one of the ports. More...
|
| |
| virtual void | scheduleNextUpgrade () |
| | schedule next upgrade self-message More...
|
| |
| virtual void | flushOtherPorts (unsigned int interfaceId) |
| | flush all port expect one More...
|
| |
| virtual void | colorLink (NetworkInterface *ie, bool forwarding) const |
| | Adds effects to be represented by Tkenv. More...
|
| |
| virtual void | refreshDisplay () const override |
| | Adds effects to be represented by Tkenv. More...
|
| |
| virtual int | getRootInterfaceId () const |
| | Obtains the root interface ID. More...
|
| |
| const Ieee8021dInterfaceData * | getPortInterfaceData (unsigned int interfaceId) const |
| | Gets Ieee8021dInterfaceData for interface ID. More...
|
| |
| Ieee8021dInterfaceData * | getPortInterfaceDataForUpdate (unsigned int interfaceId) |
| |
| NetworkInterface * | getPortNetworkInterface (unsigned int interfaceId) const |
| | Gets NetworkInterface for interface ID. More...
|
| |
| virtual NetworkInterface * | chooseInterface () |
| |
| virtual int | numInitStages () const override |
| |
| virtual void | refreshDisplay () const override |
| |
| virtual void | handleMessage (cMessage *msg) override |
| |
| virtual void | handleMessageWhenDown (cMessage *msg) |
| |
| virtual bool | handleOperationStage (LifecycleOperation *operation, IDoneCallback *doneCallback) override |
| | Perform one stage of a lifecycle operation. More...
|
| |
| virtual State | getInitialOperationalState () const |
| | Returns initial operational state: OPERATING or NOT_OPERATING. More...
|
| |
| virtual void | handleActiveOperationTimeout (cMessage *message) |
| |
| virtual bool | isUp () const |
| | utility functions More...
|
| |
| virtual bool | isDown () const |
| |
| virtual void | setOperationalState (State newState) |
| |
| virtual void | scheduleOperationTimeout (simtime_t timeout) |
| |
| virtual void | setupActiveOperation (LifecycleOperation *operation, IDoneCallback *doneCallback, State) |
| |
| virtual void | delayActiveOperationFinish (simtime_t timeout) |
| |
| virtual void | startActiveOperationExtraTime (simtime_t delay=SIMTIME_ZERO) |
| |
| virtual void | startActiveOperationExtraTimeOrFinish (simtime_t extraTime) |
| |
| virtual void | finishActiveOperation () |
| |
Implements the Rapid Spanning Tree Protocol.
See the NED file for details.
◆ CompareResult
| Enumerator |
|---|
| WORSE_PORT | |
| WORSE_SRC | |
| WORSE_RPC | |
| WORSE_ROOT | |
| SIMILAR | |
| BETTER_ROOT | |
| BETTER_RPC | |
| BETTER_SRC | |
| BETTER_PORT | |
◆ SelfKinds
| Enumerator |
|---|
| SELF_HELLOTIME | |
| SELF_UPGRADE | |
◆ Rstp()
◆ ~Rstp()
◆ checkTC()
| void inet::Rstp::checkTC |
( |
const Ptr< const BpduCfg > & |
frame, |
|
|
int |
arrivalInterfaceId |
|
) |
| |
|
protectedvirtual |
Checks the frame TC flag.
Sets TCWhile if the port was forwarding and the flag is true.
213 EV_DETAIL <<
"TCN received" << endl;
215 for (
unsigned int i = 0; i <
numPorts; i++) {
216 int interfaceId =
ifTable->getInterface(i)->getInterfaceId();
217 if (interfaceId != arrivalInterfaceId) {
221 macTable->removeForwardingInterface(interfaceId);
Referenced by handleIncomingFrame().
◆ compareInterfacedata()
Compares a port's best BPDU with a BPDU frame.
- Returns
- (<0 if vector better than frame)
782 ifd->getRootAddress(), msg->getRootAddress(),
783 ifd->getRootPathCost(), msg->getRootPathCost() + linkCost,
784 ifd->getBridgePriority(), msg->getBridgePriority(),
785 ifd->getBridgeAddress(), msg->getBridgeAddress(),
786 ifd->getPortPriority(), msg->getPortPriority(),
787 ifd->getPortNum(), msg->getPortNum());
Referenced by processBetterSource(), processBPDU(), and processSameSource().
◆ compareRSTPData()
| Rstp::CompareResult inet::Rstp::compareRSTPData |
( |
int |
rootPriority1, |
|
|
int |
rootPriority2, |
|
|
MacAddress |
rootAddress1, |
|
|
MacAddress |
rootAddress2, |
|
|
int |
rootPathCost1, |
|
|
int |
rootPathCost2, |
|
|
int |
bridgePriority1, |
|
|
int |
bridgePriority2, |
|
|
MacAddress |
bridgeAddress1, |
|
|
MacAddress |
bridgeAddress2, |
|
|
int |
portPriority1, |
|
|
int |
portPriority2, |
|
|
int |
portNum1, |
|
|
int |
portNum2 |
|
) |
| |
|
protectedvirtual |
Compares two RSTP data.
- Returns
- (<0 if vector better than frame)
798 if (rootPriority1 != rootPriority2)
801 int c = rootAddress1.compareTo(rootAddress2);
805 if (rootPathCost1 != rootPathCost2)
808 if (bridgePriority1 != bridgePriority2)
811 c = bridgeAddress1.compareTo(bridgeAddress2);
815 if (portPriority1 != portPriority2)
818 if (portNum1 != portNum2)
Referenced by compareInterfacedata(), contestInterfacedata(), and getBestAlternate().
◆ contestInterfacedata() [1/2]
Compares the BPDU frame with the BPDU this module would send through that port.
- Returns
- (<0 if the root BPDU is better than BPDU)
768 return compareRSTPData(rootPort->getRootPriority(), msg->getRootPriority(),
769 rootPort->getRootAddress(), msg->getRootAddress(),
770 rootPort->getRootPathCost(), msg->getRootPathCost(),
773 ifd->getPortPriority(), msg->getPortPriority(),
774 interfaceId, msg->getPortNum());
Referenced by processBetterSource(), and processSameSource().
◆ contestInterfacedata() [2/2]
Compares the port's best BPDU with the BPDU this module would send through that port.
- Returns
- (<0 if the root BPDU is better than port's best BPDU)
753 return compareRSTPData(rootPort->getRootPriority(), ifd->getRootPriority(),
754 rootPort->getRootAddress(), ifd->getRootAddress(),
755 rootPort->getRootPathCost() + ifd->getLinkCost(), ifd->getRootPathCost(),
758 ifd->getPortPriority(), ifd->getPortPriority(),
759 portNum, ifd->getPortNum());
◆ finish()
| virtual void inet::Rstp::finish |
( |
| ) |
|
|
inlineoverrideprotectedvirtual |
◆ flushOtherPorts()
| void inet::Rstp::flushOtherPorts |
( |
unsigned int |
interfaceId | ) |
|
|
protectedvirtual |
◆ getBestAlternate()
| int inet::Rstp::getBestAlternate |
( |
| ) |
|
|
protectedvirtual |
Gets the best alternate port.
- Returns
- Best alternate gate index
827 for (
unsigned int j = 0; j <
numPorts; j++) {
828 int interfaceId =
ifTable->getInterface(j)->getInterfaceId();
832 candidate = interfaceId;
835 if (
compareRSTPData(jPort->getRootPriority(), candidatePort->getRootPriority(),
836 jPort->getRootAddress(), candidatePort->getRootAddress(),
837 jPort->getRootPathCost(), candidatePort->getRootPathCost(),
838 jPort->getBridgePriority(), candidatePort->getBridgePriority(),
839 jPort->getBridgeAddress(), candidatePort->getBridgeAddress(),
840 jPort->getPortPriority(), candidatePort->getPortPriority(),
841 jPort->getPortNum(), candidatePort->getPortNum()) < 0)
844 candidate = interfaceId;
Referenced by handleHelloTime(), and processSameSource().
◆ handleBackup()
| void inet::Rstp::handleBackup |
( |
const Ptr< const BpduCfg > & |
frame, |
|
|
unsigned int |
arrivalInterfaceId |
|
) |
| |
|
protectedvirtual |
Handles the switch to backup in one of the ports.
230 EV_DETAIL <<
"More than one port in the same LAN" << endl;
232 if ((frame->getPortPriority() < port->getPortPriority())
233 || ((frame->getPortPriority() == port->getPortPriority()) && (frame->getPortNum() < arrivalInterfaceId)))
236 macTable->removeForwardingInterface(arrivalInterfaceId);
239 port->setLostBPDU(0);
240 EV_DETAIL <<
"Setting port " << arrivalInterfaceId <<
"to backup" << endl;
242 else if (frame->getPortPriority() > port->getPortPriority()
243 || (frame->getPortPriority() == port->getPortPriority() && frame->getPortNum() > arrivalInterfaceId))
247 macTable->removeForwardingInterface(frame->getPortNum());
250 port2->setLostBPDU(0);
251 EV_DETAIL <<
"Setting port " << frame->getPortNum() <<
"to backup" << endl;
257 EV_DETAIL <<
"Unavoidable loop. Received its own message at the same port. Setting port " << frame->getPortNum() <<
" to disabled." << endl;
259 macTable->removeForwardingInterface(frame->getPortNum());
Referenced by handleIncomingFrame().
◆ handleHelloTime()
| void inet::Rstp::handleHelloTime |
( |
cMessage * |
msg | ) |
|
|
protectedvirtual |
HelloTime event handling.
144 EV_DETAIL <<
"Hello time." << endl;
145 for (
unsigned int i = 0; i <
numPorts; i++) {
148 int interfaceId =
ifTable->getInterface(i)->getInterfaceId();
155 iPort->setLostBPDU(iPort->getLostBPDU() + 1);
156 if (iPort->getLostBPDU() > 3) {
157 EV_DETAIL <<
"3 HelloTime without the best BPDU" << endl;
162 if (candidate != -1) {
164 EV_DETAIL <<
"It was the root port. Alternate gate has been found. Setting port " << candidate <<
" to root. Setting current root port (port" << interfaceId <<
") to designated." << endl;
177 candidatePort->setLostBPDU(0);
179 macTable->replaceForwardingInterface(interfaceId, candidate);
183 EV_DETAIL <<
"It was the root port. Alternate not found. Starts from beginning." << endl;
191 EV_DETAIL <<
"Setting port " << interfaceId <<
" to designated." << endl;
200 iPort->setLostBPDU(0);
Referenced by handleMessageWhenUp().
◆ handleIncomingFrame()
| void inet::Rstp::handleIncomingFrame |
( |
Packet * |
packet | ) |
|
|
protectedvirtual |
BPDU processing.
Updates port information. Handles port role changes.
267 const auto& frame = packet->peekAtFront<BpduCfg>();
270 int arrivalInterfaceId = packet->getTag<InterfaceInd>()->getInterfaceId();
271 MacAddress src = packet->getTag<MacAddressInd>()->getSrcAddress();
272 EV_INFO <<
"BPDU received at port " << arrivalInterfaceId <<
"." << endl;
273 if (frame->getMessageAge() <
maxAge) {
275 checkTC(frame, arrivalInterfaceId);
283 EV_DETAIL <<
"Expired BPDU" << endl;
Referenced by handleMessageWhenUp().
◆ handleMessageWhenUp()
| void inet::Rstp::handleMessageWhenUp |
( |
cMessage * |
msg | ) |
|
|
overrideprotectedvirtual |
◆ handleUpgrade()
| void inet::Rstp::handleUpgrade |
( |
cMessage * |
msg | ) |
|
|
protectedvirtual |
Upgrade event handling.
115 for (
unsigned int i = 0; i <
numPorts; i++) {
116 int interfaceId =
ifTable->getInterface(i)->getInterfaceId();
120 EV_DETAIL <<
"MigrateTime. Setting port " << interfaceId <<
"to designated." << endl;
127 EV_INFO <<
"UpgradeTime. Setting port " << interfaceId <<
" state to learning." << endl;
132 EV_INFO <<
"UpgradeTime. Setting port " << interfaceId <<
" state to forwarding." << endl;
Referenced by handleMessageWhenUp().
◆ initialize()
| void inet::Rstp::initialize |
( |
int |
stage | ) |
|
|
overrideprotectedvirtual |
Reimplemented from inet::StpBase.
46 for (
int i = 0; i <
ifTable->getNumInterfaces(); i++) {
48 if (!
ie->isLoopback() &&
ie->isWired() ) {
◆ initInterfacedata()
| void inet::Rstp::initInterfacedata |
( |
unsigned int |
portNum | ) |
|
|
protectedvirtual |
◆ initPorts()
| void inet::Rstp::initPorts |
( |
| ) |
|
|
protectedvirtual |
◆ numInitStages()
| virtual int inet::Rstp::numInitStages |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ printState()
| void inet::Rstp::printState |
( |
| ) |
|
|
protectedvirtual |
Prints current data base info.
669 EV_DETAIL <<
"Switch " <<
findContainingNode(
this)->getFullName() <<
" state:" << endl;
673 if (rootIndex >= 0) {
675 EV_DETAIL <<
" Root Priority: " << rootPort->getRootPriority() << endl;
676 EV_DETAIL <<
" Root Address: " << rootPort->getRootAddress().str() << endl;
677 EV_DETAIL <<
" Cost: " << rootPort->getRootPathCost() << endl;
678 EV_DETAIL <<
" Age: " << rootPort->getAge() << endl;
679 EV_DETAIL <<
" Bridge Priority: " << rootPort->getBridgePriority() << endl;
680 EV_DETAIL <<
" Bridge Address: " << rootPort->getBridgeAddress().str() << endl;
681 EV_DETAIL <<
" Src TxGate Priority: " << rootPort->getPortPriority() << endl;
682 EV_DETAIL <<
" Src TxGate: " << rootPort->getPortNum() << endl;
684 EV_DETAIL <<
"Port State/Role:" << endl;
685 for (
unsigned int i = 0; i <
numPorts; i++) {
686 int interfaceId =
ifTable->getInterface(i)->getInterfaceId();
688 EV_DETAIL <<
" " << i <<
": " << iPort->getStateName() <<
"/" << iPort->getRoleName() << (iPort->isEdge() ?
" (Client)" :
"") << endl;
690 EV_DETAIL <<
"Per-port best sources, Root/Src:" << endl;
691 for (
unsigned int i = 0; i <
numPorts; i++) {
692 int interfaceId =
ifTable->getInterface(i)->getInterfaceId();
694 EV_DETAIL <<
" " << interfaceId <<
": " << iPort->getRootAddress().str() <<
"/" << iPort->getBridgeAddress().str() << endl;
◆ processBetterSource()
| bool inet::Rstp::processBetterSource |
( |
const Ptr< const BpduCfg > & |
frame, |
|
|
unsigned int |
arrivalInterfaceId |
|
) |
| |
|
protectedvirtual |
310 EV_DETAIL <<
"Better BPDU received than the current best for this port." << endl;
316 EV_DETAIL <<
"There was no root. Setting the arrival port to root." << endl;
320 arrivalPort->setLostBPDU(0);
332 EV_DETAIL <<
"Double link to the same port of the root source." << endl;
333 if (rootPort->getPortPriority() < arrivalPort->getPortPriority()
334 || (rootPort->getPortPriority() == arrivalPort->getPortPriority() && (
unsigned int)r < arrivalInterfaceId))
337 EV_DETAIL <<
"The current root has better local port. Setting the arrival port to alternate." << endl;
338 macTable->removeForwardingInterface(arrivalInterfaceId);
341 arrivalPort->setLostBPDU(0);
347 macTable->removeForwardingInterface(r);
348 EV_DETAIL <<
"This has better local port. Setting the arrival port to root. Setting current root port (port " << r <<
") to alternate." << endl;
353 arrivalPort->setLostBPDU(0);
354 macTable->replaceForwardingInterface(r, arrivalInterfaceId);
360 EV_DETAIL <<
"Better root received than the current root. Setting the arrival port to root." << endl;
361 for (
unsigned int i = 0; i <
numPorts; i++) {
362 int interfaceId =
ifTable->getInterface(i)->getInterfaceId();
364 if (!iPort->isEdge()) {
367 macTable->removeForwardingInterface(interfaceId);
368 if ((
unsigned int)interfaceId != arrivalInterfaceId) {
379 arrivalPort->setLostBPDU(0);
387 EV_DETAIL <<
"Better route to the current root. Setting the arrival port to root." << endl;
392 arrivalPort->setLostBPDU(0);
394 macTable->replaceForwardingInterface(r, arrivalInterfaceId);
397 EV_DETAIL <<
"Setting current root port (port " << r <<
") to alternate." << endl;
402 macTable->removeForwardingInterface(r);
405 EV_DETAIL <<
"Setting current root port (port " << r <<
") to designated." << endl;
414 EV_DETAIL <<
"Worse BPDU received than the current root. Sending BPDU to show him a better root as soon as possible." << endl;
423 EV_DETAIL <<
"Worse route to the current root. Setting the arrival port to designated." << endl;
431 EV_DETAIL <<
"Worse route to the current root. Setting the arrival port to alternate." << endl;
433 macTable->removeForwardingInterface(arrivalInterfaceId);
436 arrivalPort->setLostBPDU(0);
Referenced by processBPDU().
◆ processBPDU()
| void inet::Rstp::processBPDU |
( |
const Ptr< const BpduCfg > & |
frame, |
|
|
unsigned int |
arrivalInterfaceId |
|
) |
| |
|
protectedvirtual |
299 else if (frame->getBridgeAddress().compareTo(arrivalPort->getBridgeAddress()) == 0
Referenced by handleIncomingFrame().
◆ processSameSource()
| bool inet::Rstp::processSameSource |
( |
const Ptr< const BpduCfg > & |
frame, |
|
|
unsigned int |
arrivalInterfaceId |
|
) |
| |
|
protectedvirtual |
446 EV_DETAIL <<
"BPDU received from the same source than the current best for this port" << endl;
452 arrivalPort->setLostBPDU(0);
456 EV_DETAIL <<
"Worse root received than the current best for this port." << endl;
459 if (alternative >= 0) {
460 EV_DETAIL <<
"This port was the root, but there is a better alternative. Setting the arrival port to designated and port " << alternative <<
"to root." << endl;
466 macTable->replaceForwardingInterface(arrivalInterfaceId, alternative);
474 EV_DETAIL <<
"This port was the root and there no alternative. Initialize all ports" << endl;
478 for (
unsigned int j = 0; j <
numPorts; j++) {
479 int interfaceId =
ifTable->getInterface(j)->getInterfaceId();
480 macTable->removeForwardingInterface(interfaceId);
484 EV_DETAIL <<
"This switch is not better, keep arrival port as a ROOT" << endl;
494 EV_DETAIL <<
"This port was an alternate, setting to designated" << endl;
507 EV_DETAIL <<
"Worse route to the current root than the current best for this port." << endl;
509 arrivalPort->setLostBPDU(0);
511 if (alternative >= 0) {
522 EV_DETAIL <<
"This port was the root, but there is a better alternative. Setting the arrival port to designated and port " << alternative <<
"to root." << endl;
529 EV_DETAIL <<
"This port was the root, but there is a better alternative. Setting the arrival port to alternate and port " << alternative <<
"to root." << endl;
534 macTable->replaceForwardingInterface(arrivalInterfaceId, alternative);
546 EV_DETAIL <<
"This port was an alternate, setting to designated" << endl;
554 arrivalPort->setLostBPDU(0);
Referenced by processBPDU().
◆ receiveSignal()
| void inet::Rstp::receiveSignal |
( |
cComponent * |
source, |
|
|
simsignal_t |
signalID, |
|
|
cObject * |
obj, |
|
|
cObject * |
details |
|
) |
| |
|
overridevirtual |
Reimplemented from inet::StpBase.
866 Enter_Method(
"%s", cComponent::getSignalName(signalID));
869 NetworkInterface *changedIE = check_and_cast<const NetworkInterfaceChangeDetails *>(obj)->getNetworkInterface();
870 for (
unsigned int i = 0; i <
numPorts; i++) {
871 int interfaceId =
ifTable->getInterface(i)->getInterfaceId();
873 if (gateIfEntry == changedIE) {
874 if (gateIfEntry->hasCarrier()) {
◆ scheduleNextUpgrade()
| void inet::Rstp::scheduleNextUpgrade |
( |
| ) |
|
|
protectedvirtual |
schedule next upgrade self-message
58 const Ieee8021dInterfaceData *nextInterfaceData =
nullptr;
59 for (
unsigned int i = 0; i <
numPorts; i++) {
60 int interfaceId =
ifTable->getInterface(i)->getInterfaceId();
64 if (nextInterfaceData ==
nullptr)
65 nextInterfaceData = iPort;
66 else if (iPort->getNextUpgrade() < nextInterfaceData->getNextUpgrade())
67 nextInterfaceData = iPort;
71 if (nextInterfaceData ==
nullptr)
72 nextInterfaceData = iPort;
73 else if (iPort->getNextUpgrade() < nextInterfaceData->getNextUpgrade())
74 nextInterfaceData = iPort;
77 if (nextInterfaceData ==
nullptr)
78 nextInterfaceData = iPort;
79 else if (iPort->getNextUpgrade() < nextInterfaceData->getNextUpgrade())
80 nextInterfaceData = iPort;
85 if (nextInterfaceData !=
nullptr)
86 scheduleAt(nextInterfaceData->getNextUpgrade(),
upgradeTimer);
Referenced by handleHelloTime(), handleUpgrade(), initPorts(), processBetterSource(), processSameSource(), and receiveSignal().
◆ sendBPDU()
| void inet::Rstp::sendBPDU |
( |
int |
interfaceId | ) |
|
|
protectedvirtual |
Sends BPDU through a port.
624 const Ieee8021dInterfaceData *rootPort;
628 Packet *packet =
new Packet(
"BPDU");
629 const auto& frame = makeShared<BpduCfg>();
631 frame->setRootPriority(rootPort->getRootPriority());
632 frame->setRootAddress(rootPort->getRootAddress());
633 frame->setMessageAge(rootPort->getAge());
634 frame->setRootPathCost(rootPort->getRootPathCost());
639 frame->setMessageAge(0);
640 frame->setRootPathCost(0);
643 frame->setTcaFlag(
false);
644 frame->setPortNum(interfaceId);
646 if (simTime() < iport->getTCWhile())
647 frame->setTcFlag(
true);
649 frame->setTcFlag(
false);
654 packet->insertAtBack(frame);
656 auto macAddressReq = packet->addTag<MacAddressReq>();
659 packet->addTag<
InterfaceReq>()->setInterfaceId(interfaceId);
662 send(packet,
"relayOut");
Referenced by processBetterSource(), processSameSource(), and sendBPDUs().
◆ sendBPDUs()
| void inet::Rstp::sendBPDUs |
( |
| ) |
|
|
protectedvirtual |
◆ sendTCNtoRoot()
| void inet::Rstp::sendTCNtoRoot |
( |
| ) |
|
|
protectedvirtual |
If root TCWhile has not expired, sends a BPDU to the Root with TCFlag=true.
567 this->bubble(
"SendTCNtoRoot");
568 EV_DETAIL <<
"SendTCNtoRoot" << endl;
573 if (simTime() < rootPort->getTCWhile()) {
574 Packet *packet =
new Packet(
"BPDU");
575 const auto& frame = makeShared<BpduCfg>();
576 frame->setRootPriority(rootPort->getRootPriority());
577 frame->setRootAddress(rootPort->getRootAddress());
578 frame->setMessageAge(rootPort->getAge());
579 frame->setRootPathCost(rootPort->getRootPathCost());
581 frame->setTcaFlag(
false);
582 frame->setPortNum(r);
584 frame->setTcFlag(
true);
589 packet->insertAtBack(frame);
591 auto macAddressReq = packet->addTag<MacAddressReq>();
598 send(packet,
"relayOut");
Referenced by handleHelloTime(), and processBPDU().
◆ start()
| void inet::Rstp::start |
( |
| ) |
|
|
overrideprotectedvirtual |
◆ stop()
| void inet::Rstp::stop |
( |
| ) |
|
|
overrideprotectedvirtual |
◆ updateInterfacedata()
| void inet::Rstp::updateInterfacedata |
( |
const Ptr< const BpduCfg > & |
frame, |
|
|
unsigned int |
interfaceId |
|
) |
| |
|
protectedvirtual |
Update Interfacedata with the content of the BPDU frame.
736 ifd->setRootPriority(frame->getRootPriority());
737 ifd->setRootAddress(frame->getRootAddress());
738 ifd->setRootPathCost(frame->getRootPathCost() + ifd->getLinkCost());
739 ifd->setAge(frame->getMessageAge() + 1);
740 ifd->setBridgePriority(frame->getBridgePriority());
741 ifd->setBridgeAddress(frame->getBridgeAddress());
742 ifd->setPortPriority(frame->getPortPriority());
743 ifd->setPortNum(frame->getPortNum());
Referenced by processBetterSource(), and processSameSource().
◆ autoEdge
| bool inet::Rstp::autoEdge = false |
|
protected |
◆ helloTimer
| cMessage* inet::Rstp::helloTimer = nullptr |
|
protected |
◆ migrateTime
| simtime_t inet::Rstp::migrateTime |
|
protected |
◆ tcWhileTime
| simtime_t inet::Rstp::tcWhileTime |
|
protected |
◆ upgradeTimer
| cMessage* inet::Rstp::upgradeTimer = nullptr |
|
protected |
The documentation for this class was generated from the following files:
cModule * findContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:31
virtual void processBPDU(const Ptr< const BpduCfg > &frame, unsigned int arrivalInterfaceId)
Definition: Rstp.cc:287
const value< double, compose< units::m, pow< units::s, -1 > > > c(299792458)
virtual void sendBPDUs()
Sends BPDUs through all ports, if they are required.
Definition: Rstp.cc:604
static const Protocol stp
Definition: Protocol.h:111
opp_component_ptr< NetworkInterface > ie
Definition: StpBase.h:39
unsigned int bridgePriority
Definition: StpBase.h:29
virtual void sendBPDU(int interfaceId)
Sends BPDU through a port.
Definition: Rstp.cc:619
Ieee8021dInterfaceData * getPortInterfaceDataForUpdate(unsigned int interfaceId)
Definition: StpBase.cc:140
@ DESIGNATED
Definition: Ieee8021dInterfaceData.h:24
@ ROOT
Definition: Ieee8021dInterfaceData.h:24
virtual void updateInterfacedata(const Ptr< const BpduCfg > &frame, unsigned int interfaceId)
Update Interfacedata with the content of the BPDU frame.
Definition: Rstp.cc:733
virtual void flushOtherPorts(unsigned int interfaceId)
flush all port expect one
Definition: Rstp.cc:852
@ SELF_HELLOTIME
Definition: Rstp.h:29
virtual CompareResult compareInterfacedata(unsigned int interfaceId, const Ptr< const BpduCfg > &msg, int linkCost)
Compares a port's best BPDU with a BPDU frame.
Definition: Rstp.cc:777
removed InterfaceReq
Definition: IUdp-gates.txt:11
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down DispatchProtocolReq
Definition: IUdp-gates.txt:25
cMessage * helloTimer
Definition: Rstp.h:41
@ WORSE_PORT
Definition: Rstp.h:32
@ SELF_UPGRADE
Definition: Rstp.h:29
bool autoEdge
Definition: Rstp.h:39
@ BETTER_PORT
Definition: Rstp.h:33
static const MacAddress STP_MULTICAST_ADDRESS
The spanning tree protocol bridge's multicast address, 01:80:C2:00:00:00.
Definition: MacAddress.h:40
virtual void handleIncomingFrame(Packet *packet)
BPDU processing.
Definition: Rstp.cc:265
@ SIMILAR
Definition: Rstp.h:32
virtual int getBestAlternate()
Gets the best alternate port.
Definition: Rstp.cc:824
simtime_t forwardDelay
Definition: StpBase.h:34
@ DISCARDING
Definition: Ieee8021dInterfaceData.h:26
static const Protocol ieee8022llc
Definition: Protocol.h:88
simtime_t tcWhileTime
Definition: Rstp.h:38
virtual bool processSameSource(const Ptr< const BpduCfg > &frame, unsigned int arrivalInterfaceId)
Definition: Rstp.cc:444
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down PacketProtocolTag
Definition: IUdp-gates.txt:25
@ WORSE_RPC
Definition: Rstp.h:32
virtual void initPorts()
initialize RSTP dynamic information
Definition: Rstp.cc:713
@ WORSE_SRC
Definition: Rstp.h:32
@ BETTER_ROOT
Definition: Rstp.h:33
MacAddress bridgeAddress
Definition: StpBase.h:30
ModuleRefByPar< IInterfaceTable > ifTable
Definition: StpBase.h:38
virtual void scheduleNextUpgrade()
schedule next upgrade self-message
Definition: Rstp.cc:55
@ FORWARDING
Definition: Ieee8021dInterfaceData.h:26
virtual void initInterfacedata(unsigned int portNum)
Definition: Rstp.cc:699
simtime_t helloTime
Definition: StpBase.h:33
simsignal_t interfaceStateChangedSignal
Definition: Simsignals.cc:32
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
virtual CompareResult contestInterfacedata(const Ptr< const BpduCfg > &msg, unsigned int interfaceId)
Compares the BPDU frame with the BPDU this module would send through that port.
Definition: Rstp.cc:762
@ DISABLED
Definition: Ieee8021dInterfaceData.h:24
@ WORSE_ROOT
Definition: Rstp.h:32
const Ieee8021dInterfaceData * getPortInterfaceData(unsigned int interfaceId) const
Gets Ieee8021dInterfaceData for interface ID.
Definition: StpBase.cc:135
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
virtual int getRootInterfaceId() const
Obtains the root interface ID.
Definition: StpBase.cc:154
virtual void start()
Definition: StpBase.cc:48
@ NOTASSIGNED
Definition: Ieee8021dInterfaceData.h:24
NetworkInterface * getPortNetworkInterface(unsigned int interfaceId) const
Gets NetworkInterface for interface ID.
Definition: StpBase.cc:145
virtual void initialize(int stage) override
Definition: StpBase.cc:25
@ BACKUP
Definition: Ieee8021dInterfaceData.h:24
virtual bool processBetterSource(const Ptr< const BpduCfg > &frame, unsigned int arrivalInterfaceId)
Definition: Rstp.cc:308
virtual void checkTC(const Ptr< const BpduCfg > &frame, int arrivalInterfaceId)
Checks the frame TC flag.
Definition: Rstp.cc:209
@ ALTERNATE
Definition: Ieee8021dInterfaceData.h:24
simtime_t maxAge
Definition: StpBase.h:32
#define Enter_Method(...)
Definition: SelfDoc.h:71
virtual CompareResult compareRSTPData(int rootPriority1, int rootPriority2, MacAddress rootAddress1, MacAddress rootAddress2, int rootPathCost1, int rootPathCost2, int bridgePriority1, int bridgePriority2, MacAddress bridgeAddress1, MacAddress bridgeAddress2, int portPriority1, int portPriority2, int portNum1, int portNum2)
Compares two RSTP data.
Definition: Rstp.cc:790
@ BETTER_RPC
Definition: Rstp.h:33
simtime_t migrateTime
Definition: Rstp.h:37
virtual void handleUpgrade(cMessage *)
Upgrade event handling.
Definition: Rstp.cc:113
ModuleRefByPar< IMacForwardingTable > macTable
Definition: StpBase.h:37
unsigned int numPorts
Definition: StpBase.h:27
void registerProtocol(const Protocol &protocol, cGate *gate, ServicePrimitive servicePrimitive)
Registers a protocol primitive (PDU processing) at the given gate.
Definition: IProtocolRegistrationListener.cc:83
virtual void sendTCNtoRoot()
If root TCWhile has not expired, sends a BPDU to the Root with TCFlag=true.
Definition: Rstp.cc:564
cMessage * upgradeTimer
Definition: Rstp.h:42
@ BETTER_SRC
Definition: Rstp.h:33
virtual void handleHelloTime(cMessage *)
HelloTime event handling.
Definition: Rstp.cc:142
INET_API InitStage INITSTAGE_LINK_LAYER
Initialization of link-layer protocols.
@ LEARNING
Definition: Ieee8021dInterfaceData.h:26
virtual void stop()
Definition: StpBase.cc:58
virtual void handleBackup(const Ptr< const BpduCfg > &frame, unsigned int arrivalInterfaceId)
Handles the switch to backup in one of the ports.
Definition: Rstp.cc:228