INET Framework for OMNeT++/OMNEST
inet::RsvpClassifier Class Reference

TODO documentation. More...

#include <RsvpClassifier.h>

Inheritance diagram for inet::RsvpClassifier:
inet::IScriptable inet::IRsvpClassifier inet::IIngressClassifier

Classes

struct  FecEntry
 

Public Member Functions

 RsvpClassifier ()
 
- Public Member Functions inherited from inet::IScriptable
virtual ~IScriptable ()
 
- Public Member Functions inherited from inet::IRsvpClassifier
virtual ~IRsvpClassifier ()
 
- Public Member Functions inherited from inet::IIngressClassifier
virtual ~IIngressClassifier ()
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual int numInitStages () const override
 
virtual void handleMessage (cMessage *msg) override
 
virtual void processCommand (const cXMLElement &node) override
 Called by ScenarioManager whenever a script command needs to be carried out by the module. More...
 
virtual bool lookupLabel (Packet *ipdatagram, LabelOpVector &outLabel, std::string &outInterface, int &color) override
 The packet argument is an input parameter, the rest (outLabel, outInterface, color) are output parameters only. More...
 
virtual void bind (const SessionObj &session, const SenderTemplateObj &sender, int inLabel) override
 
virtual void readTableFromXML (const cXMLElement *fectable)
 
virtual void readItemFromXML (const cXMLElement *fec)
 
std::vector< FecEntry >::iterator findFEC (int fecid)
 

Protected Attributes

Ipv4Address routerId
 
int maxLabel = 0
 
std::vector< FecEntrybindings
 
ModuleRefByPar< LibTablelt
 
ModuleRefByPar< RsvpTersvp
 

Detailed Description

TODO documentation.

Constructor & Destructor Documentation

◆ RsvpClassifier()

inet::RsvpClassifier::RsvpClassifier ( )
inline
53 {}

Member Function Documentation

◆ bind()

void inet::RsvpClassifier::bind ( const SessionObj session,
const SenderTemplateObj sender,
int  inLabel 
)
overrideprotectedvirtual

Implements inet::IRsvpClassifier.

87 {
88  for (auto& elem : bindings) {
89  if (elem.session != session)
90  continue;
91 
92  if (elem.sender != sender)
93  continue;
94 
95  elem.inLabel = inLabel;
96  }
97 }

◆ findFEC()

std::vector< RsvpClassifier::FecEntry >::iterator inet::RsvpClassifier::findFEC ( int  fecid)
protected
195 {
196  auto it = bindings.begin();
197  for (; it != bindings.end(); it++) {
198  if (it->id == fecid)
199  break;
200  }
201  return it;
202 }

◆ handleMessage()

void inet::RsvpClassifier::handleMessage ( cMessage *  msg)
overrideprotectedvirtual
44 {
45  ASSERT(false);
46 }

◆ initialize()

void inet::RsvpClassifier::initialize ( int  stage)
overrideprotectedvirtual
24 {
25  cSimpleModule::initialize(stage);
26 
27  if (stage == INITSTAGE_LOCAL) {
28  maxLabel = 0;
29  WATCH_VECTOR(bindings);
30  }
31  // TODO INITSTAGE
32  else if (stage == INITSTAGE_ROUTING_PROTOCOLS) {
33  IIpv4RoutingTable *rt = getModuleFromPar<IIpv4RoutingTable>(par("routingTableModule"), this);
34  routerId = rt->getRouterId();
35 
36  lt.reference(this, "libTableModule", true);
37  rsvp.reference(this, "rsvpModule", true);
38 
39  readTableFromXML(par("config"));
40  }
41 }

◆ lookupLabel()

bool inet::RsvpClassifier::lookupLabel ( Packet packet,
LabelOpVector outLabel,
std::string &  outInterface,
int &  color 
)
overrideprotectedvirtual

The packet argument is an input parameter, the rest (outLabel, outInterface, color) are output parameters only.

In subclasses, this function should be implemented to determine the forwarding equivalence class for the Ipv4 datagram passed, and map it to an outLabel and outInterface.

The color parameter (which can be set to an arbitrary value) will only be used for the NAM trace if one will be recorded.

Implements inet::IIngressClassifier.

51 {
52  // never label OSPF(TED) and RSVP traffic
53  const auto& ipv4Header = packet->peekAtFront<Ipv4Header>();
54 
55  switch (ipv4Header->getProtocolId()) {
56  case IP_PROT_OSPF:
57  case IP_PROT_RSVP:
58  return false;
59 
60  default:
61  break;
62  }
63 
64  // forwarding decision for non-labeled datagrams
65 
66  for (auto& elem : bindings) {
67  if (!elem.dest.isUnspecified() && !elem.dest.equals(ipv4Header->getDestAddress()))
68  continue;
69 
70  if (!elem.src.isUnspecified() && !elem.src.equals(ipv4Header->getSrcAddress()))
71  continue;
72 
73  EV_DETAIL << "packet belongs to fecid=" << elem.id << endl;
74 
75  if (elem.inLabel < 0)
76  return false;
77 
78  return lt->resolveLabel("", elem.inLabel, outLabel, outInterface, color);
79  }
80 
81  return false;
82 }

◆ numInitStages()

virtual int inet::RsvpClassifier::numInitStages ( ) const
inlineoverrideprotectedvirtual
57 { return NUM_INIT_STAGES; }

◆ processCommand()

void inet::RsvpClassifier::processCommand ( const cXMLElement &  node)
overrideprotectedvirtual

Called by ScenarioManager whenever a script command needs to be carried out by the module.

The command is represented by the XML element or element tree. The command name can be obtained as:

const char *command = node->getTagName()

Parameters are XML attributes, e.g. a "neighbour" parameter can be retrieved as:

const char *attr = node->getAttribute("neighbour")

More complex input can be passed in child elements.

See also
cXMLElement

Implements inet::IScriptable.

102 {
103  if (!strcmp(node.getTagName(), "bind-fec")) {
104  readItemFromXML(&node);
105  }
106  else
107  ASSERT(false);
108 }

◆ readItemFromXML()

void inet::RsvpClassifier::readItemFromXML ( const cXMLElement *  fec)
protectedvirtual
123 {
124  ASSERT(fec);
125  ASSERT(!strcmp(fec->getTagName(), "fecentry") || !strcmp(fec->getTagName(), "bind-fec"));
126 
127  int fecid = getParameterIntValue(fec, "id");
128 
129  auto it = findFEC(fecid);
130 
131  if (getUniqueChildIfExists(fec, "label")) {
132  // bind-fec to label
133  checkTags(fec, "id label destination source");
134 
135  EV_INFO << "binding to a given label" << endl;
136 
137  FecEntry newFec;
138 
139  newFec.id = fecid;
140  newFec.dest = getParameterIPAddressValue(fec, "destination");
141  newFec.src = getParameterIPAddressValue(fec, "source", Ipv4Address());
142 
143  newFec.inLabel = getParameterIntValue(fec, "label");
144 
145  if (it == bindings.end()) {
146  // create new binding
147  bindings.push_back(newFec);
148  }
149  else {
150  // update existing binding
151  *it = newFec;
152  }
153  }
154  else if (getUniqueChildIfExists(fec, "lspid")) {
155  // bind-fec to LSP
156  checkTags(fec, "id destination source tunnel_id extended_tunnel_id endpoint lspid");
157 
158  EV_INFO << "binding to a given path" << endl;
159 
160  FecEntry newFec;
161 
162  newFec.id = fecid;
163  newFec.dest = getParameterIPAddressValue(fec, "destination");
164  newFec.src = getParameterIPAddressValue(fec, "source", Ipv4Address());
165 
166  newFec.session.Tunnel_Id = getParameterIntValue(fec, "tunnel_id");
167  newFec.session.Extended_Tunnel_Id = getParameterIPAddressValue(fec, "extened_tunnel_id", routerId).getInt();
168  newFec.session.DestAddress = getParameterIPAddressValue(fec, "endpoint", newFec.dest); // ??? always use newFec.dest ???
169 
170  newFec.sender.Lsp_Id = getParameterIntValue(fec, "lspid");
171  newFec.sender.SrcAddress = routerId;
172 
173  newFec.inLabel = rsvp->getInLabel(newFec.session, newFec.sender);
174 
175  if (it == bindings.end()) {
176  // create new binding
177  bindings.push_back(newFec);
178  }
179  else {
180  // update existing binding
181  *it = newFec;
182  }
183  }
184  else {
185  // un-bind
186  checkTags(fec, "id");
187 
188  if (it != bindings.end()) {
189  bindings.erase(it);
190  }
191  }
192 }

◆ readTableFromXML()

void inet::RsvpClassifier::readTableFromXML ( const cXMLElement *  fectable)
protectedvirtual
113 {
114  ASSERT(fectable);
115  ASSERT(!strcmp(fectable->getTagName(), "fectable"));
116  checkTags(fectable, "fecentry");
117  cXMLElementList list = fectable->getChildrenByTagName("fecentry");
118  for (auto& elem : list)
119  readItemFromXML(elem);
120 }

Member Data Documentation

◆ bindings

std::vector<FecEntry> inet::RsvpClassifier::bindings
protected

◆ lt

ModuleRefByPar<LibTable> inet::RsvpClassifier::lt
protected

◆ maxLabel

int inet::RsvpClassifier::maxLabel = 0
protected

◆ routerId

Ipv4Address inet::RsvpClassifier::routerId
protected

◆ rsvp

ModuleRefByPar<RsvpTe> inet::RsvpClassifier::rsvp
protected

The documentation for this class was generated from the following files:
inet::xmlutils::getParameterIntValue
int getParameterIntValue(const cXMLElement *ptr, const char *name, int def)
Definition: XMLUtils.cc:106
inet::Ipv4Address::getInt
uint32_t getInt() const
Returns the address as an uint32_t in host byte order (e.g.
Definition: Ipv4Address.h:186
inet::RsvpClassifier::routerId
Ipv4Address routerId
Definition: RsvpClassifier.h:45
inet::IP_PROT_RSVP
@ IP_PROT_RSVP
Definition: IpProtocolId_m.h:100
inet::IP_PROT_OSPF
@ IP_PROT_OSPF
Definition: IpProtocolId_m.h:104
inet::RsvpClassifier::rsvp
ModuleRefByPar< RsvpTe > rsvp
Definition: RsvpClassifier.h:50
inet::RsvpClassifier::readTableFromXML
virtual void readTableFromXML(const cXMLElement *fectable)
Definition: RsvpClassifier.cc:112
inet::RsvpClassifier::readItemFromXML
virtual void readItemFromXML(const cXMLElement *fec)
Definition: RsvpClassifier.cc:122
inet::xmlutils::checkTags
void checkTags(const cXMLElement *node, const char *allowed)
Definition: XMLUtils.cc:55
inet::RsvpClassifier::maxLabel
int maxLabel
Definition: RsvpClassifier.h:46
inet::xmlutils::getParameterIPAddressValue
Ipv4Address getParameterIPAddressValue(const cXMLElement *ptr, const char *name, Ipv4Address def)
Definition: XMLUtils.cc:121
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
NUM_INIT_STAGES
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
inet::RsvpClassifier::bindings
std::vector< FecEntry > bindings
Definition: RsvpClassifier.h:48
inet::RsvpClassifier::lt
ModuleRefByPar< LibTable > lt
Definition: RsvpClassifier.h:49
inet::xmlutils::getUniqueChildIfExists
const cXMLElement * getUniqueChildIfExists(const cXMLElement *node, const char *name)
Definition: XMLUtils.cc:18
inet::RsvpClassifier::findFEC
std::vector< FecEntry >::iterator findFEC(int fecid)
Definition: RsvpClassifier.cc:194
inet::INITSTAGE_ROUTING_PROTOCOLS
INET_API InitStage INITSTAGE_ROUTING_PROTOCOLS
Initialization of routing protocols.