Logo AND Algorithmique Numérique Distribuée

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