Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add new entry in Release_Notes.
[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 Several 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=Dijkstra``: 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 .. _pf_rm_cluster:
96
97 Clusters
98 ========
99
100 Clusters constitute a fundamental building bricks of any cyberinfrastructure. SimGrid provides several kinds of clusters:
101 crossbar clusters (contention-free internal network), backbone clusters (constrained internal network), fat-trees,
102 DragonFly, Torus and generic Star clusters. Each of them are created through the :ref:`pf_tag_cluster` tag, and have a
103 highly optimized implementation in SimGrid source code.
104
105 The documentation of each cluster kinds is given as :ref:`platform_examples`.
106
107 .. _pf_rm_vivaldi:
108
109 Vivaldi
110 =======
111
112 This routing model is particularly well adapted to Peer-to-Peer and Clouds platforms: each component is connected to the
113 cloud through a private link whose upload and download rates may be asymmetric.
114
115 The network core (between the private links) is assumed to be  over-provisioned so that only the latency has to be
116 taken into account. Instead of a matrix of latencies that would become too large when the amount of peers grows,
117 Vivaldi netzones give a coordinate to each peer and compute the latency between host A=(xA,yA,zA) and host B=(xB,yB,zB)
118 as follows:
119
120   latency = sqrt( (xA-xB)² + (yA-yB)² ) + zA + zB
121
122 The resulting value is assumed to be in milliseconds.
123
124 .. image:: img/vivaldi.svg
125     :scale: 60%
126     :align: center
127
128 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
129 additional latency computed above. The bandwidth of the UP and DOWN links is not symmetric (in contrary to usual SimGrid
130 links), but naturally correspond to the values provided when the peer was created. See also :ref:`pf_tag_peer`.
131
132 The script ``examples/platforms/syscoord/generate_peer_platform.pl`` in the archive can be used to convert the
133 coordinate-based platforms from the OptorSim project into SimGrid platform files.
134
135 Such Network Coordinate systems were shown to provide rather good latency estimations in a compact way. Other systems,
136 such as `Phoenix network coordinates <https://en.wikipedia.org/wiki/Phoenix_network_coordinates>`_ were shown
137 superior to the Vivaldi system and could be also implemented in SimGrid.
138
139 Here is a small platform example:
140
141 .. code-block:: XML
142
143    <?xml version='1.0'?>
144    <!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
145    <platform version="4">
146
147     <zone  id="zone0"  routing="Vivaldi">
148        <peer id="peer-0" coordinates="173.0 96.8 0.1" speed="730Mf" bw_in="13.38MBps" bw_out="1.024MBps" lat="500us"/>
149        <peer id="peer-1" coordinates="247.0 57.3 0.6" speed="730Mf" bw_in="13.38MBps" bw_out="1.024MBps" lat="500us" />
150        <peer id="peer-2" coordinates="243.4 58.8 1.4" speed="730Mf" bw_in="13.38MBps" bw_out="1.024MBps" lat="500us" />
151     </zone>
152   </platform>
153
154 Wi-Fi
155 =====
156
157 Please see :ref:`models_wifi`.
158
159 ns-3
160 ====
161
162 When using :ref:`models_ns3`, SimGrid configures the ns-3 simulator according to the configured platform.
163 Since ns-3 uses a shortest path algorithm on its side, all routes must be of length 1.
164
165 .. _pf_routes:
166
167 Describing routes
168 *****************
169
170 If you want to define a route within a given zone, you simply have to use the :ref:`pf_tag_route` tag, providing the
171 ``src``, ``dst`` parameters along with the list of links to use from ``src`` to ``dst``.
172
173 Defining a route between two separate zones with :ref:`pf_tag_zoneroute` takes more parameters: ``src``, ``dst``,
174 ``gw_src`` (source gateway) and ``gw_dst`` (destination gateway) along with the list of links. Afterward, the path from
175 ``src_host`` in zone ``src`` to ``dst_host`` in zone ``dst`` is composed of 3 segments. First, move within zone ``src`` from
176 ``src_host`` to the specified gateway ``gw_src``. Then, traverse all links specified by the zoneRoute (purportedly within
177 the common ancestor) and finally, move within zone ``dst`` from ``gw_dst`` to ``dst_host``.
178
179 SimGrid enforces that each gateway is within its zone, either directly or in a sub-zone to ensure that the algorithm
180 described in the next section actually works.
181
182 One can also use :ref:`pf_tag_bypassRoute` and :ref:`pf_tag_bypassZoneRoute` to define exceptions to the classical routing
183 algorithm. This advanced feature is also detailed in the next section.
184
185 .. _pf_route_usage:
186
187 Calculating network paths
188 *************************
189
190 Computing the path between two hosts is easy when they are located in the same zone. It is done directly by the routing
191 algorithm of that zone. Full routing looks in its table, Vivaldi computes the distance between peers, etc.
192
193 Another simple case is when a :ref:`pf_tag_bypassRoute` was provided. Such routes are used in priority, with no further
194 routing computation. You can define a bypass between any hosts, even if they are not in the same zone.
195
196 When communicating through several zones, a recursive algorithm is used. As an illustration, we will apply this
197 algorithm to a communication between `host1` in `AS1` and `host2` in `AS5-4`, in our previous topology. This section
198 only gives an overview of the algorithm used. You should refer to the source code for the full details, in
199 ``NetZoneImpl::get_global_route()``.
200
201 .. image:: ./img/zoom_comm.svg
202    :scale: 70%
203
204 1. **Find common ancestor** zone of ``src`` and ``dst``, the ancestors of ``src`` and ``dst`` and how they are connected.
205
206    In our case, *AS1* is the common ancestor while *AS2* and *AS5* are the respective ancestors of ``src`` and ``dst``.
207    Assume that the relevant route was defined as follows:
208
209    .. code-block:: XML
210
211       <zoneRoute src="AS2" dst="AS5" gw_src="Host1" gw_dst="gw1">
212          <link_ctn id="Link1"/>
213       </zoneRoute>
214
215 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.
216
217    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*
218
219 3. **Add the zoneRoute between ancestors**.
220
221    From the XML fragment above defining the zoneRoute between *AS2* and *AS5*, we need to add ``Link1`` to the path.
222
223 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.
224
225    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).
226
227    .. code-block:: XML
228
229       <zoneRoute src="AS5-4" dst="AS5-3" gw_src="gw2" gw_dst="gw1">
230          <link_ctn id="Link3"/>
231       </zoneRoute>
232
233    So to compute the route from *gw1* to *Host2*, we need to add:
234
235      - the route from the source to the gateway, i.e. from *gw1* to *gw1* (empty route segment),
236      - the links listed in the zoneRoute (*Link3*)
237      - 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:
238
239        .. code-block:: XML
240
241           <route> src="Host2" dst="gw2">
242             <link_ctn id="Link2">
243           </route>
244
245 In the end, our communication from *Host1@AS2* to *Host2@AS5-4* follows this path: ``{Link1, Link3, Link2}``
246
247 It is possbile to use :ref:`pf_tag_bypassZoneRoute` to provide a path between two zones that are not necessarily sibilings.
248 If such routes exist, SimGrid will try to match each of the ancestor zones of the source with each of the ancestor zone of
249 the destination, looking for such a bypass to use intead of the common ancestor.
250
251 .. _pf_loopback:
252
253 Loopback links
254 **************
255
256 Loopback links are used when from an host to itself (they are excluded in the recursive search described above). As it
257 can be quite tedious to describe each a loopback link for each host in the platform, SimGrid provides a default global
258 **FATPIPE** link which is used by all hosts. Its bandwidth is 10GBps while its latency is 0ms, but these arbitrary
259 values should changed through configuration to reflect your environment (see :ref:`cfg=network/loopback`).
260
261 To give a specific loopback link to a given host, simply a add :ref:`pf_tag_route` from this node to itself. SimGrid
262 will then use the provided link(s) as a loopback for this host instead of the global one.
263
264 .. code-block:: XML
265
266     <link id="loopback" bandwidth="100MBps" latency="0"/>
267     <route src="Tremblay" dst="Tremblay">
268       <link_ctn id="loopback"/>
269     </route>
270
271 Some zones such as :ref:`pf_tag_cluster` provide ways to describe the characteristics of
272 the loopback nodes inside the zone.
273
274 .. |br| raw:: html
275
276    <br />