NetworkStackTrafficGen.h

00001 //
00002 // This program is free software: you can redistribute it and/or modify
00003 // it under the terms of the GNU Lesser General Public License as published by
00004 // the Free Software Foundation, either version 3 of the License, or
00005 // (at your option) any later version.
00006 //
00007 // This program is distributed in the hope that it will be useful,
00008 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00009 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010 // GNU Lesser General Public License for more details.
00011 //
00012 // You should have received a copy of the GNU Lesser General Public License
00013 // along with this program.  If not, see http://www.gnu.org/licenses/.
00014 //
00015 
00016 #ifndef NETWORKSTACKTRAFFICGEN_H_
00017 #define NETWORKSTACKTRAFFICGEN_H_
00018 
00019 #include "NetwPkt_m.h"
00020 #include "SimpleAddress.h"
00021 #include "BaseLayer.h"
00022 #include "BaseArp.h"
00023 #include <BaseWorldUtility.h>
00024 
00025 #include <omnetpp.h>
00026 
00032 class NetworkStackTrafficGen : public BaseLayer
00033 {
00034 public:
00035 
00036   enum TrafficGenMessageKinds{
00037 
00038     SEND_BROADCAST_TIMER = 1,
00039     BROADCAST_MESSAGE
00040   };
00041 
00042 protected:
00043 
00044   int packetLength;
00045   simtime_t packetTime;
00046   double pppt;
00047   int burstSize;
00048   int remainingBurst;
00049   long destination;
00050 
00051   int catPacket;
00052 
00053   long nbPacketDropped;
00054 
00055 
00056   BaseArp* arp;
00057   int myNetwAddr;
00058 
00059   cMessage *delayTimer;
00060 
00061   BaseWorldUtility* world;
00062 
00063 public:
00064   virtual ~NetworkStackTrafficGen();
00065 
00066   virtual void initialize(int stage);
00067 
00068   virtual void finish();
00069 
00070 protected:
00072   virtual void handleSelfMsg(cMessage *msg);
00073 
00075   virtual void handleLowerMsg(cMessage *msg);
00076 
00078   virtual void handleLowerControl(cMessage *msg);
00079 
00081   virtual void handleUpperMsg(cMessage *msg)
00082   {
00083     opp_error("NetworkStackTrafficGen has no upper layers!");
00084     delete msg;
00085   }
00086 
00088   virtual void handleUpperControl(cMessage *msg)
00089   {
00090     opp_error("NetworkStackTrafficGen has no upper layers!");
00091     delete msg;
00092   }
00093 
00095   virtual void sendBroadcast();
00096 };
00097 
00098 #endif