From: Martin Quinson Date: Sun, 20 Mar 2016 22:45:39 +0000 (+0100) Subject: kill some dead code in NS3 X-Git-Tag: v3_13~361 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/b969c14b66a498dbe7562cec4fbc5747b2d988d7 kill some dead code in NS3 --- diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index d3f0405fda..2624c3e60d 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -4,6 +4,8 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ +#include "ns3/core-module.h" + #include "src/surf/network_ns3.hpp" #include "src/surf/HostImpl.hpp" @@ -288,11 +290,11 @@ double NetworkNS3Model::next_occuring_event(double now) else do { ns3_simulator(now); - time_to_next_flow_completion = ns3_time() - surf_get_clock();//FIXME: use now instead ? + time_to_next_flow_completion = ns3::Simulator::Now().GetSeconds() - surf_get_clock();//FIXME: use now instead ? } while(double_equals(time_to_next_flow_completion, 0, sg_surf_precision)); XBT_DEBUG("min : %f", now); - XBT_DEBUG("ns3 time : %f", ns3_time()); + XBT_DEBUG("ns3 time : %f", ns3::Simulator::Now().GetSeconds()); XBT_DEBUG("surf time : %f", surf_get_clock()); XBT_DEBUG("Next completion %f :", time_to_next_flow_completion); @@ -310,8 +312,8 @@ void NetworkNS3Model::updateActionsState(double now, double delta) /* If there are no running flows, just return */ if (!getRunningActionSet()->size()) { - while(double_positive(now-ns3_time(), sg_surf_precision)) { - ns3_simulator(now-ns3_time()); + while(double_positive(now-ns3::Simulator::Now().GetSeconds(), sg_surf_precision)) { + ns3_simulator(now-ns3::Simulator::Now().GetSeconds()); } return; } diff --git a/src/surf/ns3/my-point-to-point-helper.cc b/src/surf/ns3/my-point-to-point-helper.cc index 7ac53db2b9..3e8c62bc5d 100644 --- a/src/surf/ns3/my-point-to-point-helper.cc +++ b/src/surf/ns3/my-point-to-point-helper.cc @@ -43,53 +43,6 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(ns3); -///> RED Parameters see src/node/red-queue.* for details -//.AddAttribute ("Mode", -// "Whether to use Bytes (see MaxBytes) or Packets (see MaxPackets) as the maximum queue size metric.", -// EnumValue (BYTES), ///> currently supports BYTES only -// MakeEnumAccessor (&RedQueue::SetMode), -// MakeEnumChecker (BYTES, "Bytes", -// PACKETS, "Packets")) -// .AddAttribute ("MaxPackets", -// "The maximum number of packets accepted by this RedQueue.", -// UintegerValue (100), -// MakeUintegerAccessor (&RedQueue::m_maxPackets), -// MakeUintegerChecker ()) -// .AddAttribute ("MaxBytes", -// "The maximum number of bytes accepted by this RedQueue.", -// UintegerValue (100000), -// MakeUintegerAccessor (&RedQueue::m_maxBytes), -// MakeUintegerChecker ()) -// .AddAttribute ("m_burst", -// "maximum number of m_burst packets accepted by this queue", -// UintegerValue (6), ///> bursts must be > minTh/avpkt -// MakeUintegerAccessor (&RedQueue::m_burst), -// MakeUintegerChecker ()) -// .AddAttribute ("m_avPkt", -// "In bytes, use with m_burst to determine the time constant for average queue size calculations", -// UintegerValue (1024), ///> average packet size -// MakeUintegerAccessor (&RedQueue::m_avPkt), -// MakeUintegerChecker ()) -// .AddAttribute ("m_minTh", -// "Average queue size at which marking becomes a m_prob", -// UintegerValue (5120), ///> in bytes 1024x5 -// MakeUintegerAccessor (&RedQueue::m_minTh), -// MakeUintegerChecker ()) -// .AddAttribute ("m_maxTh", -// "Maximal marking m_prob, should be at least twice min to prevent synchronous retransmits", -// UintegerValue (15360), ///> in bytes 1024x15 -// MakeUintegerAccessor (&RedQueue::m_maxTh), -// MakeUintegerChecker ()) -// .AddAttribute ("m_rate", -// "this m_rate is used for calculating the average queue size after some idle time.", -// UintegerValue (1500000), ///> in bps, should be set to bandwidth of interface -// MakeUintegerAccessor (&RedQueue::m_rate), -// MakeUintegerChecker ()) -// .AddAttribute ("m_prob", -// "Probability for marking, suggested values are 0.01 and 0.02", -// DoubleValue (0.02), -// MakeDoubleAccessor (&RedQueue::m_prob), -// MakeDoubleChecker ()) std::string qMode = "Bytes"; std::string qBurst = "6"; std::string qAvPkt = "1024"; @@ -105,14 +58,6 @@ MyPointToPointHelper::MyPointToPointHelper () { m_queueFactory.SetTypeId ("ns3::DropTailQueue"); m_queueFactory_red.SetTypeId ("ns3::RedQueue"); -// m_queueFactory_red.Set ("Mode", StringValue (qMode)); -// m_queueFactory_red.Set ("MaxBytes",StringValue (qLimit)); -// m_queueFactory_red.Set ("m_burst", StringValue (qBurst)); -// m_queueFactory_red.Set ("m_avPkt", StringValue (qAvPkt)); -// m_queueFactory_red.Set ("m_minTh", StringValue (qthMin)); -// m_queueFactory_red.Set ("m_maxTh", StringValue (qthMax)); -// m_queueFactory_red.Set ("m_rate", StringValue (qIdleRate)); -// m_queueFactory_red.Set ("m_prob", StringValue (qProb)); m_deviceFactory.SetTypeId ("ns3::PointToPointNetDevice"); m_channelFactory.SetTypeId ("ns3::PointToPointChannel"); m_remoteChannelFactory.SetTypeId ("ns3::PointToPointRemoteChannel"); @@ -340,9 +285,7 @@ MyPointToPointHelper::Install (Ptr a, e_ns3_network_element_type_t type_a, uint32_t n2SystemId = b->GetSystemId (); uint32_t currSystemId = MpiInterface::GetSystemId (); if (n1SystemId != currSystemId || n2SystemId != currSystemId) - { useNormalChannel = false; - } } if (useNormalChannel) { @@ -393,9 +336,7 @@ MyPointToPointHelper::Install (Ptr a, Ptr b) uint32_t n2SystemId = b->GetSystemId (); uint32_t currSystemId = MpiInterface::GetSystemId (); if (n1SystemId != currSystemId || n2SystemId != currSystemId) - { useNormalChannel = false; - } } if (useNormalChannel) { diff --git a/src/surf/ns3/ns3_interface.cc b/src/surf/ns3/ns3_interface.cc index 4507c9d811..95ca5f8216 100644 --- a/src/surf/ns3/ns3_interface.cc +++ b/src/surf/ns3/ns3_interface.cc @@ -37,23 +37,19 @@ void ns3_simulator(double min){ } void* ns3_get_socket_action(void *socket){ - return ns3_sim->get_action_from_socket(socket); + return ((MySocket *)socket)->action; } double ns3_get_socket_remains(void *socket){ - return ns3_sim->get_remains_from_socket(socket); + return ((MySocket *)socket)->remaining; } double ns3_get_socket_sent(void *socket){ - return ns3_sim->get_sent_from_socket(socket); + return ((MySocket *)socket)->sentBytes; } char ns3_get_socket_is_finished(void *socket){ - return ns3_sim->get_finished(socket); -} - -double ns3_time(){ - return Simulator::Now().GetSeconds(); + return ((MySocket *)socket)->finished; } int ns3_create_flow(const char* a,const char *b,double start,u_int32_t TotalBytes,void * action) diff --git a/src/surf/ns3/ns3_interface.h b/src/surf/ns3/ns3_interface.h index cc92d4871c..1fc6d22048 100644 --- a/src/surf/ns3/ns3_interface.h +++ b/src/surf/ns3/ns3_interface.h @@ -38,7 +38,6 @@ XBT_PUBLIC(int) ns3_finalize(void); XBT_PUBLIC(int) ns3_initialize(const char* TcpProtocol); XBT_PUBLIC(int) ns3_create_flow(const char* a,const char *b,double start,u_int32_t TotalBytes,void * action); XBT_PUBLIC(void) ns3_simulator(double min); -XBT_PUBLIC(double) ns3_time(void); XBT_PUBLIC(void*) ns3_get_socket_action(void *socket); XBT_PUBLIC(double) ns3_get_socket_remains(void *socket); XBT_PUBLIC(double) ns3_get_socket_sent(void *socket); diff --git a/src/surf/ns3/ns3_simulator.cc b/src/surf/ns3/ns3_simulator.cc index ccb10d6d71..df043f241c 100644 --- a/src/surf/ns3/ns3_simulator.cc +++ b/src/surf/ns3/ns3_simulator.cc @@ -20,20 +20,17 @@ static char socket_key[24]; static void receive_callback(Ptr localSocket); static void send_callback(Ptr localSocket, uint32_t txSpace); static void datasent_callback(Ptr localSocket, uint32_t dataSent); -static void StartFlow(Ptr sock, - const char *to, - uint16_t port_number); +static void StartFlow(Ptr sock, const char *to, uint16_t port_number); XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(ns3); -// Constructor. NS3Sim::NS3Sim(){ } -//Destructor. NS3Sim::~NS3Sim(){ } -static inline void transformSocketPtr (Ptr localSocket){ +static inline void transformSocketPtr (Ptr localSocket) +{ std::stringstream sstream; sstream << localSocket ; std::string s = sstream.str(); @@ -47,7 +44,7 @@ static void delete_mysocket(void *p) } /* - * This function create a flow from src to dst + * This function creates a flow from src to dst * * Parameters * src: node source @@ -66,15 +63,15 @@ void NS3Sim::create_flow_NS3( uint32_t totalBytes, void * action) { - if(!dict_socket) dict_socket = xbt_dict_new_homogeneous(delete_mysocket); + if(!dict_socket) + dict_socket = xbt_dict_new_homogeneous(delete_mysocket); PacketSinkHelper sink ("ns3::TcpSocketFactory", InetSocketAddress (Ipv4Address::GetAny(), port_number)); sink.Install (dst); - Ptr sock = Socket::CreateSocket (src, - TcpSocketFactory::GetTypeId()); + Ptr sock = Socket::CreateSocket (src, TcpSocketFactory::GetTypeId()); MySocket *mysocket = new MySocket(); mysocket->totalBytes = totalBytes; @@ -88,27 +85,9 @@ void NS3Sim::create_flow_NS3( xbt_dict_set(dict_socket,socket_key, mysocket,NULL); sock->Bind(InetSocketAddress(port_number)); - XBT_DEBUG("Create flow starting to %fs + %fs = %fs",start-ns3_time(), ns3_time(), start); - - Simulator::Schedule (Seconds(start-ns3_time()),&StartFlow, sock, addr, port_number); -// Simulator::Schedule (Seconds(0.0),&StartFlow, sock, addr, port_number); - -} - -void* NS3Sim::get_action_from_socket(void *socket){ - return ((MySocket *)socket)->action; -} + XBT_DEBUG("Create flow starting to %fs + %fs = %fs",start-ns3::Simulator::Now().GetSeconds(), ns3::Simulator::Now().GetSeconds(), start); -char NS3Sim::get_finished(void *socket){ - return ((MySocket *)socket)->finished; -} - -double NS3Sim::get_remains_from_socket(void *socket){ - return ((MySocket *)socket)->remaining; -} - -double NS3Sim::get_sent_from_socket(void *socket){ - return ((MySocket *)socket)->sentBytes; + Simulator::Schedule (Seconds(start-ns3::Simulator::Now().GetSeconds()),&StartFlow, sock, addr, port_number); } void NS3Sim::simulator_start(double min){ @@ -139,7 +118,7 @@ static void send_callback(Ptr localSocket, uint32_t txSpace){ MySocket* mysocket = get_my_socket(localSocket); if (mysocket->remaining == 0){ - //all data was already buffered (and socket was already closed), just return + // all data was already buffered (and socket was already closed), just return return; } @@ -162,9 +141,8 @@ static void send_callback(Ptr localSocket, uint32_t txSpace){ free(data); - if ((mysocket->bufferedBytes) >= mysocket->totalBytes){ + if ((mysocket->bufferedBytes) >= mysocket->totalBytes) localSocket->Close(); - } } static void datasent_callback(Ptr localSocket, uint32_t dataSent){ @@ -196,9 +174,7 @@ static void failedConnect_callback(Ptr localSocket){ xbt_die("NS3: a socket failed to connect"); } -static void StartFlow(Ptr sock, - const char *to, - uint16_t port_number) +static void StartFlow(Ptr sock, const char *to, uint16_t port_number) { InetSocketAddress serverAddr (to, port_number); diff --git a/src/surf/ns3/ns3_simulator.h b/src/surf/ns3/ns3_simulator.h index 740c7e1e7e..73e2305670 100644 --- a/src/surf/ns3/ns3_simulator.h +++ b/src/surf/ns3/ns3_simulator.h @@ -49,10 +49,6 @@ public: std::uint32_t TotalBytes, void * action); void simulator_start(double min); - void* get_action_from_socket(void *socket); - double get_remains_from_socket(void *socket); - double get_sent_from_socket(void *socket); - char get_finished(void *socket); }; #endif /* __cplusplus */