source: trash/pingpong/PingPong.h@ 5860

Last change on this file since 5860 was 5860, checked in by Christoph Mayer, 15 years ago

networkinfo fix wenn socket kaputt geht, erfolgreich verwendete bootstrap infos speichern und wenn overlay verbindungen alle weg sind diese infos ausprobieren

File size: 3.3 KB
Line 
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
21using std::vector;
22using std::map;
23using std::cout;
24using ariba::application::pingpong::PingPongMessage;
25using ariba::interface::ServiceInterface;
26using ariba::interface::UnderlayAbstraction;
27using ariba::interface::AribaContext;
28using ariba::utility::NodeID;
29using ariba::utility::LinkID;
30using ariba::utility::StartupInterface;
31using ariba::utility::Timer;
32using ariba::utility::Configuration;
33using ariba::utility::NodeID;
34using ariba::utility::Identifier;
35using ariba::utility::ServiceID;
36using ariba::utility::PathloadMeasurement;
37using ariba::utility::PathloadMeasurementListener;
38
39namespace ariba {
40namespace appplication {
41namespace 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**/
49class PingPong :
50 public ServiceInterface,
51 public StartupInterface,
52 public Timer,
53 public PathloadMeasurementListener {
54
55 use_logging_h(PingPong);
56
57public:
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
78protected:
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
85private:
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
96ARIBA_SIMULATION_SERVICE(PingPong);
97
98}}} // namespace ariba, appplication, pingpong
99
100#endif // __PINGPONG_H_
Note: See TracBrowser for help on using the repository browser.