Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Sonar variety
[simgrid.git] / src / surf / network_wifi.hpp
1 /* Copyright (c) 2019-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 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 bandwidths attached 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 maximal bit rate according to the ns-3 802.11n standard */
34   const double wifi_max_rate_ = 54 * 1e6 / 8;
35   /** @brief minimum bit rate observed with ns3 during our calibration experiments */
36   const double wifi_min_rate_ = 41.70837 * 1e6 / 8;
37   /** @brief Amount of stations used in the reference point to rescale SimGrid predictions to fit ns-3 ones */
38   const int model_n_=5;
39   /** @brief Bit rate observed on ns3 at the reference point used for rescaling */
40   const double model_rate_=42.61438*1e6 / 8;
41   /** @brief The bandwidth to use for each SNR level, corrected with the decay rescale mechanism */
42   std::vector<Metric> decay_bandwidths_;
43
44 public:
45   NetworkWifiLink(const std::string& name, const std::vector<double>& bandwidths, lmm::System* system);
46
47   void set_host_rate(const s4u::Host* host, int rate_level);
48   /** @brief Get the AP rate associated to the host (or -1 if not associated to the AP) */
49   double get_host_rate(const s4u::Host* host) const;
50
51   s4u::Link::SharingPolicy get_sharing_policy() const override;
52   void apply_event(kernel::profile::Event*, double) override { THROW_UNIMPLEMENTED; }
53   void set_bandwidth(double) override { THROW_UNIMPLEMENTED; }
54   void set_latency(double) override;
55   void refresh_decay_bandwidths();
56   bool toggle_decay_model();
57   int get_host_count() const;
58 };
59
60 class NetworkWifiAction : public NetworkCm02Action {
61   NetworkWifiLink* src_wifi_link_;
62   NetworkWifiLink* dst_wifi_link_;
63
64 public:
65   NetworkWifiAction() = delete;
66   NetworkWifiAction(Model* model, s4u::Host& src, s4u::Host& dst, double cost, bool failed,
67                     NetworkWifiLink* src_wifi_link, NetworkWifiLink* dst_wifi_link)
68       : NetworkCm02Action(model, src, dst, cost, failed)
69       , src_wifi_link_(src_wifi_link)
70       , dst_wifi_link_(dst_wifi_link)
71     {}
72
73   NetworkWifiLink* get_src_link() const { return src_wifi_link_; }
74   NetworkWifiLink* get_dst_link() const { return dst_wifi_link_; }
75 };
76
77 } // namespace resource
78 } // namespace kernel
79 } // namespace simgrid
80 #endif /* SURF_NETWORK_WIFI_HPP_ */