Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
c007c2592d4a593344830507fd0176f2a43881a2
[simgrid.git] / src / surf / ns3 / ns3_simulator.hpp
1 /* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #ifndef NS3_SIMULATOR_HPP
7 #define NS3_SIMULATOR_HPP
8
9 #include <cstdint>
10
11 #include "ns3_interface.hpp"
12
13 #include <ns3/csma-helper.h>
14 #include <ns3/global-route-manager.h>
15 #include <ns3/internet-stack-helper.h>
16 #include <ns3/ipv4-address-helper.h>
17 #include <ns3/packet-sink-helper.h>
18 #include <ns3/point-to-point-helper.h>
19 #include <ns3/tcp-socket-factory.h>
20
21 class SgFlow {
22 public:
23   SgFlow(uint32_t totalBytes, simgrid::surf::NetworkNS3Action* action);
24
25   // private:
26   std::uint32_t bufferedBytes_ = 0;
27   std::uint32_t sentBytes_     = 0;
28   std::uint32_t remaining_;
29   std::uint32_t totalBytes_;
30   bool finished_ = false;
31   simgrid::surf::NetworkNS3Action* action_;
32 };
33
34 void StartFlow(ns3::Ptr<ns3::Socket> sock, const char* to, uint16_t port_number);
35
36 static inline const char* transformSocketPtr(ns3::Ptr<ns3::Socket> localSocket)
37 {
38   static char key[24];
39   std::stringstream sstream;
40   sstream << localSocket;
41   snprintf(key, 24, "%s", sstream.str().c_str());
42
43   return key;
44 }
45
46 #endif