--- /dev/null
+/* Copyright (c) 2006-2021. The SimGrid Team. All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include <simgrid/s4u.hpp>
+namespace sg4 = simgrid::s4u;
+
+/**
+ * @brief Create a new cluster netzone inside the root netzone
+ *
+ * This function creates the cluster, adding the hosts and links properly.
+ *
+ * @param root Root netzone
+ * @param cluster_suffix ID of the cluster being created
+ * @param host List of hostname inside the cluster
+ * @param single_link_host Hostname of "special" node
+ */
+static void create_cluster(sg4::NetZone* root, const std::string& cluster_suffix, const std::vector<std::string>& hosts,
+ const std::string& single_link_host)
+{
+ auto* cluster = sg4::create_star_zone("cluster" + cluster_suffix);
+ cluster->set_parent(root);
+
+ /* create the backbone link */
+ sg4::Link* l_bb =
+ cluster->create_link("backbone" + cluster_suffix, std::vector<double>{2.25e9})->set_latency(5e-4)->seal();
+
+ /* create all hosts and connect them to outside world */
+ for (const auto& hostname : hosts) {
+ /* create host */
+ sg4::Host* host = cluster->create_host(hostname, std::vector<double>{1e9});
+ /* create UP link */
+ sg4::Link* l_up = cluster->create_link(hostname + "_up", std::vector<double>{1.25e8})->set_latency(0.0001)->seal();
+ /* create DOWN link, if needed */
+ sg4::Link* l_down = l_up;
+ if (hostname != single_link_host) {
+ l_down = cluster->create_link(hostname + "_down", std::vector<double>{1.25e8})->set_latency(0.0001)->seal();
+ }
+
+ /* add link UP and backbone for communications from the host */
+ cluster->add_route(host->get_netpoint(), nullptr, nullptr, nullptr, std::vector<sg4::Link*>{l_up, l_bb}, false);
+ /* add backbone and link DOWN for communications to the host */
+ cluster->add_route(nullptr, host->get_netpoint(), nullptr, nullptr, std::vector<sg4::Link*>{l_bb, l_down}, false);
+ }
+
+ /* create router */
+ cluster->create_router("router" + cluster_suffix);
+
+ cluster->seal();
+}
+
+/** @brief Programmatic version of routing_cluster.xml */
+extern "C" void load_platform(const sg4::Engine& e);
+void load_platform(const sg4::Engine& e)
+{
+ /**
+ *
+ * Target platform: 2 simular but irregular clusters.
+ * Nodes use full-duplex links to connect to the backbone, except one node that uses a single
+ * shared link.
+
+ * router1 - - - - - - link1-2 - - - - - - router2
+ * __________________________ _________________________
+ * | | | |
+ * | backbone1 | | backbone2 |
+ * |________________________| |________________________|
+ * / / | \ \ / / | \ \
+ *l1_up / / l1_down | l3 l2_up\ \ l2_down l4_up / / l4_down | l6 l5_up\ \ l5_down
+ * / / | \ \ / / | \ \
+ * host1 host3 host2 host4 host6 host5
+ */
+
+ auto* root = sg4::create_full_zone("AS0");
+
+ /* create left cluster */
+ create_cluster(root, "1", {"host1", "host2", "host3"}, "host3");
+ /* create right cluster */
+ create_cluster(root, "2", {"host4", "host5", "host6"}, "host6");
+
+ /* connect both cluster through their respective routers */
+ sg4::Link* link = root->create_link("link1-2", std::vector<double>{2.25e9})->set_latency(5e-4)->seal();
+ root->add_route(e.netpoint_by_name_or_null("cluster1"), e.netpoint_by_name_or_null("cluster2"),
+ e.netpoint_by_name_or_null("router1"), e.netpoint_by_name_or_null("router2"), {link});
+
+ root->seal();
+}
\ No newline at end of file
+++ /dev/null
-/* Copyright (c) 2006-2021. The SimGrid Team. All rights reserved. */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#include <simgrid/s4u.hpp>
-namespace sg4 = simgrid::s4u;
-
-/**
- * @brief Create the hosts in the platform
- *
- * @param zone Zone to insert the hosts
- */
-static void create_sp_hosts(sg4::NetZone* zone)
-{
- zone->create_host("Tremblay", {"98.095Mf"})->seal();
- zone->create_host("Jupiter", {"76.296Mf"})->seal();
- zone->create_host("Fafard", {"76.296Mf"})->seal();
- zone->create_host("Ginette", {"48.492Mf"})->seal();
- zone->create_host("Bourassa", {"48.492Mf"})->seal();
- zone->create_host("Jacquelin", {"137.333Mf"})->seal();
- zone->create_host("Boivin", {"98.095Mf"})->seal();
-}
-
-/**
- * @brief Create the links in the platform
- *
- * They'll be used later in the routes.
- *
- * @param zone Netzone
- */
-static void create_sp_links(sg4::NetZone* zone)
-{
- zone->create_link("6", {"41.279125MBps"})->set_latency("59.904us")->seal();
- zone->create_link("3", {"34.285625MBps"})->set_latency("514.433us")->seal();
- zone->create_link("7", {"11.618875MBps"})->set_latency("189.98us")->seal();
- zone->create_link("9", {"7.20975MBps"})->set_latency("1.461517ms")->seal();
- zone->create_link("2", {"118.6825MBps"})->set_latency("136.931us")->seal();
- zone->create_link("8", {"8.158MBps"})->set_latency("270.544us")->seal();
- zone->create_link("1", {"34.285625MBps"})->set_latency("514.433us")->seal();
- zone->create_link("4", {"10.099625MBps"})->set_latency("479.78us")->seal();
- zone->create_link("0", {"41.279125MBps"})->set_latency("59.904us")->seal();
- zone->create_link("5", {"27.94625MBps"})->set_latency("278.066us")->seal();
- zone->create_link("145", {"2.583375MBps"})->set_latency("410.463us")->seal();
- zone->create_link("10", {"34.285625MBps"})->set_latency("514.433us")->seal();
- zone->create_link("11", {"118.6825MBps"})->set_latency("136.931us")->seal();
- zone->create_link("16", {"34.285625MBps"})->set_latency("514.433us")->seal();
- zone->create_link("17", {"118.6825MBps"})->set_latency("136.931us")->seal();
- zone->create_link("44", {"10.314625MBps"})->set_latency("6.932556ms")->seal();
- zone->create_link("47", {"10.314625MBps"})->set_latency("6.932556ms")->seal();
- zone->create_link("54", {"15.376875MBps"})->set_latency("35.083019ms")->seal();
- zone->create_link("56", {"21.41475MBps"})->set_latency("29.5890617ms")->seal();
- zone->create_link("59", {"11.845375MBps"})->set_latency("370.788us")->seal();
- zone->create_link("78", {"27.94625MBps"})->set_latency("278.066us")->seal();
- zone->create_link("79", {"8.42725MBps"})->set_latency("156.056us")->seal();
- zone->create_link("80", {"15.376875MBps"})->set_latency("35.083019ms")->seal();
-
- /* single FATPIPE links for loopback */
- zone->create_link("loopback", {"498MBps"})
- ->set_latency("15us")
- ->set_sharing_policy(sg4::Link::SharingPolicy::FATPIPE)
- ->seal();
-}
-
-/**
- * @brief Auxiliary function to create a single route
- *
- * It translates the parameters from string to proper API
- * @param e S4U Engine
- * @param src Source hostname
- * @param dst Destination hostname
- * @param links List of links to use in this route
- */
-static void create_single_route(const sg4::Engine& e, std::string const& src, std::string const& dst,
- std::vector<std::string> const& links)
-{
- std::vector<sg4::Link*> link_list;
- for (auto& link : links) {
- link_list.push_back(e.link_by_name(link));
- }
- sg4::NetZone* zone = e.get_netzone_root();
- zone->add_route(e.netpoint_by_name(src), e.netpoint_by_name(dst), nullptr, nullptr, link_list);
-}
-
-/** @brief Creates the routes in the platform */
-static void create_sp_routes(const sg4::Engine& e)
-{
- auto nodes = std::vector<std::string>{"Tremblay", "Jupiter", "Fafard", "Ginette", "Bourassa"};
- for (const auto& name : nodes) {
- create_single_route(e, name, name, {"loopback"});
- }
- create_single_route(e, "Tremblay", "Jupiter", {"9"});
- create_single_route(e, "Tremblay", "Fafard", {"4", "3", "2", "0", "1", "8"});
- create_single_route(e, "Tremblay", "Ginette", {"4", "3", "5"});
- create_single_route(e, "Tremblay", "Bourassa", {"4", "3", "2", "0", "1", "6", "7"});
- create_single_route(e, "Jupiter", "Fafard", {"9", "4", "3", "2", "0", "1", "8"});
- create_single_route(e, "Jupiter", "Bourassa", {"9", "4", "3", "2", "0", "1", "6", "7"});
- create_single_route(e, "Fafard", "Ginette", {"8", "1", "0", "2", "5"});
- create_single_route(e, "Jupiter", "Jacquelin", {"145"});
- create_single_route(e, "Jupiter", "Boivin", {"47"});
- create_single_route(e, "Jupiter", "Ginette", {"9", "4", "3", "5"});
- create_single_route(e, "Fafard", "Bourassa", {"8", "6", "7"});
- create_single_route(e, "Ginette", "Bourassa", {"5", "2", "0", "1", "6", "7"});
- create_single_route(e, "Ginette", "Jacquelin", {"145"});
- create_single_route(e, "Ginette", "Boivin", {"47"});
- create_single_route(e, "Bourassa", "Jacquelin", {"145"});
- create_single_route(e, "Bourassa", "Boivin", {"47"});
- create_single_route(e, "Jacquelin", "Boivin", {"145", "59", "56", "54", "17", "16", "10", "11", "44", "47"});
- create_single_route(e, "Jacquelin", "Fafard", {"145", "59", "56", "54", "17", "16", "10", "6", "9", "79", "78"});
- create_single_route(e, "Jacquelin", "Tremblay", {"145", "59", "56", "54", "2", "3"});
- create_single_route(e, "Boivin", "Tremblay", {"47", "44", "11", "10", "16", "0", "3"});
- create_single_route(e, "Boivin", "Fafard", {"47", "44", "11", "6", "9", "79", "78", "80"});
-}
-
-/**
- * @brief Programmatic version of small_platform.xml
- *
- * Possible not the best example since we need to describe each component manually,
- * but it illustrates the new API
- */
-extern "C" void load_platform(const sg4::Engine& e);
-void load_platform(const sg4::Engine& e)
-{
- auto* root_zone = sg4::create_full_zone("zone0");
-
- /* create hosts */
- create_sp_hosts(root_zone);
- /* create links */
- create_sp_links(root_zone);
- /* create routes */
- create_sp_routes(e);
- /* finally seal the root zone */
- root_zone->seal();
-}
\ No newline at end of file