Logo AND Algorithmique Numérique Distribuée

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