Ignore:
Timestamp:
Jul 21, 2009, 1:54:55 PM (15 years ago)
Author:
Christoph Mayer
Message:

begin merge back from relay branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sample/pingpong/PingPong.cpp

    r4948 r5151  
    1717// construction
    1818PingPong::PingPong() : pingId( 0 ) {
    19         Timer::setInterval( 5000 );
     19        Timer::setInterval( 1000 );
    2020}
    2121
     
    4141        // get initiator flag
    4242        this->isInitiator = Configuration::instance().read<bool>("node.initiator");
     43
     44        this->name = string("<ping>");
    4345
    4446        // get node name
     
    5557        if (config.exists("ariba.bootstrap.hints")) ariba->setProperty("bootstrap.hints",
    5658                        config.read<string>("ariba.bootstrap.hints"));
     59        if (config.exists("pingpong.name")) name =
     60                        config.read<string>("pingpong.name");
    5761
    5862        // start ariba module
     
    7175        // when initiating, you can define the overlay type, default is Chord [CHORD_OVERLAY]
    7276        SpoVNetProperties params;
    73         params.setBaseOverlayType( SpoVNetProperties::ONE_HOP_OVERLAY ); // alternative: OneHop
     77        //params.setBaseOverlayType( SpoVNetProperties::ONE_HOP_OVERLAY ); // alternative: OneHop
    7478
    7579        // initiate or join the spovnet
     
    122126        // function that is implemented further down in PingPong::onLinkUp
    123127
    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 );
    127131
    128132        //-----------------------------------------------------------------------
    129133        // Option 1: get all neighboring nodes and send the message to each
    130134        //-----------------------------------------------------------------------
     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        }
    131146        vector<NodeID> nodes = node->getNeighborNodes();
    132147        BOOST_FOREACH( NodeID nid, nodes ){
     
    162177void PingPong::onMessage(const DataMessage& msg, const NodeID& remote, const LinkID& lnk) {
    163178        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() );
    168185}
    169186
Note: See TracChangeset for help on using the changeset viewer.