Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make model name constant
[simgrid.git] / src / surf / network_ns3.hpp
1 /* Copyright (c) 2004-2021. 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   explicit NetworkNS3Model(std::string name);
20   LinkImpl* create_link(const std::string& name, const std::vector<double>& bandwidth,
21                         s4u::Link::SharingPolicy policy) override;
22   Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;
23   double next_occurring_event(double now) override;
24   bool next_occurring_event_is_idempotent() 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(const std::string& name, double bandwidth, s4u::Link::SharingPolicy policy);
34   ~LinkNS3() override;
35   s4u::Link::SharingPolicy sharing_policy_;
36
37   void apply_event(profile::Event* event, double value) override;
38   void set_bandwidth(double) override { THROW_UNIMPLEMENTED; }
39   LinkImpl* set_latency(double) override;
40   void set_bandwidth_profile(profile::Profile* profile) override;
41   void set_latency_profile(profile::Profile* profile) override;
42   s4u::Link::SharingPolicy get_sharing_policy() const override { return sharing_policy_; }
43 };
44
45 /**********
46  * Action *
47  **********/
48 class XBT_PRIVATE NetworkNS3Action : public NetworkAction {
49 public:
50   NetworkNS3Action(Model* model, double cost, s4u::Host* src, s4u::Host* dst);
51
52   void suspend() override;
53   void resume() override;
54   std::list<LinkImpl*> get_links() const override;
55   void update_remains_lazy(double now) override;
56
57   // private:
58   double last_sent_ = 0;
59 };
60
61 } // namespace resource
62 } // namespace kernel
63 } // namespace simgrid
64
65 #endif /* NETWORK_NS3_HPP_ */