1 /* Copyright (c) 2004-2023. The SimGrid Team. All rights reserved. */
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. */
6 #ifndef NETWORK_NS3_HPP_
7 #define NETWORK_NS3_HPP_
12 #include "src/kernel/resource/NetworkModel.hpp"
13 #include "src/kernel/resource/StandardLinkImpl.hpp"
15 namespace simgrid ::kernel::resource {
17 class NetworkNS3Model : public NetworkModel {
19 explicit NetworkNS3Model(const std::string& name);
20 ~NetworkNS3Model() override;
21 StandardLinkImpl* create_link(const std::string& name, const std::vector<double>& bandwidth) override;
22 StandardLinkImpl* create_wifi_link(const std::string& name, const std::vector<double>& bandwidth) override;
23 Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate, bool streamed) 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;
32 class LinkNS3 : public StandardLinkImpl {
34 explicit LinkNS3(const std::string& name, double bandwidth);
36 s4u::Link::SharingPolicy sharing_policy_ = s4u::Link::SharingPolicy::SHARED;
38 void apply_event(profile::Event* event, double value) override;
39 void set_bandwidth(double) override { THROW_UNIMPLEMENTED; }
40 void set_latency(double) override;
41 void set_bandwidth_profile(profile::Profile* profile) override;
42 void set_latency_profile(profile::Profile* profile) override;
43 void set_sharing_policy(s4u::Link::SharingPolicy policy, const s4u::NonLinearResourceCb& cb) override;
44 s4u::Link::SharingPolicy get_sharing_policy() const override { return sharing_policy_; }
50 class XBT_PRIVATE NetworkNS3Action : public NetworkAction {
52 NetworkNS3Action(Model* model, double cost, s4u::Host* src, s4u::Host* dst);
54 void suspend() override;
55 void resume() override;
56 std::list<StandardLinkImpl*> get_links() const override;
57 void update_remains_lazy(double now) override;
60 double last_sent_ = 0;
63 } // namespace simgrid::kernel::resource
65 #endif /* NETWORK_NS3_HPP_ */