+NetworkCm02Action* NetworkCm02Model::comm_action_create(s4u::Host* src, s4u::Host* dst, double size,
+ const std::vector<StandardLinkImpl*>& route, bool failed)
+{
+ WifiLinkImpl* src_wifi_link = nullptr;
+ WifiLinkImpl* dst_wifi_link = nullptr;
+ /* many checks related to Wi-Fi links */
+ if (not route.empty() && route.front()->get_sharing_policy() == s4u::Link::SharingPolicy::WIFI) {
+ src_wifi_link = static_cast<WifiLinkImpl*>(route.front());
+ xbt_assert(src_wifi_link->get_host_rate(src) != -1,
+ "The route from %s to %s begins with the WIFI link %s, but the host %s does not seem attached to that "
+ "WIFI link. Did you call link->set_host_rate()?",
+ src->get_cname(), dst->get_cname(), src_wifi_link->get_cname(), src->get_cname());
+ }
+ if (route.size() > 1 && route.back()->get_sharing_policy() == s4u::Link::SharingPolicy::WIFI) {
+ dst_wifi_link = static_cast<WifiLinkImpl*>(route.back());
+ xbt_assert(dst_wifi_link->get_host_rate(dst) != -1,
+ "The route from %s to %s ends with the WIFI link %s, but the host %s does not seem attached to that "
+ "WIFI link. Did you call link->set_host_rate()?",
+ src->get_cname(), dst->get_cname(), dst_wifi_link->get_cname(), dst->get_cname());
+ }
+ if (route.size() > 2)
+ for (unsigned i = 1; i < route.size() - 1; i++)
+ xbt_assert(route[i]->get_sharing_policy() != s4u::Link::SharingPolicy::WIFI,
+ "Link '%s' is a WIFI link. It can only be at the beginning or the end of the route from '%s' to '%s', "
+ "not in between (it is at position %u out of %zu). "
+ "Did you declare an access_point in your WIFI zones?",
+ route[i]->get_cname(), src->get_cname(), dst->get_cname(), i + 1, route.size());
+
+ for (auto const* link : route) {
+ if (link->get_sharing_policy() == s4u::Link::SharingPolicy::WIFI) {
+ xbt_assert(link == src_wifi_link || link == dst_wifi_link,
+ "Wifi links can only occur at the beginning of the route (meaning that it's attached to the src) or "
+ "at its end (meaning that it's attached to the dst");
+ }
+ }
+
+ /* create action and do some initializations */
+ NetworkCm02Action* action;
+ if (src_wifi_link == nullptr && dst_wifi_link == nullptr)
+ action = new NetworkCm02Action(this, *src, *dst, size, failed);
+ else
+ action = new WifiLinkAction(this, *src, *dst, size, failed, src_wifi_link, dst_wifi_link);