1 /* Copyright (c) 2019-2020. 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 SURF_NETWORK_WIFI_HPP_
7 #define SURF_NETWORK_WIFI_HPP_
11 #include "network_cm02.hpp"
12 #include "xbt/string.hpp"
22 class XBT_PRIVATE NetworkWifiAction;
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_;
28 /** @brief A link can have several bandwith attach to it (mostly use by wifi model) */
29 std::vector<Metric> bandwidths_;
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 */
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_;
45 NetworkWifiLink(NetworkCm02Model* model, const std::string& name, std::vector<double> bandwidths,
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);
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();
60 class NetworkWifiAction : public NetworkCm02Action {
61 NetworkWifiLink* src_wifi_link_;
62 NetworkWifiLink* dst_wifi_link_;
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){};
71 NetworkWifiLink* get_src_link() { return src_wifi_link_; }
72 NetworkWifiLink* get_dst_link() { return dst_wifi_link_; }
75 } // namespace resource
77 } // namespace simgrid
78 #endif /* SURF_NETWORK_WIFI_HPP_ */