IPTrafGen.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2004 Andras Varga
00003 // Copyright (C) 2000 Institut fuer Telematik, Universitaet Karlsruhe
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public License
00016 // along with this program; if not, see <http://www.gnu.org/licenses/>.
00017 //
00018 
00019 
00020 #ifndef __INET_IPTRAFGEN_H
00021 #define __INET_IPTRAFGEN_H
00022 
00023 #include <vector>
00024 #include <omnetpp.h>
00025 
00026 #include "IPvXAddress.h"
00027 
00028 
00032 class INET_API IPTrafSink : public cSimpleModule
00033 {
00034   protected:
00035     int numReceived;
00036 
00037     virtual void printPacket(cPacket *msg);
00038     virtual void processPacket(cPacket *msg);
00039 
00040   protected:
00041     virtual void initialize();
00042     virtual void handleMessage(cMessage *msg);
00043 };
00044 
00045 
00049 class INET_API IPTrafGen : public IPTrafSink
00050 {
00051   protected:
00052     std::string nodeName;
00053     int protocol;
00054     int msgByteLength;
00055     int numPackets;
00056     std::vector<IPvXAddress> destAddresses;
00057 
00058     static int counter; // counter for generating a global number for each packet
00059 
00060     int numSent;
00061 
00062     // chooses random destination address
00063     virtual IPvXAddress chooseDestAddr();
00064     virtual void sendPacket();
00065 
00066   protected:
00067     virtual int numInitStages() const {return 4;}
00068     virtual void initialize(int stage);
00069     virtual void handleMessage(cMessage *msg);
00070 };
00071 
00072 #endif
00073 
00074