Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Define FairBottleneck and Lagrange as subclasses of lmm::System.
[simgrid.git] / src / surf / network_ns3.hpp
1 /* Copyright (c) 2004-2018. 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 NETWORK_NS3_HPP_
7 #define NETWORK_NS3_HPP_
8
9 #include "xbt/base.h"
10
11 #include "network_interface.hpp"
12
13 namespace simgrid {
14 namespace surf {
15
16 class NetworkNS3Model : public NetworkModel {
17 public:
18   NetworkNS3Model();
19   ~NetworkNS3Model();
20   LinkImpl* createLink(const std::string& name, double bandwidth, double latency,
21                        e_surf_link_sharing_policy_t policy) override;
22   kernel::resource::Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;
23   double next_occuring_event(double now) override;
24   bool nextOccuringEventIsIdempotent() override { return false; }
25   void update_actions_state(double now, double delta) override;
26 };
27
28 /************
29  * Resource *
30  ************/
31 class LinkNS3 : public LinkImpl {
32 public:
33   explicit LinkNS3(NetworkNS3Model* model, const std::string& name, double bandwidth, double latency);
34   ~LinkNS3();
35
36   void apply_event(tmgr_trace_event_t event, double value) override;
37   void setBandwidth(double value) override { THROW_UNIMPLEMENTED; }
38   void setLatency(double value) override { THROW_UNIMPLEMENTED; }
39   void setBandwidthTrace(tmgr_trace_t trace) override;
40   void setLatencyTrace(tmgr_trace_t trace) override;
41 };
42
43 /**********
44  * Action *
45  **********/
46 class XBT_PRIVATE NetworkNS3Action : public NetworkAction {
47 public:
48   NetworkNS3Action(kernel::resource::Model* model, double cost, s4u::Host* src, s4u::Host* dst);
49
50   void suspend() override;
51   void resume() override;
52   std::list<LinkImpl*> links() override;
53   void update_remains_lazy(double now) override;
54
55   // private:
56   double lastSent_ = 0;
57   s4u::Host* src_;
58   s4u::Host* dst_;
59 };
60
61 }
62 }
63
64 #endif /* NETWORK_NS3_HPP_ */