From 36d71e3707463a389153fbf9cebd68ce4a5276a1 Mon Sep 17 00:00:00 2001 From: Lucas Schnorr Date: Wed, 7 Sep 2011 15:57:50 +0200 Subject: [PATCH] [NS3] rewriting receive_callback to mark a flow finished only if it has not done before --- src/surf/ns3/ns3_simulator.cc | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/surf/ns3/ns3_simulator.cc b/src/surf/ns3/ns3_simulator.cc index ccd323b37a..54d45c8476 100644 --- a/src/surf/ns3/ns3_simulator.cc +++ b/src/surf/ns3/ns3_simulator.cc @@ -102,21 +102,14 @@ void NS3Sim::simulator_start(void){ } static void receive_callback(Ptr localSocket){ - Address addr; - localSocket->GetSockName (addr); - InetSocketAddress iaddr = InetSocketAddress::ConvertFrom (addr); MySocket* mysocket = (MySocket*)xbt_dict_get_or_null(dict_socket,(char*)&localSocket); - mysocket->finished = 1; - - //cout << "[" << Simulator::Now ().GetSeconds() << "] " << "Received [" << mysocket->totalBytes << "bytes], from: " << iaddr.GetIpv4 () << " port: " << iaddr.GetPort () << endl; - std::stringstream sstream; - sstream << Simulator::Now ().GetSeconds(); - std::string s = sstream.str(); - size_t size = s.size() + 1; - char * time_sec = new char[ size ]; - strncpy( time_sec, s.c_str(), size ); - XBT_DEBUG("Stop simulator at %s seconds",time_sec); - Simulator::Stop(); + + if (mysocket->finished == 0){ + mysocket->finished = 1; +// cout << "[" << Simulator::Now ().GetSeconds() << "] " << "recv_cb of F[" << mysocket->totalBytes << "] " << endl; + XBT_DEBUG("Stop simulator at %f seconds", Simulator::Now().GetSeconds()); + Simulator::Stop(); + } } static void send_callback(Ptr localSocket, uint32_t txSpace){ -- 2.20.1