Permalink
Browse files

SelfSimMGI was added

  • Loading branch information...
privalov1967 committed Apr 4, 2014
1 parent 41af0ae commit 85542f4c1f995963a6b19f787746daa37af63b82
Showing with 11,433 additions and 0 deletions.
  1. +33 −0 src/underTest/SelfSimMGI/Common_Modules/Sink.cc
  2. +9 −0 src/underTest/SelfSimMGI/Common_Modules/Sink.ned
  3. +76 −0 src/underTest/SelfSimMGI/FromFile_Source/FromFile_Source.cc
  4. +13 −0 src/underTest/SelfSimMGI/FromFile_Source/FromFile_Source.ned
  5. +15 −0 src/underTest/SelfSimMGI/FromFile_Traffic_sim.ned
  6. +106 −0 src/underTest/SelfSimMGI/MGI_LOG_Source/Ind_MGI_LOG_Source.cc
  7. +29 −0 src/underTest/SelfSimMGI/MGI_LOG_Source/MGI_LOG_Collector.cc
  8. +55 −0 src/underTest/SelfSimMGI/MGI_LOG_Source/MGI_LOG_Generator.cc
  9. +207 −0 src/underTest/SelfSimMGI/MGI_LOG_Source/MGI_LOG_Par.cc
  10. +52 −0 src/underTest/SelfSimMGI/MGI_LOG_Source/MGI_LOG_Source.ned
  11. +15 −0 src/underTest/SelfSimMGI/MGI_LOG_Traffic_sim.ned
  12. +119 −0 src/underTest/SelfSimMGI/MGI_Source/Individual_MGI_Source.cc
  13. +29 −0 src/underTest/SelfSimMGI/MGI_Source/MGI_Collector.cc
  14. +55 −0 src/underTest/SelfSimMGI/MGI_Source/MGI_Generator.cc
  15. +273 −0 src/underTest/SelfSimMGI/MGI_Source/MGI_Parameters_Calculator.cc
  16. +52 −0 src/underTest/SelfSimMGI/MGI_Source/MGI_Source.ned
  17. +15 −0 src/underTest/SelfSimMGI/MGI_Traffic_sim.ned
  18. BIN src/underTest/SelfSimMGI/SelfSimMGI Readme.pdf
  19. +219 −0 src/underTest/SelfSimMGI/Statistics/Traffic_Stats.cc
  20. +29 −0 src/underTest/SelfSimMGI/Statistics/Traffic_Stats.ned
  21. +27 −0 src/underTest/SelfSimMGI/omnetpp.ini
  22. +5 −0 src/underTest/SelfSimMGI/pcap2TL.bat
  23. BIN src/underTest/SelfSimMGI/pcap2TL.zip
  24. +10,000 −0 src/underTest/SelfSimMGI/sanjoseA2008.TL
@@ -0,0 +1,33 @@
// Simplest Sink for arriving packets

#include <omnetpp.h>

class Sink : public cSimpleModule
{
protected:

// The following redefined virtual function holds the algorithm.
virtual void initialize();
virtual void handleMessage(cMessage *msg);
};


// The module class needs to be registered with OMNeT++
Define_Module(Sink);


void Sink::initialize()
{
// Initialize is called at the beginning of the simulation.

}


void Sink::handleMessage(cMessage *msg)
{
// The handleMessage() method is called whenever a message arrives
// at the module.

// cPacket *pkt = check_and_cast<cPacket *>(msg);
delete msg;
}
@@ -0,0 +1,9 @@
// Simplest Sink for arriving packets

package Common_Modules;

simple Sink
{
gates:
input in;
}
@@ -0,0 +1,76 @@
// Source of packet traffic restored from packet trace file
// of TL or TCP format

#include <omnetpp.h>
#include <string>
#include <fstream>
#include <math.h>

class FromFile_Source : public cSimpleModule
{
protected:
// file with traffic trace
std::ifstream trace;
std::string filetype;

// fields for packet record processing
double ArrTime;
int pktsize;
int i1, i2, i3, i4;

// The following redefined virtual function holds the algorithm.
virtual void initialize();
virtual void handleMessage(cMessage *msg);

// File type dependent function
void readRecord();
};

// The module class needs to be registered with OMNeT++
Define_Module(FromFile_Source);


void FromFile_Source::readRecord()
{
if (filetype == "tcp")
trace >> ArrTime >> i1 >> i2 >> i3 >> i4 >> pktsize;
else // here it means "TL"
trace >> ArrTime >> pktsize;
}


void FromFile_Source::initialize()
{
// Initialize is called at the beginning of the simulation.

filetype=par("filetype").stringValue();
trace.open( par("tracefile").stringValue() );
if (trace != NULL )
if ( !trace.eof() ) {
readRecord();
ArrTime -= floor(ArrTime);
cMessage *msg = new cMessage("next");
scheduleAt( (simtime_t)ArrTime, msg);
}
else {
trace.close();
EV<<"Trace file is empty, source is shut down"<<endl;
}
else EV<<"No trace file, source is shut down"<<endl;
}


void FromFile_Source::handleMessage(cMessage *msg)
{
// The handleMessage() method is called whenever a message arrives
// at the module.

if ( !trace.eof() ) {
cPacket *pkt = new cPacket("packet");
pkt->setByteLength(pktsize);
send(pkt, "out");
readRecord();
scheduleAt((simtime_t)ArrTime, msg);
}
else trace.close();
}
@@ -0,0 +1,13 @@
// Source of packet traffic restored from packet trace file
// of TL or TCP format

package FromFile_Source;

simple FromFile_Source
{
parameters:
string filetype = default("tcp");
string tracefile;
gates:
output out;
}
@@ -0,0 +1,15 @@
import Common_Modules.*;
import FromFile_Source.*;
import Statistics.*;

network FromFile_Traffic_sim
{
submodules:
src: FromFile_Source;
stat: Traffic_Stats;
dst: Sink;
connections:
src.out --> stat.in;
stat.out --> dst.in;
}

@@ -0,0 +1,106 @@
// Individual source, generated by MGI_Generator class object.
// Works finite time and then disappears.

#include <string>
#include <vector>
#include <math.h>
#include <omnetpp.h>

class Ind_MGI_LOG_Source : public cSimpleModule
{
protected:
simtime_t timeslot; // time between packets
int cellsize; // cell size in bytes
int pktsize; // packet size in bytes
simtime_t timeleft; // time of working before disappirance

cXMLElement *doc; // file with source parameters

cGate *dst; // gate for packet direct sending

// Source speed parameters and functions
std::vector<double> dstS;
int setPacketSize();

// timeleft distribution parameters and functions
std::vector<double> pA;
simtime_t setTimeLeft();

// The following redefined virtual function holds the algorithm.
virtual void initialize();
virtual void handleMessage(cMessage *msg);
};


// The module class needs to be registered with OMNeT++
Define_Module(Ind_MGI_LOG_Source);


#define gDEBP(A,B) (A->getDocumentElementByPath(A,B))->getNodeValue()


void Ind_MGI_LOG_Source::initialize()
{
// Initialize is called at the beginning of the simulation.


doc=par("profile");

// basic parameters initialization
timeslot = atof(gDEBP(doc,"/TIMESLOT"));
cellsize = atoi(gDEBP(doc,"/CELLSIZE"));

pktsize = setPacketSize();
timeleft= setTimeLeft();

dst= getParentModule()->getSubmodule("collect")->gate("in");

// Starting message scheduling
cMessage *msg = new cMessage("next");
scheduleAt( simTime(), msg);
}


void Ind_MGI_LOG_Source::handleMessage(cMessage *msg)
{
// The handleMessage() method is called whenever a message arrives
// at the module.

if ( timeleft>0) { // generate new paket
cPacket *pkt = new cPacket("packet");
pkt->setByteLength(pktsize);
sendDirect(pkt, dst);
scheduleAt(simTime()+timeslot, msg);
timeleft-=timeslot;
}
else { // stop working and disappire
delete msg;
callFinish();
deleteModule();
}
}


int Ind_MGI_LOG_Source::setPacketSize()
{
return cellsize;
}

simtime_t Ind_MGI_LOG_Source::setTimeLeft()
{

// preparing data for timeleft calculation
cStringTokenizer tok(gDEBP(doc,"/ACF-SHAPE-PARAMETERS"));
pA = tok.asDoubleVector();
double alpha= pA[0];
double px = pA[1];
double py = pA[2];
double A = pA[3];
double imax = pA[4]+0.5;

// timeleft random value generation
int i;
double s, x=uniform(0,1);
for(s=py,i=2; x>=s && i<imax; i++) s+=A*pow(px+i,-alpha);
return timeslot*(i-1);
}
@@ -0,0 +1,29 @@
// Collects packets from all individual sources into one output stream

#include <omnetpp.h>

class MGI_LOG_Collector : public cSimpleModule
{
protected:

// The following redefined virtual function holds the algorithm.
virtual void initialize();
virtual void handleMessage(cMessage *msg);

};

// The module class needs to be registered with OMNeT++
Define_Module(MGI_LOG_Collector);

void MGI_LOG_Collector::initialize()
{
// Initialize is called at the beginning of the simulation.

}

void MGI_LOG_Collector::handleMessage(cMessage *msg)
{
// The handleMessage() method is called whenever a message arrives
// at the module.
send(msg,"out");
}
@@ -0,0 +1,55 @@
// Generates new individual sources during Input M/G/Infinity Source
// working.

#include <omnetpp.h>
#include <fstream>
#include <string>

class MGI_LOG_Generator : public cSimpleModule
{

protected:
cModuleType *Ind_Source_Factory;
double lambda;
simtime_t timeslot;

cXMLElement *doc;

// The following redefined virtual function holds the algorithm.
virtual void initialize();
virtual void handleMessage(cMessage *msg);
};

// The module class needs to be registered with OMNeT++
Define_Module(MGI_LOG_Generator);

#define gDEBP(A,B) (A->getDocumentElementByPath(A,B))->getNodeValue()

void MGI_LOG_Generator::initialize()
{
// Initialize is called at the beginning of the simulation.

// Initializing factory of individual sources
Ind_Source_Factory = cModuleType::get("MGI_LOG_Source.Ind_MGI_LOG_Source");

EV<<"Generator parameters loading started"<<endl;

// basic parameters initialization
doc=par("profile");
timeslot = atof(gDEBP(doc,"/TIMESLOT"));
lambda = atof(gDEBP(doc,"//SOURCE-BORN-RATE"));

// Start message scheduling
cMessage *msg = new cMessage("newsource");
scheduleAt( simTime(), msg);
}

void MGI_LOG_Generator::handleMessage(cMessage *msg)
{
// The handleMessage() method is called whenever a message arrives
// at the module.

// Creating new CBR source and planning next
Ind_Source_Factory->createScheduleInit("Ind_Src", this->getParentModule());
scheduleAt(simTime()+timeslot*exponential(1/lambda), msg);
}
Oops, something went wrong.

0 comments on commit 85542f4

Please sign in to comment.