SomeUDPApp.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // Copyright (C) 2004 Andras Varga
  3. // Copyright (C) 2000 Institut fuer Telematik, Universitaet Karlsruhe
  4. //
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the GNU General Public License
  7. // as published by the Free Software Foundation; either version 2
  8. // of the License, or (at your option) any later version.
  9. //
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program; if not, write to the Free Software
  17. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. //
  19. #ifndef __SOMEUDPAPP_H__
  20. #define __SOMEUDPAPP_H__
  21. #include <vector>
  22. #include "inet/common/INETDefs.h"
  23. #include "UDPAppBase.h"
  24. /**
  25. * A copy of UDPBasicApp, just for testing.
  26. * NOTE that this class is NOT declared INET_API!
  27. */
  28. class SomeUDPApp : public UDPAppBase
  29. {
  30. protected:
  31. std::string nodeName;
  32. int localPort, destPort;
  33. int msgLength;
  34. std::vector<Address> destAddresses;
  35. static int counter; // counter for generating a global number for each packet
  36. int numSent;
  37. int numReceived;
  38. // chooses random destination address
  39. virtual Address chooseDestAddr();
  40. virtual void sendPacket();
  41. virtual void processPacket(cMessage *msg);
  42. protected:
  43. virtual int numInitStages() const { return NUM_INIT_STAGES; }
  44. virtual void initialize(int stage);
  45. virtual void handleMessage(cMessage *msg);
  46. virtual void refreshDisplay() const override;
  47. };
  48. #endif