help modify error in accessponit.cc of omnet++

43 views
Skip to first unread message

Sonia Lamba

unread,
Jul 22, 2014, 11:01:37 AM7/22/14
to omn...@googlegroups.com
Hi there,
please help me in rectifying the .cc code...

#include "omnetpp.h"
class AccessPoint : public cSimpleModule
{
      Module_Class_Members(AccessPoint,cSimpleModule,16384);
      virtual void activity();
};

Define_Module( AccessPoint );

void AccessPoint::activity()
{
     //recording variables
     cOutVector resp_v("DataStn");
     float process_time = 0;
     float time_stamp = 0;
     float elasped_time = 0;
     float delay = 0;
     int random_wait; // variance time randomised

     //Address Information
     int sta_add = parentModule()->par("num_station");    //error: function parentModule could not be resolved
     int AP_addr = sta_add + 1;
     const int data_addr = 99; //permanent addr for data sta

      //msg parameters
      int source; // msg source
      int destination; // msg destination
      int msg_kind; //msg kind
      long msg_nav; // nav of the msg    
      float msg_timestamp; // time stamp of msg

       //IEEE802 vectors
       //--------------------------
       //State definitions
       int State = 1;
       //1 - Unauthenticated, Unassociated
       //2 - Authenticated, Unassociated
       //3 - Authenticated, Associated
       //Network Allocation Vector (NAV) - max value 32767 (appox 32 msec)
       long NAV = 0;
       long temp_NAV = 0; // updated NAV value of the incoming packet
       //Flags
       bool flag_AUT = false; // is there an outstanding AUT request
       bool flag_ASS = false; // is there an outstanding ASS request
       bool flag_CTS = false; // This station has CTS
       bool flag_RTS = false; // This station has RTS outstanding
       bool flag_ORTS = false;// Another Station has RTS outstanding
       bool flag_OCTS = false;// Another Station has CTS outstanding
       bool flag_CLK = false; // not waiting for CLK signal
       //Timing Constants - dependant on the PHY
       //Device Interval - delays due to busy device

       const int Device_Itvl = 3; // 3 cycles of clock
       //DIFS
       const int DIFS = 128; // microsecond
       const int error_DIFS = 12; // microsecond
      //SIFS 
       const int SIFS = 28; // microsecond
       const int error_SIFS = 4; // microsecond
       
        //Clock Cycle Time
        const int CLOCK = 4; // microsecond
       //microsecond denominator
       const double Million = 0.000001;
        // Message Kind Definition
        const int RTS = 1;
        const int CTS = 2;
        const int AUT = 3;
        const int ASS = 4;
        const int rply_AUT = 5;
        const int rply_ASS = 6;
        const int de_AUT = 7;
        const int de_ASS = 8;
        const int DATA = 9;
        const int ACK = 10;
        const int CLK = 11;
        const int LASTPKT = 12;

       //-------------------------------------------------------------------------
       for(;;)
       {//for
       //receiving from FS
       cMessage *done = receive();
       source = done->scr_add();//error : method src_add could not be resolved
       destination = done->des_add();
msg_kind = done->kind();
msg_nav = done->nvec();
msg_timestamp = done->msgtimer();
delete done;
if (destination == AP_addr)
{//if destination
if (msg_kind == AUT)
{//if AUT
//reply with a rply_AUT
cMessage *work = new cMessage( "rply_AUT" );
work->setSCR(AP_addr);
work->setDES(source);
//work->setROUTESCR(AP_addr);
//work->setROUTDES(source);
work->setKind(rply_AUT);
work->setMsgTime(simTime());
work->setNAV(0);
random_wait = intrand(6);
wait ((SIFS+random_wait)*Million);
send( work, "out" );

}//if AUT
if(msg_kind == ASS)
{//if ASS
//reply with a rply_ASS
cMessage *work = new cMessage( "rply_ASS" );
work->setSCR(AP_addr);
work->setDES(source);
//work->setROUTESCR(AP_addr);
//work->setROUTDES(source);
work->setKind(rply_ASS);
work->setNAV(0);
work->setMsgTime(simTime());
random_wait = intrand(6);
wait ((SIFS+random_wait)*Million);
send( work, "out" );
}//if ASS
if((msg_kind == RTS))
{//if RTS reply with CTS
//reply with a CTS
cMessage *work = new cMessage( "CTS" );
work->setSCR(AP_addr);
work->setDES(source);
//work->setROUTESCR(AP_addr);
//work->setROUTDES(source);
work->setKind(CTS);
work->setMsgTime(simTime());
// The transmission delay from RTS to CTS needs to be subtracted
// from the RTS NAV
process_time = msg_nav - SIFS;
work->setNAV(process_time);
NAV = process_time; //setting own NAV vector
time_stamp = simTime(); //of the NAV vector
wait ((SIFS)*Million);
send( work, "out" );
}//if RTS
if(msg_kind == LASTPKT)
{//if DATA
//reply with a ACK for last packet
cMessage *work = new cMessage( "ACK" );
work->setSCR(AP_addr);
work->setDES(source);
//work->setROUTESCR(AP_addr);
//work->setROUTDES(source);
work->setKind(ACK);
work->setNAV(0);
wait ((SIFS)*Million);//delay SIFS
work->setTimestamp();

send( work, "out" );
//resp_v.record(source); //xxx
}//if DATA
}//if destination
} //for
}//void

please help me in removing these errors...

Alfonso Ariza Quintana

unread,
Jul 22, 2014, 11:19:10 AM7/22/14
to omn...@googlegroups.com

Read the documentation parentModule doesn’t exist it is

 

getParentModule ()

--
You received this message because you are subscribed to the Google Groups "omnetpp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omnetpp+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sonia Lamba

unread,
Jul 22, 2014, 12:49:45 PM7/22/14
to omn...@googlegroups.com
Although parameter num_station has defined a value of 10...but only one station is created instead of 10...why is it so...Is there exist a problem in the code...

ned code

 

simple AccessPoint

{

    parameters:

    gates:

        input in;

        output out;

}

 

simple Freespace

{

    parameters:

    gates:

        output out[];

        input in[];

        output APout;

        input APin;

        output Aout;

        input Ain;

}

 

simple Station

{

    gates:

        output out[];

        input in[];

        input Cin[];

}

 

simple Attacker

{

    gates:

        input in;

        output out;

}

 

simple Clock

{

    gates:

        output out[];

}

 

 

//module IEEE

 

network wirelessLAN

{

    parameters:

        //num_station=input(10,"Number of mobile stations:");

    submodules:

        nodes[num_station]: IEEE {

            @display("p=65,51");

        }

}

   // parameters:

    //int num_station=default(10);

 

module IEEE

{

    parameters:

        int num_station = default(10);

 

    submodules:

        ap: AccessPoint {

            parameters:

                @display("p=134,101;i=access_point02;b=80,75");

        }

 

 

        freespace: Freespace {

 

            parameters:

                @display("p=293,231;i=cloud_1;b=103,49");

 

            gates:

                in[num_station];

                out[num_station];

 

 

        }

 

 

        sta[num_station]: Station {

            parameters:

                @display("p=106,317,r,50; i=pda1; b=25,36");

            gates:

                in[num_station];

                out[num_station];

                Cin[num_station];

        }

 

 

        attacker: Attacker {

            parameters:

                @display("p=541,116;i=hacker05;b=139,105");

 

        }

 

        clk[num_station]: Clock {

            parameters:

                @display("p=56,378,r,100;i=cogwheel2_s;b=50,40");

            gates:

                out[num_station];

 

 

        }

    connections:

        for i=0..num_station-1 {

            sta[i].out[i] --> {  datarate = 11000000Mbps; } --> freespace.in[i];

            freespace.out[i] --> sta[i].in[i];

            clk[i].out[i] --> sta[i].Cin[i];

 

        }

 

        ap.out --> {  datarate = 11000000Mbps; } --> freespace.APin;

        freespace.APout --> ap.in;

        freespace.APout --> attacker.in;// @display("m=m,95,63,47,28");

        attacker.out --> {  datarate = 11000000Mbps; } --> freespace.Ain; //display "m=m,47,28,95,63";

 

           //  @display("p=2,4; b=638,464");

Reply all
Reply to author
Forward
0 new messages