Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reword the Platform::routing documentation
[simgrid.git] / docs / source / Platform_routing.rst
1 .. raw:: html
2
3    <object id="TOC" data="graphical-toc.svg" type="image/svg+xml"></object>
4    <script>
5    window.onload=function() { // Wait for the SVG to be loaded before changing it
6      var elem=document.querySelector("#TOC").contentDocument.getElementById("RoutingBox")
7      elem.style="opacity:0.93999999;fill:#ff0000;fill-opacity:0.1;stroke:#000000;stroke-width:0.35277778;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1";
8    }
9    </script>
10    <br/>
11    <br/>
12
13 .. _platform_routing:
14
15 Advanced routing
16 ################
17
18 SimGrid platforms are divided in networking zones (:ref:`pf_tag_zone`) to compose larger platforms from smaller parts.
19 This factorizes the description and improves the simulation performance, both in time and in size. Any zone may contain
20 sub-zones, allowing for a hierarchical decomposition of the platform as depicted in the example below. Inter-zone routes
21 are then factorized with :ref:`pf_tag_zoneRoute`.
22
23 In addition to the efficiency improvement, multi-zones routing also improve the modeling expressiveness, as each zone
24 can use different models. For example, you can have a coordinate-based routing for the WAN parts of your platform, a
25 full routing within each datacenter, and a highly optimized routing within each cluster of the datacenter. In all cases,
26 SimGrid strives to compute routes in a time- and space-efficient manner.
27
28
29 |flat_img| |tree_img|
30
31 .. |flat_img| image:: img/zone_hierarchy.png
32    :width: 45%
33
34 .. |tree_img| image:: img/zone_tree.svg
35    :width: 45%
36
37 Both images above represent the same platform. On the left, circles represent hosts (i.e. processing units) and squares
38 represent network routers. Bold lines represent communication links. The zone "AS2" models the core of a national
39 network interconnecting a small flat cluster (AS4) and a larger hierarchical cluster (AS5), a subset of a LAN (AS6), and
40 a set of peers scattered around the world (AS7). On the right, the corresponding hierarchy of zones is highlighted.
41
42 Routing models
43 **************
44
45 Each zone implements a routing strategy according to the ``routing`` attribute of :ref:`pf_tag_zone`.
46
47 Explicit routing
48 ================
49
50 When ``routing=full``, all routes must be explicitly given using the :ref:`pf_tag_route` and :ref:`pf_tag_link_ctn` tags.
51 This routing model is both simple and inefficient :) It is OK to not specify each and every route between hosts, as
52 long as you do not try to start a communication on any of the missing routes during your simulation.
53
54 .. _platform_rm_shortest:
55
56 Shortest path
57 =============
58
59 SimGrid can compute automatically the paths between all pair of hosts in a zone. You just need to provide the one-hop routes to connect all hosts.
60 Two algorithms are provided: 
61
62   - ``routing=Floyd``: use the number of hops to build shortest path. It is calculated only once at the beginning of the
63     simulation.
64   - ``routing=Dijksta``: shortest-path calculated considering the path's latency. As the latency of links can change
65     during simulation, it is recomputed each time a route is necessary.
66   - ``routing=DijkstraCache``: Just like the regular Dijkstra, but with a cache of previously computed paths for performance.
67
68 Here is a small example describing a star-shaped zone depicted below. The path from e.g. *host0* to *host1* will be
69 computed automatically at startup. Another way to describe the same platform can be found :ref:`here
70 <platform_example_3hosts>`, with a full routing and without the central router.
71
72 .. code-block:: XML
73
74    <?xml version='1.0'?>
75    <!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
76    <platform version="4.1">
77      <zone id="my zone" routing="Floyd">
78        <host id="host0" speed="1Gf"/>
79        <host id="host1" speed="2Gf"/>
80        <host id="host2" speed="40Gf"/>
81        <link id="link0" bandwidth="125MBps" latency="100us"/>
82        <link id="link1" bandwidth="50MBps" latency="150us"/>
83        <link id="link2" bandwidth="250MBps" latency="50us"/>
84        <router id="center"/>
85        <!-- Only 1-hop routes for topological information. Missing routes are computed with Floyd -->
86        <route src="center" dst="host0"><link_ctn id="link0"/></route>
87        <route src="center" dst="host1"><link_ctn id="link1"/></route>
88        <route src="center" dst="host2"><link_ctn id="link2"/></route>
89      </zone>
90    </platform>
91
92 .. image:: /tuto_smpi/3hosts.png
93    :align: center
94
95 Clusters
96 ========
97
98 TODO
99
100   - **Cluster/Fat-Tree/DragonFly/Torus**: routing is defined by the topology, automatically created.
101     These zones must be defined through the :ref:`pf_tag_cluster` tag in the XML.
102   - **Star**: star-like topology. Users describe routes from/to every host in the zone.
103
104 Vivaldi
105 =======
106
107 This routing model is particularly well adapted to Peer-to-Peer and Clouds platforms: each component is connected to the
108 cloud through a private link of which the upload and download rate may be asymmetric.
109
110 The network core (between the private links) is assumed to be over-sized so only the latency is taken into account.
111 Instead of a matrix of latencies that would become too large when the amount of peers grows, Vivaldi netzones give a
112 coordinate to each peer and compute the latency between host A=(xA,yA,zA) and host B=(xB,yB,zB) as follows:
113
114   latency = sqrt( (xA-xB)² + (yA-yB)² ) + zA + zB
115
116 The resulting value is assumed to be in milliseconds.
117
118 .. image:: img/vivaldi.svg
119     :scale: 60%
120     :align: center
121
122 So, to go from a host A to a host B, the following links would be used: ``private(A)_UP``, ``private(B)_DOWN``, with the
123 additional latency computed above. The bandwidth of the UP and DOWN links is not symmetric (in contrary to usual SimGrid
124 links), but naturally correspond to the values provided when the peer was created. See also :ref:`pf_tag_peer`.
125
126 The script ``examples/platforms/syscoord/generate_peer_platform.pl`` in the archive can be used to convert the
127 coordinate-based platforms from the OptorSim project into SimGrid platform files.
128
129 Such Network Coordinate systems were shown to provide rather good latency estimations in a compact way. Other systems,
130 such as `Phoenix network coordinates <https://en.wikipedia.org/wiki/Phoenix_network_coordinates>`_ were shown
131 superior to the Vivaldi system and could be also implemented in SimGrid.
132     
133 Here is a small platform example:
134
135 .. code-block:: XML
136
137    <?xml version='1.0'?>
138    <!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
139    <platform version="4">
140
141     <zone  id="zone0"  routing="Vivaldi">
142        <peer id="peer-0" coordinates="173.0 96.8 0.1" speed="730Mf" bw_in="13.38MBps" bw_out="1.024MBps" lat="500us"/>
143        <peer id="peer-1" coordinates="247.0 57.3 0.6" speed="730Mf" bw_in="13.38MBps" bw_out="1.024MBps" lat="500us" />
144        <peer id="peer-2" coordinates="243.4 58.8 1.4" speed="730Mf" bw_in="13.38MBps" bw_out="1.024MBps" lat="500us" />
145     </zone>
146   </platform>
147
148 Wi-Fi
149 =====
150
151 TODO
152
153 .. _pf_routes:
154
155 Describing routes
156 *****************
157
158 If you want to define a route within a given zone, you simply have to use the :ref:`pf_tag_route` tag, providing the
159 ``src``, ``dst`` parameters along with the list of links to use from ``src`` to ``dst``.
160
161 Defining a route between two separate zones with :ref:`pf_tag_zoneroute` takes more parameters: ``src``, ``dst``,
162 ``gw_src`` (source gateway) and ``gw_dst`` (destination gateway) along with the list of links. Afterward, the path from
163 ``src_host`` in zone ``src`` to ``dst_host`` in zone ``dst`` is composed of 3 segments. First, move within zone ``src`` from
164 ``src_host`` to the specified gateway ``gw_src``. Then, traverse all links specified by the zoneRoute (purportedly within
165 the common ancestor) and finally, move within zone ``dst`` from ``gw_dst`` to ``dst_host``. 
166
167 SimGrid enforces that each gateway is within its zone, either directly or in a sub-zone to ensure that the algorithm
168 described in the next section actually works.
169
170 TODO: bypassRoute
171
172 Calculating network paths
173 *************************
174
175 Computing the path between two hosts is easy when they are located in the same zone. It is done directly by the routing
176 algorithm of that zone. Full routing looks in its table, Vivaldi computes the distance between peers, etc.
177
178 When communicating through several zones, a recursive algorithm is used. As an illustration, we will apply this
179 algorithm to a communication between `host1` in `AS1` and `host2` in `AS5-4`, in our previous topology. This section
180 only gives an overview of the algorithm used. You should refer to the source code for the full details, in
181 ``NetZoneImpl::get_global_route()``.
182
183 .. image:: ./img/zoom_comm.svg
184    :scale: 70%
185
186 1. **Find common ancestor** zone of ``src`` and ``dst``, the ancestors of ``src`` and ``dst`` and how they are connected.
187
188    In our case, *AS1* is the common ancestor while *AS2* and *AS5* are the respective ancestors of ``src`` and ``dst``.
189    Assume that the relevant route was defined as follows:
190
191    .. code-block:: XML
192
193         <zoneRoute src="AS2" dst="AS5" gw_src="Host1" gw_dst"="gw1">
194             <link_ctn id="Link1">
195         </zoneRoute>
196
197 2. **Add the route up to the ancestor**, i.e. from ``src`` to the ``gw_src`` in the route between ancestor zones. This is a recursive call to the current algorithm.
198
199    That's easy in our case, as both ``src`` and ``gw_src`` are *Host1*, so that route segment is empty. If we were to compute the path from *Host3* to *Host2*, we would have to add the route from *Host3* to the gateway that is *Host1*
200
201 3. **Add the zoneRoute between ancestors**.
202
203    From the XML fragment above defining the zoneRoute between *AS2* and *AS5*, we need to add ``Link1`` to the path.
204
205 4. **Add the route down from the ancestor**, i.e. from ``gw_dst`` to ``dst`` in the route between ancestor zones. This is another recursive call to the current algorithm.
206
207    Here, we need the route from *gw1* and *host2*. The common ancestor is *AS5*, and the relative ancestors are *AS5-4* and *AS5-3*. This route is defined as follows (routes are symmetrical by default).
208
209    .. code-block:: XML
210
211         <zoneRoute src="AS5-4" dst="AS5-3" gw_src="gw2" gw_dst"="gw1">
212             <link_ctn id="Link3">
213         </zoneRoute>
214
215    So to compute the route from *gw1* to *Host2*, we need to add:
216
217      - the route from the source to the gateway, i.e. from *gw1* to *gw1* (empty route segment),
218      - the links listed in the zoneRoute (*Link3*)
219      - the route from the gateway to the destination, i.e. from *gw2* to *Host2* (they are in the same zone *AS5-4*, and that path is limited to *Link2*). The last segment is because of the following fragment:
220
221        .. code-block:: XML
222
223           <route> src="Host2" dst="gw2">
224             <link_ctn id="Link2">
225           </route>
226
227 In the end, our communication from *Host1@AS2* to *Host2@AS5-4* follows this path: ``{Link1, Link3, Link2}`` 
228
229
230 Loopback links
231 **************
232
233 Loopback links are used when from an host to itself (they are excluded in the recursive search described above). As it
234 can be quite tedious to describe each a loopback link for each host in the platform, SimGrid provides a default global
235 **FATPIPE** link which is used by all hosts. Its bandwidth is 10GBps while its latency is 0ms, but these arbitrary
236 values should changed through configuration to reflect your environment (see :ref:`cfg=network/loopback`).
237
238 To give a specific loopback link to a given host, simply a add :ref:`pf_tag_route` from this node to itself. SimGrid
239 will then use the provided link(s) as a loopback for this host instead of the global one.
240
241 .. code-block:: XML
242
243     <link id="loopback" bandwidth="100MBps" latency="0"/>
244     <route src="Tremblay" dst="Tremblay">
245       <link_ctn id="loopback"/>
246     </route>
247
248 Some zones such as :ref:`pf_tag_cluster` provide ways to describe the characteristics of
249 the loopback nodes inside the zone. 
250
251 .. |br| raw:: html
252
253    <br />