Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Save the src_wifi_link and dst_wifi_link in a subclass of NetCm02Action
[simgrid.git] / src / surf / network_wifi.hpp
1 /* Copyright (c) 2019-2020. 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 SURF_NETWORK_WIFI_HPP_
7 #define SURF_NETWORK_WIFI_HPP_
8
9 #include <xbt/base.h>
10
11 #include "network_cm02.hpp"
12 #include "xbt/string.hpp"
13
14 /***********
15  * Classes *
16  ***********/
17
18 namespace simgrid {
19 namespace kernel {
20 namespace resource {
21
22 class XBT_PRIVATE NetworkWifiAction;
23
24 class NetworkWifiLink : public LinkImpl {
25   /** @brief Hold every rates association between host and links (host name, rates id) */
26   std::map<xbt::string, int> host_rates_;
27
28   /** @brief A link can have several bandwith attach to it (mostly use by wifi model) */
29   std::vector<Metric> bandwidths_;
30
31   /** @brief Should we use the decay model ? */
32   bool use_decay_model_=false;
33   /** @brief Wifi ns-3 802.11n average bit rate */
34   const double wifi_max_rate_=54*1e6 / 8;
35   /** @brief ns-3 802.11n minimum bit rate */
36   const double wifi_min_rate_=41.70837*1e6 / 8;
37   /** @brief Decay model calibration */
38   const int model_n_=5;
39   /** @brief Decay model calibration: bitrate when using model_n_ stations */
40   const double model_rate_=42.61438*1e6 / 8;
41   /** @brief Decay model bandwidths */
42   std::vector<Metric> decay_bandwidths_;
43
44 public:
45   NetworkWifiLink(NetworkCm02Model* model, const std::string& name, std::vector<double> bandwidths,
46                   lmm::System* system);
47
48   void set_host_rate(const s4u::Host* host, int rate_level);
49   /** @brief Get the AP rate associated to the host (or -1 if not associated to the AP) */
50   double get_host_rate(const s4u::Host* host);
51
52   s4u::Link::SharingPolicy get_sharing_policy() override;
53   void apply_event(kernel::profile::Event*, double) override { THROW_UNIMPLEMENTED; }
54   void set_bandwidth(double) override { THROW_UNIMPLEMENTED; }
55   void set_latency(double) override { THROW_UNIMPLEMENTED; }
56   void refresh_decay_bandwidths();
57   bool toggle_decay_model();
58 };
59
60 class NetworkWifiAction : public NetworkCm02Action {
61   NetworkWifiLink* src_wifi_link_;
62   NetworkWifiLink* dst_wifi_link_;
63
64 public:
65   NetworkWifiAction(Model* model, s4u::Host& src, s4u::Host& dst, double cost, bool failed,
66                     NetworkWifiLink* src_wifi_link, NetworkWifiLink* dst_wifi_link)
67       : NetworkCm02Action(model, src, dst, cost, failed)
68       , src_wifi_link_(src_wifi_link)
69       , dst_wifi_link_(dst_wifi_link){};
70
71   NetworkWifiLink* get_src_link() { return src_wifi_link_; }
72   NetworkWifiLink* get_dst_link() { return dst_wifi_link_; }
73 };
74
75 } // namespace resource
76 } // namespace kernel
77 } // namespace simgrid
78 #endif /* SURF_NETWORK_WIFI_HPP_ */