| 1 | #ifndef __PINGPONG_H_
|
---|
| 2 | #define __PINGPONG_H_
|
---|
| 3 |
|
---|
| 4 | #include <map>
|
---|
| 5 | #include <iostream>
|
---|
| 6 | #include <vector>
|
---|
| 7 | #include "ariba/utility/types.h"
|
---|
| 8 | #include "ariba/utility/system/Timer.h"
|
---|
| 9 | #include "ariba/utility/misc/Helper.h"
|
---|
| 10 | #include "ariba/utility/messages.h"
|
---|
| 11 | #include "ariba/utility/measurement/PathloadMeasurement.h"
|
---|
| 12 | #include "ariba/utility/configuration/Configuration.h"
|
---|
| 13 | #include "ariba/utility/logging/Logging.h"
|
---|
| 14 | #include "ariba/utility/measurement/PathloadMeasurement.h"
|
---|
| 15 | #include "ariba/utility/system/StartupInterface.h"
|
---|
| 16 | #include "ariba/interface/UnderlayAbstraction.h"
|
---|
| 17 | #include "ariba/interface/AribaContext.h"
|
---|
| 18 | #include "ariba/interface/ServiceInterface.h"
|
---|
| 19 | #include "PingPongMessage.h"
|
---|
| 20 |
|
---|
| 21 | using std::vector;
|
---|
| 22 | using std::map;
|
---|
| 23 | using std::cout;
|
---|
| 24 | using ariba::application::pingpong::PingPongMessage;
|
---|
| 25 | using ariba::interface::ServiceInterface;
|
---|
| 26 | using ariba::interface::UnderlayAbstraction;
|
---|
| 27 | using ariba::interface::AribaContext;
|
---|
| 28 | using ariba::utility::NodeID;
|
---|
| 29 | using ariba::utility::LinkID;
|
---|
| 30 | using ariba::utility::StartupInterface;
|
---|
| 31 | using ariba::utility::Timer;
|
---|
| 32 | using ariba::utility::Configuration;
|
---|
| 33 | using ariba::utility::NodeID;
|
---|
| 34 | using ariba::utility::Identifier;
|
---|
| 35 | using ariba::utility::ServiceID;
|
---|
| 36 | using ariba::utility::PathloadMeasurement;
|
---|
| 37 | using ariba::utility::PathloadMeasurementListener;
|
---|
| 38 |
|
---|
| 39 | namespace ariba {
|
---|
| 40 | namespace appplication {
|
---|
| 41 | namespace pingpong {
|
---|
| 42 |
|
---|
| 43 | /**
|
---|
| 44 | /* The PingPong main class
|
---|
| 45 | /* This class implements an example service for demonstration purposes
|
---|
| 46 | /* The pingpong class sends and receives messages between two SpoVNet
|
---|
| 47 | /* instances
|
---|
| 48 | **/
|
---|
| 49 | class PingPong :
|
---|
| 50 | public ServiceInterface,
|
---|
| 51 | public StartupInterface,
|
---|
| 52 | public Timer,
|
---|
| 53 | public PathloadMeasurementListener {
|
---|
| 54 |
|
---|
| 55 | use_logging_h(PingPong);
|
---|
| 56 |
|
---|
| 57 | public:
|
---|
| 58 | PingPong();
|
---|
| 59 | virtual ~PingPong();
|
---|
| 60 | void setMode( bool startingNode );
|
---|
| 61 |
|
---|
| 62 |
|
---|
| 63 | virtual void onOverlayCreate( const SpoVNetID& id );
|
---|
| 64 | virtual void onOverlayDestroy( const SpoVNetID& id );
|
---|
| 65 | virtual bool isJoinAllowed( const NodeID& nodeid, const SpoVNetID& spovnetid );
|
---|
| 66 | virtual void onNodeJoin( const NodeID& nodeid, const SpoVNetID& spovnetid );
|
---|
| 67 | virtual void onNodeLeave( const NodeID& id, const SpoVNetID& spovnetid );
|
---|
| 68 | virtual void onJoinSuccess( const SpoVNetID& spovnetid );
|
---|
| 69 | virtual void onJoinFail( const SpoVNetID& spovnetid );
|
---|
| 70 | virtual void onLinkUp( const LinkID& link, const NodeID& local, const NodeID& remote );
|
---|
| 71 | virtual void onLinkDown( const LinkID& link, const NodeID& local, const NodeID& remote );
|
---|
| 72 | virtual void onLinkChanged( const LinkID& link, const NodeID& local, const NodeID& remote );
|
---|
| 73 | virtual void onLinkFail(const LinkID& id, const NodeID& local, const NodeID& remote);
|
---|
| 74 | virtual void onLinkQoSChanged(const LinkID& id, const NodeID& local, const NodeID& remote , const QoSParameterSet& qos);
|
---|
| 75 |
|
---|
| 76 | virtual bool receiveMessage( const Message* message, const LinkID& link, const NodeID& node );
|
---|
| 77 |
|
---|
| 78 | protected:
|
---|
| 79 | virtual void startup();
|
---|
| 80 | virtual void shutdown();
|
---|
| 81 |
|
---|
| 82 | virtual void eventFunction(); // timer event function
|
---|
| 83 | virtual void onMeasurement(NodeID node, double mbps); // measurement event function
|
---|
| 84 |
|
---|
| 85 | private:
|
---|
| 86 | bool startping;
|
---|
| 87 | UnderlayAbstraction* abstraction;
|
---|
| 88 | AribaContext* context;
|
---|
| 89 | BaseOverlay* overlay;
|
---|
| 90 | static ServiceID PINGPONG_ID;
|
---|
| 91 | unsigned long pingid;
|
---|
| 92 | typedef map<NodeID, LinkID> RemoteNodes;
|
---|
| 93 | RemoteNodes remoteNodes;
|
---|
| 94 | };
|
---|
| 95 |
|
---|
| 96 | ARIBA_SIMULATION_SERVICE(PingPong);
|
---|
| 97 |
|
---|
| 98 | }}} // namespace ariba, appplication, pingpong
|
---|
| 99 |
|
---|
| 100 | #endif // __PINGPONG_H_
|
---|