INET Framework for OMNeT++/OMNEST
DscpTtlCorrector Class Reference

#include <DscpTtlCorrector.h>

List of all members.

Protected Member Functions

virtual void initialize ()
virtual void handleMessage (cMessage *msg)

Private Attributes

TrafGentg

Detailed Description

Definition at line 26 of file DscpTtlCorrector.h.


Member Function Documentation

void DscpTtlCorrector::handleMessage ( cMessage *  msg) [protected, virtual]

Definition at line 42 of file DscpTtlCorrector.cc.

{
  // zistenie indexu vstupnej brany a nazvu
  cGate* gate = msg->getArrivalGate();
        std::string name = gate->getBaseName();
        int index = gate->getIndex();
        
        if (name == "toNetworkLayerIn")
        { // paket prichadzajuci z generatora -> musi byt upraveny
    cMessage *copy = msg->dup(); 

    cPacket *test = (cPacket*)(copy);
                std::string type = test->getClassName();
          if (type == "IPDatagram")
          { // zmena s tyka len IP paketov
      IPDatagram *ipData = dynamic_cast<IPDatagram*> (copy);
      IPAddress srcAdd =  ipData->getSrcAddress();
      IPAddress destAdd =  ipData->getDestAddress();
      
      unsigned char tos = 0;
      short ttl = 32;
      TCPSegment *tcppacket;
      UDPPacket *udppacket;
      int srcPort;
      int destPort;
             
      switch (ipData->getTransportProtocol())
      { // rozbalenie IP paketu a zistenie DSCP a TTL podla definicie toku
        case IP_PROT_UDP: 
          udppacket = dynamic_cast<UDPPacket *> (ipData->decapsulate());
          srcPort = udppacket->getSourcePort();
          destPort = udppacket->getDestinationPort();
          tos = tg->getDscpByFlowInfo(srcAdd, destAdd, IP_PROT_UDP, srcPort, destPort);
          ttl = tg->getTtlByFlowInfo(srcAdd, destAdd, IP_PROT_UDP, srcPort, destPort);
          tg->updateSentStats(udppacket->decapsulate());
          delete udppacket;
          break;
        case IP_PROT_TCP: 
          tcppacket = dynamic_cast<TCPSegment *> (ipData->decapsulate());
          srcPort = tcppacket->getSrcPort(); 
          destPort = tcppacket->getDestPort();
          tos = tg->getDscpByFlowInfo(srcAdd, destAdd, IP_PROT_TCP, srcPort, destPort);
          ttl = tg->getTtlByFlowInfo(srcAdd, destAdd, IP_PROT_TCP, srcPort, destPort);
          cPacket *cpkt;
          uint32 endSeqNo;
          while ((cpkt=tcppacket->removeFirstPayloadMessage(endSeqNo))!=NULL)
          {
            tg->updateSentStats(cpkt);
          }
          delete tcppacket;
          break;
        default:
          break;
      }
      // zmena pozadovanych hodnot
      ipData = dynamic_cast<IPDatagram*> (msg);
      ipData->setTimeToLive(ttl);
      ipData->setDiffServCodePoint(tos);
    }
          // vysle zmeneny paket na vystupnu vranu 
    this->send(msg, "ifOut", index);
    delete copy;
  }
  else
  { // paket prichadzajuci zo siete -> posiela sa bez zmeny
    this->send(msg, "toNetworkLayerOut", index);
  }
}
void DscpTtlCorrector::initialize ( ) [protected, virtual]

Definition at line 30 of file DscpTtlCorrector.cc.

{
  // ziska ukazovatel na modul traffic generatoru
  tg = TrafGenAccess().get(); 
}

Member Data Documentation

Definition at line 30 of file DscpTtlCorrector.h.

Referenced by handleMessage(), and initialize().


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