There is an error in Define_Module(OLT) when i try to build my code.
Am i doing something wrong?
D:\omnetpp-4.6\ptixiaki\XGPON/OLT.cc:18: undefined reference to `OLT::OLT()' collect2.exe: error: ld returned 1 exit status make: *** [out/gcc-debug//XGPON.exe] Error 1 Makefile:94: recipe for target 'out/gcc-debug//XGPON.exe' failed
//XGPON.NED
package xgpon;
import ned.DelayChannel;
import ned.IdealChannel;
simple OLT
{
@display("i=device/mainframe");
gates:
input splitter_to_OLT;
output OLT_to_splitter;
}
simple Splitter
{
@display("i=device/modem");
gates:
input ONU_splitter[];
input OLT_splitter;
output splitter_OLT;
output splitter_ONU[];
}
simple ONU
{
@display("i=device/laptop");
gates:
input splitter_to_ONU;
output ONU_to_splitter;
}
network XGPON
{
parameters:
@display("bgb=550,234;i=block/network2");
int n_nodes = 6;
types:
channel upstream extends ned.DatarateChannel
{
datarate = 2.48832 Gbps; //datarate of the channel
}
channel downstream extends ned.DatarateChannel
{
datarate = 9.95328 Gbps; //datarate of the channel
}
submodules:
splitter: Splitter {
@display("p=258,109");
}
olt: OLT {
@display("p=57,59");
}
onu: ONU {
@display("p=393,87");
}
connections:
olt.OLT_to_splitter --> downstream -->splitter.OLT_splitter;
splitter.splitter_OLT --> downstream --> onu.splitter_to_ONU;
splitter.splitter_ONU++ --> upstream --> olt.splitter_to_OLT;
onu.ONU_to_splitter --> upstream --> splitter.ONU_splitter++;
}
//OLT.H
#ifndef OLT_H_
#define OLT_H_
#include <omnetpp.h>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include "Packet_m.h"
#include "DownstreamFrame_m.h"
#include "UpstreamFrame_m.h"
#define FRAME_TIME 691.2
class OLT : public cSimpleModule
{
private:
int source;
//int destination;
simsignal_t arrivalSignal;
int no_sent;
int no_rcvd;
cMessage *DownstreamFrameSendEvent, *NewPacketArrivalEvent;
simtime_t sendTimeout, bufferTimeout;
XGPONpacket *downFragment;
cPacketQueue *OLTBuffer;
std::vector<double> distance, RTT, BandwidthUtilizationProfile, AllocationWeight;
//std::vector<long double> accumulatedRequestedBandwidth , accumulatedAllocatedBandwidth;
std:: vector<int> upstreamBandwidthDemands, DownPacketsForONU, destination;
int oltId, numberOfOnus, headerSize, PSBd, parityBytes, PLOAMdMessages, FrameQueueSize, fragmentBytes, BWMap;
//int FixedGuarandeedBandwidth, totalUpstreamBandwidth, AssuredGuarandeedBandwidth, firstPhaseNonGuarandeedBandwidth;
//long double totalBytesCreated, totalBytesReceived, SumDelay, SquareSumDelay, totalUpDelay, SumBUP;
//double ABU, ProtectionParameter, OverloadedOnusAllocationWeighSum, UpdatingImpact, SW;
double ONU_time_counter ; /* a local time counter for file results */
double variate; /* the final exponenetial variate (interarrivals) */
double sum_variate ; /* used to compute the experimental mean for variate */
double sum_rnd; /* used to compute the experimental mean for UD */
long loops ; /* counter for loops */
long pkt_per_time_unit ; /* nb of pkts per unit of time */
double time; /* our simulated time in us */
double mean,start_pktime,ref_time,end_pktime;
double rnd_nb; /* the uniform random number */
public :
OLT();
virtual ~OLT();
protected:
virtual void initialize();
virtual void handleMessage(cMessage *msg);
virtual XGPONpacket *generatePacket();
virtual void generateFrame(cPacketQueue *queue);
//virtual void generateHeader(cPacketQueue *queue);
virtual void forwardFrame(XGPONpacket *msg);
virtual void finish();
//virtual int defragmentation(cPacketQueue *queue);
};
#endif /* OLT_H_ */
//OLT.CC
#include "OLT.h"
Define_Module(OLT); //the error is here
void OLT::initialize()
{
numberOfOnus = 6;
cPacketQueue* OLTBuffer = new cPacketQueue("OLTBuffer");
for(int i = 0; i<= numberOfOnus; i++){
OLTBuffer->insert(generatePacket());
XGPONpacket *packet = (XGPONpacket *) OLTBuffer->pop();
//Distance
distance.push_back(destination.at(i) + 20);
EV << "My distance is " << distance[i] << " numbers.\n \n";
EV << "My destination is " << packet->getDestination()/2 << ".\n \n";
//RTT
RTT.push_back(distance.at(i) / 3*(10^8));
EV << "My RTT is " << RTT[i] << " numbers.\n \n";
}
EV << "My buffer size is " << OLTBuffer->getLength() << " numbers.\n \n";
//generateFrame(OLTBuffer);
}
void OLT::handleMessage(cMessage *msg)
{
XGPONpacket *ttmsg = check_and_cast<XGPONpacket *>(msg);
forwardFrame(ttmsg);
}
void OLT::generateFrame(cPacketQueue *OLTBuffer)
{
DownFrame *queue = new DownFrame();
//Fmqueue Fmqueue;
queue->~DownFrame();
//FrameQueueSize = queue -> getFrameSize();
//cPacketQueue *queue = new cPacketQueue();
//FrameQueueSize = 155520;
for(int i=0 ; i <OLTBuffer->getLength(); i++)
{
//EV << "GAMW TI MANA SOU " << OLTBuffer->getLength() << " numbers.\n \n";
XGPONpacket *packet = (XGPONpacket *) OLTBuffer->pop();
simtime_t waitingTime = simTime() - packet->getCreationTime();
double processTime = (packet->getBitLength()/(9.95328 * pow (10,9))) + (RTT.at(packet->getDestination())/2);
simtime_t receptTime = waitingTime + processTime;
packet->setReceptionTime(receptTime);
EV << "<<<<<<< OLT (id =" << oltId << ") : Packet " << packet->getName() << "reception time:" << packet->getReceptionTime() << ">>>>> \n";
OLTBuffer -> insert(packet);
}
while ((queue->getByteLength() < FrameQueueSize) && (OLTBuffer->isEmpty() == false))
{
XGPONpacket *max = (XGPONpacket *) OLTBuffer->pop();
for(int i=0; i<OLTBuffer->length(); i++)
{
XGPONpacket *data = (XGPONpacket *) OLTBuffer->pop();
if(max->getReceptionTime() >= data->getReceptionTime())
{
OLTBuffer -> insert(data);
}
else
{
OLTBuffer->insert(max);
max = data->dup();
delete data;
}
}
EV <<"<<<< OLT (id =" << oltId <<") : Packet " << max->getName() << " reception time:" << max->getReceptionTime() << "inserted to frame >>>>\n";
queue->insert(max);
}
}
XGPONpacket *OLT::generatePacket()
{
// Produce source and destination addresses.
//source = getIndex(); // our module index
//Destinationn
int time_limit = 60;
for(source = 1; source <= numberOfOnus-1; source++)
{
ONU_time_counter = 0;
pkt_per_time_unit = 0;
sum_variate = 0;
sum_rnd = 0;
loops = 0;
time=0;
destination.push_back(intuniform(2,numberOfOnus-1));
start_pktime=0.7;
end_pktime=12.7; //1gb prepei na brw transmision time
mean = start_pktime;
ref_time = time;
while( time < time_limit )
{
if(ONU_time_counter >= FRAME_TIME)
{
mean = (double) mean +(end_pktime - start_pktime)/((time_limit - ref_time)/FRAME_TIME);
ONU_time_counter = ONU_time_counter - FRAME_TIME;
/* prints the nb of pkts / unit time */
//fprintf(files1, "\n%ld", pkt_per_time_unit);
pkt_per_time_unit = 0;
}
//rnd_nb = (random()/limit); /* the random number 0<= x <=1 */
rnd_nb = uniform(0,1);
/* compute the IAT */
variate = (-mean)*log(rnd_nb); /* Poisson IAT */
//wait(variate);
XGPONpacket *msg = new XGPONpacket();
msg->setSource(source);
msg->setDestination(destination[source]);
msg->setByteLength(intuniform(64,1518));
return msg;
}
}
}
void OLT::forwardFrame(XGPONpacket *msg)
{
// Same routing as before: random gate.
int n = gateSize("out");
//int k = destination;
//EV << "Forwarding message " << msg << " on gate[" << k << "]\n";
send(msg, "out");
}
void OLT::finish()
{
//recordScalar("#sent", no_sent);
//recordScalar("received", no_rcvd);
}
OLT::OLT()
? I see that constructor declared, but it doesn't seem to be defined anywhere in this code.