Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Inventive hack to get flex raising exceptions on parse error
[simgrid.git] / src / surf / network_ns3.hpp
1 /* Copyright (c) 2004-2019. 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 kernel {
15 namespace resource {
16
17 class NetworkNS3Model : public NetworkModel {
18 public:
19   NetworkNS3Model();
20   ~NetworkNS3Model();
21   LinkImpl* create_link(const std::string& name, const std::vector<double>& bandwidth, double latency,
22                         s4u::Link::SharingPolicy policy) override;
23   Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;
24   double next_occurring_event(double now) override;
25   bool next_occurring_event_is_idempotent() override { return false; }
26   void update_actions_state(double now, double delta) override;
27 };
28
29 /************
30  * Resource *
31  ************/
32 class LinkNS3 : public LinkImpl {
33 public:
34   explicit LinkNS3(NetworkNS3Model* model, const std::string& name, double bandwidth, double latency);
35   ~LinkNS3();
36
37   void apply_event(profile::Event* event, double value) override;
38   void set_bandwidth(double value) override { THROW_UNIMPLEMENTED; }
39   void set_latency(double value) override { THROW_UNIMPLEMENTED; }
40   void set_bandwidth_profile(profile::Profile* profile) override;
41   void set_latency_profile(profile::Profile* profile) override;
42 };
43
44 /**********
45  * Action *
46  **********/
47 class XBT_PRIVATE NetworkNS3Action : public NetworkAction {
48 public:
49   NetworkNS3Action(Model* model, double cost, s4u::Host* src, s4u::Host* dst);
50
51   void suspend() override;
52   void resume() override;
53   std::list<LinkImpl*> links() const override;
54   void update_remains_lazy(double now) override;
55
56   // private:
57   double last_sent_ = 0;
58   s4u::Host* src_;
59   s4u::Host* dst_;
60 };
61
62 } // namespace resource
63 } // namespace kernel
64 } // namespace simgrid
65
66 #endif /* NETWORK_NS3_HPP_ */