INET Framework for OMNeT++/OMNEST
SimpleClassifier Class Reference

#include <SimpleClassifier.h>

Inheritance diagram for SimpleClassifier:
IScriptable IRSVPClassifier IClassifier

List of all members.

Classes

struct  FECEntry

Public Member Functions

 SimpleClassifier ()

Protected Member Functions

virtual void initialize (int stage)
virtual int numInitStages () const
virtual void handleMessage (cMessage *msg)
virtual void processCommand (const cXMLElement &node)
virtual bool lookupLabel (IPDatagram *ipdatagram, LabelOpVector &outLabel, std::string &outInterface, int &color)
virtual void bind (const SessionObj_t &session, const SenderTemplateObj_t &sender, int inLabel)
virtual void readTableFromXML (const cXMLElement *fectable)
virtual void readItemFromXML (const cXMLElement *fec)
std::vector< FECEntry >::iterator findFEC (int fecid)

Protected Attributes

IPAddress routerId
int maxLabel
std::vector< FECEntrybindings
LIBTablelt
RSVPrsvp

Detailed Description

TODO documentation


Constructor & Destructor Documentation

SimpleClassifier::SimpleClassifier ( ) [inline]
{}

Member Function Documentation

void SimpleClassifier::bind ( const SessionObj_t &  session,
const SenderTemplateObj_t &  sender,
int  inLabel 
) [protected, virtual]

Implements IRSVPClassifier.

{
    std::vector<FECEntry>::iterator it;
    for (it = bindings.begin(); it != bindings.end(); it++)
    {
        if (it->session != session)
            continue;

        if (it->sender != sender)
            continue;

        it->inLabel = inLabel;
    }
}
std::vector< SimpleClassifier::FECEntry >::iterator SimpleClassifier::findFEC ( int  fecid) [protected]

Referenced by readItemFromXML().

{
    std::vector<FECEntry>::iterator it;
    for (it = bindings.begin(); it != bindings.end(); it++)
    {
        if (it->id != fecid)
            continue;

        break;
    }
    return it;
}
void SimpleClassifier::handleMessage ( cMessage *  msg) [protected, virtual]
{
    ASSERT(false);
}
void SimpleClassifier::initialize ( int  stage) [protected, virtual]
{
    // we have to wait until routerId gets assigned in stage 3
    if (stage!=4)
        return;

    maxLabel = 0;

    RoutingTableAccess routingTableAccess;
    IRoutingTable *rt = routingTableAccess.get();
    routerId = rt->getRouterId();

    LIBTableAccess libTableAccess;
    lt = libTableAccess.get();

    RSVPAccess rsvpAccess;
    rsvp = rsvpAccess.get();

    readTableFromXML(par("conf").xmlValue());

    WATCH_VECTOR(bindings);
}
bool SimpleClassifier::lookupLabel ( IPDatagram *  ipdatagram,
LabelOpVector outLabel,
std::string &  outInterface,
int &  color 
) [protected, virtual]

The ipdatagram 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 IP 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 IClassifier.

{
    // never label OSPF(TED) and RSVP traffic

    switch(ipdatagram->getTransportProtocol())
    {
        case IP_PROT_OSPF:
        case IP_PROT_RSVP:
            return false;

        default:
            ;
    }

    // forwarding decision for non-labeled datagrams

    std::vector<FECEntry>::iterator it;
    for (it = bindings.begin(); it != bindings.end(); it++)
    {
        if (!it->dest.isUnspecified() && !it->dest.equals(ipdatagram->getDestAddress()))
            continue;

        if (!it->src.isUnspecified() && !it->src.equals(ipdatagram->getSrcAddress()))
            continue;

        EV << "packet belongs to fecid=" << it->id << endl;

        if (it->inLabel < 0)
            return false;

        return lt->resolveLabel("", it->inLabel, outLabel, outInterface, color);
    }

    return false;
}
virtual int SimpleClassifier::numInitStages ( ) const [inline, protected, virtual]
{return 5;}
void SimpleClassifier::processCommand ( const cXMLElement &  node) [protected, virtual]

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 IScriptable.

{
    if (!strcmp(node.getTagName(), "bind-fec"))
    {
        readItemFromXML(&node);
    }
    else
        ASSERT(false);
}
void SimpleClassifier::readItemFromXML ( const cXMLElement *  fec) [protected, virtual]

Referenced by processCommand(), and readTableFromXML().

{
    ASSERT(fec);
    ASSERT(!strcmp(fec->getTagName(), "fecentry") || !strcmp(fec->getTagName(), "bind-fec"));

    int fecid = getParameterIntValue(fec, "id");

    std::vector<FECEntry>::iterator it = findFEC(fecid);

    if (getUniqueChildIfExists(fec, "label"))
    {
        // bind-fec to label
        checkTags(fec, "id label destination source");

        EV << "binding to a given label" << endl;

        FECEntry newFec;

        newFec.id = fecid;
        newFec.dest = getParameterIPAddressValue(fec, "destination");
        newFec.src = getParameterIPAddressValue(fec, "source", IPAddress());

        newFec.inLabel = getParameterIntValue(fec, "label");

        if (it == bindings.end())
        {
            // create new binding
            bindings.push_back(newFec);
        }
        else
        {
            // update existing binding
            *it = newFec;
        }
    }
    else if (getUniqueChildIfExists(fec, "lspid"))
    {
        // bind-fec to LSP
        checkTags(fec, "id destination source tunnel_id extended_tunnel_id endpoint lspid");

        EV << "binding to a given path" << endl;

        FECEntry newFec;

        newFec.id = fecid;
        newFec.dest = getParameterIPAddressValue(fec, "destination");
        newFec.src = getParameterIPAddressValue(fec, "source", IPAddress());

        newFec.session.Tunnel_Id = getParameterIntValue(fec, "tunnel_id");
        newFec.session.Extended_Tunnel_Id = getParameterIPAddressValue(fec, "extened_tunnel_id", routerId).getInt();
        newFec.session.DestAddress = getParameterIPAddressValue(fec, "endpoint", newFec.dest); // ??? always use newFec.dest ???

        newFec.sender.Lsp_Id = getParameterIntValue(fec, "lspid");
        newFec.sender.SrcAddress = routerId;

        newFec.inLabel = rsvp->getInLabel(newFec.session, newFec.sender);

        if (it == bindings.end())
        {
            // create new binding
            bindings.push_back(newFec);
        }
        else
        {
            // update existing binding
            *it = newFec;
        }
    }
    else
    {
        // un-bind
        checkTags(fec, "id");

        if (it != bindings.end())
        {
            bindings.erase(it);
        }
    }
}
void SimpleClassifier::readTableFromXML ( const cXMLElement *  fectable) [protected, virtual]

Referenced by initialize().

{
    ASSERT(fectable);
    ASSERT(!strcmp(fectable->getTagName(), "fectable"));
    checkTags(fectable, "fecentry");
    cXMLElementList list = fectable->getChildrenByTagName("fecentry");
    for (cXMLElementList::iterator it=list.begin(); it != list.end(); it++)
        readItemFromXML(*it);
}

Member Data Documentation

Referenced by initialize(), and lookupLabel().

int SimpleClassifier::maxLabel [protected]

Referenced by initialize().

Referenced by initialize(), and readItemFromXML().


The documentation for this class was generated from the following files: