Changeset 5151 for sample/pingpong/PingPong.cpp
- Timestamp:
- Jul 21, 2009, 1:54:55 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sample/pingpong/PingPong.cpp
r4948 r5151 17 17 // construction 18 18 PingPong::PingPong() : pingId( 0 ) { 19 Timer::setInterval( 5000 );19 Timer::setInterval( 1000 ); 20 20 } 21 21 … … 41 41 // get initiator flag 42 42 this->isInitiator = Configuration::instance().read<bool>("node.initiator"); 43 44 this->name = string("<ping>"); 43 45 44 46 // get node name … … 55 57 if (config.exists("ariba.bootstrap.hints")) ariba->setProperty("bootstrap.hints", 56 58 config.read<string>("ariba.bootstrap.hints")); 59 if (config.exists("pingpong.name")) name = 60 config.read<string>("pingpong.name"); 57 61 58 62 // start ariba module … … 71 75 // when initiating, you can define the overlay type, default is Chord [CHORD_OVERLAY] 72 76 SpoVNetProperties params; 73 params.setBaseOverlayType( SpoVNetProperties::ONE_HOP_OVERLAY ); // alternative: OneHop77 //params.setBaseOverlayType( SpoVNetProperties::ONE_HOP_OVERLAY ); // alternative: OneHop 74 78 75 79 // initiate or join the spovnet … … 122 126 // function that is implemented further down in PingPong::onLinkUp 123 127 124 logging_info( "pinging overlay neighbors with ping id " << ++pingId );125 126 PingPongMessage pingmsg( pingId );128 // logging_info( "pinging overlay neighbors with ping id " << ++pingId ); 129 130 PingPongMessage pingmsg( pingId, name ); 127 131 128 132 //----------------------------------------------------------------------- 129 133 // Option 1: get all neighboring nodes and send the message to each 130 134 //----------------------------------------------------------------------- 135 counter++; 136 if (counter<0 || counter>4) { 137 counter = 0; 138 string s; 139 for (int i=0; i<names.size();i++) { 140 if (i!=0) s+= ", "; 141 s = s+names[i]; 142 } 143 logging_info("----> I am " << name << " and I know " << s); 144 names.clear(); 145 } 131 146 vector<NodeID> nodes = node->getNeighborNodes(); 132 147 BOOST_FOREACH( NodeID nid, nodes ){ … … 162 177 void PingPong::onMessage(const DataMessage& msg, const NodeID& remote, const LinkID& lnk) { 163 178 PingPongMessage* pingmsg = msg.getMessage()->convert<PingPongMessage> (); 164 165 logging_info( "received ping message on link " << lnk.toString() 166 << " from node " << remote.toString() 167 << ": " << pingmsg->info() ); 179 bool found=false; 180 for (int i=0;i<names.size(); i++) if (names[i]==pingmsg->getName()) found=true; 181 if (!found) names.push_back(pingmsg->getName()); 182 // logging_info( "received ping message on link " << lnk.toString() 183 // << " from node " << remote.toString() 184 // << ": " << pingmsg->info() ); 168 185 } 169 186
Note:
See TracChangeset
for help on using the changeset viewer.