Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ef07cb4d4f1b458279ae0cfa168583aa7fcc923b
[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 NetworkWifiLink : public LinkImpl {
23   /** @brief Hold every rates association between host and links (host name, rates id) */
24   std::map<xbt::string, int> host_rates_;
25
26   /** @brief A link can have several bandwith attach to it (mostly use by wifi model) */
27   std::vector<Metric> bandwidths_;
28
29   /** @brief Should we use the decay model ? */
30   bool use_decay_model_=false;
31   /** @brief Wifi ns-3 802.11n average bit rate */
32   const double wifi_max_rate_=54*1e6 / 8;
33   /** @brief ns-3 802.11n minimum bit rate */
34   const double wifi_min_rate_=41.70837*1e6 / 8;
35   /** @brief Decay model calibration */
36   const int model_n_=5;
37   /** @brief Decay model calibration: bitrate when using model_n_ stations */
38   const double model_rate_=42.61438*1e6 / 8;
39   /** @brief Decay model bandwidths */
40   std::vector<Metric> decay_bandwidths_;
41
42 public:
43   NetworkWifiLink(NetworkCm02Model* model, const std::string& name, std::vector<double> bandwidths,
44                   lmm::System* system);
45
46   void set_host_rate(const s4u::Host* host, int rate_level);
47   /** @brief Get the AP rate associated to the host (or -1 if not associated to the AP) */
48   double get_host_rate(const s4u::Host* host);
49
50   s4u::Link::SharingPolicy get_sharing_policy() override;
51   void apply_event(kernel::profile::Event*, double) override { THROW_UNIMPLEMENTED; }
52   void set_bandwidth(double) override { THROW_UNIMPLEMENTED; }
53   void set_latency(double) override { THROW_UNIMPLEMENTED; }
54   void refresh_decay_bandwidths();
55   bool toggle_decay_model();
56 };
57
58 } // namespace resource
59 } // namespace kernel
60 } // namespace simgrid
61 #endif /* SURF_NETWORK_WIFI_HPP_ */