3 <object id="TOC" data="graphical-toc.svg" type="image/svg+xml"></object>
5 window.onload=function() { // Wait for the SVG to be loaded before changing it
6 var elem=document.querySelector("#TOC").contentDocument.getElementById("ModelBox")
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";
18 As for any simulator, the models are very important components in SimGrid. This page first introduces the several kind of models
19 used in SimGrid before focusing on the **performance models** that compute the duration of :ref:`every activities
20 <S4U_main_concepts>` in the simulator depending on the platform characteristics and on the other activities that are sharing the
23 The **routing models** constitute advanced elements of the platform description. This description naturally entails
24 :ref:`components<platform>` that are very related to the performance models, because determining for example the execution time
25 of a task obviously depends on the characteristics of the machine executing it. Furthermore, networking zones can be
26 interconnected to form larger platforms `in a scalable way <http://hal.inria.fr/hal-00650233/>`_. Each of these zone can be given
27 a specific :ref:`routing model<platform_routing>` that efficiently computes the list of links entailing a network path between
30 The model checker uses an abstraction of the performance simulations. Mc SimGrid explores every causally possible executions of
31 the application, completely abstracting the performance away. The simulated time not even computed in this mode! The abstraction
32 involved in this process also models the mutual impacts between actions, to not re-explore histories that only differ by the
33 order of independent and unrelated actions. As with the rest of the model checker, these models are unfortunately still to be
36 Finally, the `SimGrid-FMI external plugin <https://framagit.org/simgrid/simgrid-FMI>`_ can be used to integrate any FMI-based
37 models into SimGrid. This was used to accurately study a *Smart grid* through co-simulation: `PandaPower
38 <http://www.pandapower.org/>`_ was used to simulate the power grid, `ns-3 <https://nsnam.org/>`_ co-simulate was used the
39 communication network while SimGrid was simulating the IT infrastructure. Please refer to the `relevant publication
40 <https://hal.archives-ouvertes.fr/hal-01762540/>`_ for more details.
45 The main objective of SimGrid is to provide timing information for three kind of resources: network, CPU and disk.
47 The **network models** are improved and assessed since almost 20 years. It should be possible to get accurate predictions once
48 you properly :ref:`calibrate the models for your settings<models_calibration>`. As detailed in the next section, SimGrid
49 provides several network models. Two plugins can be used to compute the network energy consumption: One for the :ref:`wired
50 networks<plugin_link_energy>`, and another one for the :ref:`Wi-Fi networks<plugin_link_energy>`. Some users find :ref:`TCP
51 simulated performance counter-intuitive<understanding_lv08>` at first in SimGrid, sometimes because of a misunderstanding of the
52 TCP behavior in real networks.
54 The **computing models** are less developed in SimGrid. With the S4U interface, the user specifies the amount of flops that each
55 computation "consumes", and the model simply divides this amount by the host's flops rate to compute the duration of this
56 execution. In SMPI, the user code is automatically timed, and the :ref:`computing speed<cfg=smpi/host-speed>` of the host
57 machine is used to evaluate the corresponding amount of flops. This model should be sufficient for most users, even if assuming
58 a constant flops rate for each machine is a simplification. In reality, the flops rate varies because of I/O, memory and cache
59 effects. It is somehow possible to :ref:`overcome this simplification<cfg=smpi/comp-adjustment-file>`, but the required
60 calibration process is rather intricate and not documented yet (feel free to :ref:`contact the community<community>` on need).
61 In the future, more advanced models may be added but the existing model proved good enough for all experiments done on
62 distributed applications during the last two decades. The CPU energy consumption can be computed with the :ref:`relevant
63 plugin<plugin_host_energy>`.
65 The **disk models** of SimGrid are more recent than for the network and computing resources, but they should still be correct
66 for most users. Studies have shown that they are sensible under some conditions, and a :ref:`calibration process<howto_disk>` is
67 provided. As usual, you probably want to double-check their predictions through an appropriate validation campaign.
72 SimGrid aims at the sweet spot between accuracy and simulation speed. Concerning the accuracy, our goal is to report correct
73 performance trends when comparing competing designs with minimal burden on the user, while allowing power users to fine tune the
74 simulation models for predictions that are within 5% or below of the results on real machines. For example, we determined the
75 `speedup achieved by the Tibidabo ARM-based cluster <http://hal.inria.fr/hal-00919507>`_ before its construction. On the other
76 side, the tool must be fast and scalable enough to study modern IT systems at scale. SimGrid was for example used to `simulate a
77 Chord ring involving millions of actors <https://hal.inria.fr/inria-00602216>`_ (even if that not really more instructive for
78 this protocol than smaller simulations), or `a qualification run at full-scale of the Stampede supercomputer
79 <https://hal.inria.fr/hal-02096571>`_.
81 Most of our models are based on a linear max-min solver (LMM), as depicted below. The actors' activities are represented by
82 actions in the simulation kernel, accounting the initial amount of work of the corresponding activity (in flops for computing
83 activities or bytes for networking and disk activities), and the remaining amount of work. At each simulation step, the
84 instantaneous computing and communicating speed of each action is computed according to the model. A set of constraints is used
85 to express for example that the instantaneous speed of actions on a given resource must remain smaller than the instantaneous
86 speed of that resource. In the example below, it is stated that the speed :math:`x_1` of activity 1 plus the speed :math:`x_n`
87 of activity :math:`n` must remain smaller than the capacity :math:`C_A` of the corresponding host A.
89 .. image:: img/lmm-overview.svg
91 There is obviously many valuation of :math:`x_1 \ldots{} x_n` that respect such as set of constraints. SimGrid usually computes
92 the instantaneous speeds according to a Max-Mix objective function, that maximizing the minimum over all :math:`x_i`. The
93 coefficients associated to each variable in the inequalities are used to model some performance effects, such as the fact that
94 TCP tend to favor communications with small RTTs. These coefficients computed from both hardcoded values and from the
95 :ref:`latency and bandwidth factors<cfg=network/latency-factor>`.
97 Once the instantaneous speeds are computed, the simulation kernel computes the earliest terminating action from their speeds and
98 remaining work. The simulated time is then updated along with the values in the LMM. The corresponding activities terminate,
99 unblocking the corresponding actors that can further execute.
101 Most of the SimGrid models build upon the LMM solver, that they adapt and configure for a given usage. **CM02** is the simplest
102 LMM model as it does not introduce any correction factors. This model should be used if you prefer understandable results over
103 realistic ones. **LV08** (the default model) uses constant factors that are intended to capture common effects such as
104 slow-start, or the fact that TCP headers reduce the *effective* bandwidth. **SMPI** use more advanced factors that also capture
105 the MPI-specific effects such as the eager vs. rendez-vous communication mode. You can :ref:`pick another
106 model<options_model_select>` on the command line, and these models can be :ref:`further configured<options_model>`.
108 **L07** is rather distinct because it uses another objective function called *bottleneck*. This is because this model is
109 intended to be used for parallel tasks that are actions mixing flops and bytes while the Max-Min objective function requires
110 that all variables are expressed using the same unit. This is also why in reality, we have one LMM system per resource kind in
111 the simulation, but the idea remains similar.
113 .. _understanding_lv08:
115 The default TCP model
116 =====================
118 When simulating a data transfer between two hosts, you may be surprised by the obtained simulation time. Lets consider the
123 <host id="A" speed="1Gf" />
124 <host id="B" speed="1Gf" />
126 <link id="link1" latency="10ms" bandwidth="1Mbps" />
128 <route src="A" dst="B">
129 <link_ctn id="link1" />
132 If host `A` sends `100kB` (a hundred kilobytes) to host `B`, one could expect that this communication would take `0.81` seconds
133 to complete according to a simple latency-plus-size-divided-by-bandwidth model (0.01 + 8e5/1e6 = 0.81). However, the default TCP
134 model of SimGrid is a bit more complex than that. It accounts for three phenomena that directly impact the simulation time even
135 on such a simple example:
137 - The size of a message at the application level (i.e., 100kB in this example) is not the size that will actually be
138 transferred over the network. To mimic the fact that TCP and IP headers are added to each packet of the original payload,
139 the TCP model of SimGrid empirically considers that `only 97% of the nominal bandwidth` are available. In other words, the
140 size of your message is increased by a few percents, whatever this size be.
142 - In the real world, the TCP protocol is not able to fully exploit the bandwidth of a link from the emission of the first
143 packet. To reflect this `slow start` phenomenon, the latency declared in the platform file is multiplied by `a factor of
144 13.01`. Here again, this is an empirically determined value that may not correspond to every TCP implementations on every
145 networks. It can be tuned when more realistic simulated times for short messages are needed though.
147 - When data is transferred from A to B, some TCP ACK messages travel in the opposite direction. To reflect the impact of this
148 `cross-traffic`, SimGrid simulates a flow from B to A that represents an additional bandwidth consumption of `0.05`. The
149 route from B to A is implicitly declared in the platform file and uses the same link `link1` as if the two hosts were
150 connected through a communication bus. The bandwidth share allocated to the flow from A to B is then the available bandwidth
151 of `link1` (i.e., 97% of the nominal bandwidth of 1Mb/s) divided by 1.05 (i.e., the total consumption). This feature,
152 activated by default, can be disabled by adding the `--cfg=network/crosstraffic:0` flag to command line.
154 As a consequence, the time to transfer 100kB from A to B as simulated by the default TCP model of SimGrid is not 0.81 seconds
157 .. code-block:: python
159 0.01 * 13.01 + 800000 / ((0.97 * 1e6) / 1.05) = 0.996079 seconds.
165 In SimGrid, WiFi networks are modeled with WiFi zones, where a zone contains the access point of the WiFi network and the hosts
166 connected to it (called station in the WiFi world). Links inside WiFi zones are modeled as regular links with a specific
167 attribute, and these links are then added to routes between hosts. The main difference of WiFi networks is that their
168 performance is not given by the link bandwidth and latency but by both the access point WiFi characteristics and the distance
169 between the access point and the hosts.
171 Such WiFi zones can be used in both the LMM-based model or with ns-3, and are supposed to behave similarly in both cases.
173 Declaring a WiFi zone
174 ---------------------
176 To declare a new WiFi network, simply declare a network zone with the ``WIFI`` routing.
180 <zone id="SSID_1" routing="WIFI">
182 Inside this zone you must declare which host or router will be the access point of the WiFi network.
186 <prop id="access_point" value="alice"/>
188 Afterward simply declare the hosts and routers inside the WiFi network. Remember that one must have the same name as declared in
189 the property "access point".
193 <router id="alice" speed="1Gf"/>
194 <host id="STA0-0" speed="1Gf"/>
195 <host id="STA0-1" speed="1Gf"/>
197 Finally, close the WiFi zone.
203 The WiFi zone may be connected to another zone using a traditional link and a zoneRoute. Note that the connection between two
204 zones is always wired.
208 <link id="wireline" bandwidth="100Mbps" latency="2ms" sharing_policy="SHARED"/>
210 <zoneRoute src="SSID_1" dst="SSID_2" gw_src="alice" gw_dst="bob">
211 <link_ctn id="wireline"/>
214 WiFi network performance
215 ------------------------
217 The performance of a wifi network is controlled by 3 property that can be added to hosts connected to the wifi zone:
219 * ``mcs`` (`Modulation and Coding Scheme <https://en.wikipedia.org/wiki/Link_adaptation>`_)
220 Roughly speaking, it defines the speed at which the access point is
221 exchanging data with all stations. It depends on its model and configuration,
222 and the possible values are listed for example on Wikipedia.
223 |br| By default, ``mcs=3``.
224 It is a property of the WiFi zone.
225 * ``nss`` (Number of Spatial Streams, or `number of antennas <https://en.wikipedia.org/wiki/IEEE_802.11n-2009#Number_of_antennas>`_)
226 defines the amount of simultaneous data streams that the AP can sustain.
227 Not all value of MCS and NSS are valid nor compatible (cf. `802.11n standard <https://en.wikipedia.org/wiki/IEEE_802.11n-2009#Data_rates>`_).
228 |br| By default, ``nss=1``.
229 It is a property of the WiFi zone.
230 * ``wifi_distance`` is the distance from the station to the access point. Each
231 station can have a specific value.
232 |br| By default, ``wifi_distance=10``.
233 It is a property of stations of the WiFi network.
235 Here is an example of a zone changing ``mcs`` and ``nss`` values.
239 <zone id="SSID_1" routing="WIFI">
240 <prop id="access_point" value="alice"/>
241 <prop id="mcs" value="2"/>
242 <prop id="nss" value="2"/>
246 Here is an example of a host changing ``wifi_distance`` value.
250 <host id="STA0-0" speed="1Gf">
251 <prop id="wifi_distance" value="37"/>
257 SimGrid provides two other models in addition to the LMM-based ones.
259 First, the **constant-time model** is a simplistic network model where all communication take a constant time (one second). It
260 provides the lowest realism, but is marginally faster and much simpler to understand. This model may reveal interesting if you
261 plan to study abstract distributed algorithms such as leader election or causal broadcast.
263 On the contrary, the **ns-3 based model** is the most accurate network model that you can get in SimGrid. It relies on the
264 well-known `ns-3 packet-level network simulator <http://www.nsnam.org>`_ to compute every timing information of your simulation.
265 For example, this may be used to investigate the validity of a simulation. Note that this model is much slower than the
266 LMM-based models, because ns-3 simulates every network packet involved in as communication while SimGrid only recompute the
267 instantaneous speeds when one of the communications starts or stops. Both simulators are linear in the size of their input, but
268 ns-3 has a much larger input in case of large steady communications.
270 ns-3 as a SimGrid model
271 =======================
273 You need to install ns-3 and recompile SimGrid accordingly to use this model.
275 The SimGrid/ns-3 binding only contains features that are common to both systems.
276 Not all ns-3 models are available from SimGrid (only the TCP and WiFi ones are),
277 while not all SimGrid platform files can be used in conjunction ns-3 (routes
278 must be of length 1). Also, the platform built in ns-3 from the SimGrid
279 description is very basic. Finally, communicating from a host to
280 itself is forbidden in ns-3, so every such communication completes
281 immediately upon startup.
284 Compiling the ns-3/SimGrid binding
285 ----------------------------------
290 SimGrid requires ns-3 version 3.26 or higher, and you probably want the most
291 recent version of both SimGrid and ns-3. While the Debian package of SimGrid
292 don't have the ns-3 bindings activated, you can still use the packaged version
293 of ns-3 by grabbing the ``libns3-dev ns3`` packages. Alternatively, you can
294 install ns-3 from scratch (see the `ns-3 documentation <http://www.nsnam.org>`_).
296 Enabling ns-3 in SimGrid
297 ^^^^^^^^^^^^^^^^^^^^^^^^
299 SimGrid must be recompiled with the ``enable_ns3`` option activated in cmake.
300 Optionally, use ``NS3_HINT`` to tell cmake where ns3 is installed on
303 .. code-block:: console
305 $ cmake . -Denable_ns3=ON -DNS3_HINT=/opt/ns3 # or change the path if needed
307 By the end of the configuration, cmake reports whether ns-3 was found,
308 and this information is also available in ``include/simgrid/config.h``
309 If your local copy defines the variable ``SIMGRID_HAVE_NS3`` to 1, then ns-3
310 was correctly detected. Otherwise, explore ``CMakeFiles/CMakeOutput.log`` and
311 ``CMakeFiles/CMakeError.log`` to diagnose the problem.
313 Test that ns-3 was successfully integrated with the following (from your SimGrid
314 build directory). It will run all SimGrid tests that are related to the ns-3
315 integration. If no test is run at all, you probably forgot to enable ns-3 in cmake.
317 .. code-block:: console
324 If you use a version of ns-3 that is not known to SimGrid yet, edit
325 ``tools/cmake/Modules/FindNS3.cmake`` in your SimGrid tree, according to the
326 comments on top of this file. Conversely, if something goes wrong with an old
327 version of either SimGrid or ns-3, try upgrading everything.
329 Note that there is a known bug with version 3.31 of ns3, when it's built with
330 MPI support, like it is with the package libns3-dev in Debian 11 « Bullseye ».
331 A simple workaround is to edit the file
332 ``/usr/include/ns3.31/ns3/point-to-point-helper.h`` to remove the ``#ifdef NS3_MPI``
333 include guard. This can be achieved with the following command (as root):
335 .. code-block:: console
337 # sed -i '/^#ifdef NS3_MPI/,+2s,^#,//&,' /usr/include/ns3.31/ns3/point-to-point-helper.h
341 Using ns-3 from SimGrid
342 -----------------------
344 Platform files compatibility
345 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
347 Any route longer than one will be ignored when using ns-3. They are
348 harmless, but you still need to connect your hosts using one-hop routes.
349 The best solution is to add routers to split your route. Here is an
350 example of an invalid platform:
354 <?xml version='1.0'?>
355 <!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
356 <platform version="4.1">
357 <zone id="zone0" routing="Floyd">
358 <host id="alice" speed="1Gf" />
359 <host id="bob" speed="1Gf" />
361 <link id="l1" bandwidth="1Mbps" latency="5ms" />
362 <link id="l2" bandwidth="1Mbps" latency="5ms" />
364 <route src="alice" dst="bob">
365 <link_ctn id="l1"/> <!-- !!!! IGNORED WHEN USED WITH ns-3 !!!! -->
366 <link_ctn id="l2"/> <!-- !!!! ROUTES MUST CONTAIN ONE LINK ONLY !!!! -->
371 This can be reformulated as follows to make it usable with the ns-3 binding.
372 There is no direct connection from alice to bob, but that's OK because ns-3
373 automatically routes from point to point (using
374 ``ns3::Ipv4GlobalRoutingHelper::PopulateRoutingTables``).
378 <?xml version='1.0'?>
379 <!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
380 <platform version="4.1">
381 <zone id="zone0" routing="Full">
382 <host id="alice" speed="1Gf" />
383 <host id="bob" speed="1Gf" />
385 <router id="r1" /> <!-- routers are compute-less hosts -->
387 <link id="l1" bandwidth="1Mbps" latency="5ms"/>
388 <link id="l2" bandwidth="1Mbps" latency="5ms"/>
390 <route src="alice" dst="r1">
394 <route src="r1" dst="bob">
400 Once your platform is OK, just change the :ref:`network/model
401 <options_model_select>` configuration option to `ns-3` as follows. The other
402 options can be used as usual.
404 .. code-block:: console
406 $ ./network-ns3 --cfg=network/model:ns-3 (other parameters)
408 Many other files from the ``examples/platform`` directory are usable with the
409 ns-3 model, such as `examples/platforms/dogbone.xml <https://framagit.org/simgrid/simgrid/tree/master/examples/platforms/dogbone.xml>`_.
410 Check the file `examples/cpp/network-ns3/network-ns3.tesh <https://framagit.org/simgrid/simgrid/tree/master/examples/cpp/network-ns3/network-ns3.tesh>`_
411 to see which ones are used in our regression tests.
413 Alternatively, you can manually modify the ns-3 settings by retrieving
414 the ns-3 node from any given host with the
415 :cpp:func:`simgrid::get_ns3node_from_sghost` function (defined in
416 ``simgrid/plugins/ns3.hpp``).
418 .. doxygenfunction:: simgrid::get_ns3node_from_sghost
422 It is possible to define a fixed or random seed to the ns3 random number generator using the config tag.
426 <?xml version='1.0'?><!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
427 <platform version="4.1">
429 <prop id = "network/model" value = "ns-3" />
430 <prop id = "ns3/seed" value = "time" />
435 The first property defines that this platform will be used with the ns3 model.
436 The second property defines the seed that will be used. Defined to ``time``
437 it will use a random seed, defined to a number it will use this number as
443 A ns-3 platform is automatically created from the provided SimGrid
444 platform. However, there are some known caveats:
446 * The default values (e.g., TCP parameters) are the ns-3 default values.
447 * ns-3 networks are routed using the shortest path algorithm, using ``ns3::Ipv4GlobalRoutingHelper::PopulateRoutingTables``.
448 * End hosts cannot have more than one interface card. So, your SimGrid hosts
449 should be connected to the platform through only one link. Otherwise, your
450 SimGrid host will be considered as a router (FIXME: is it still true?).
452 Our goal is to keep the ns-3 plugin of SimGrid as easy (and hopefully readable)
453 as possible. If the current state does not fit your needs, you should modify
454 this plugin, and/or create your own plugin from the existing one. If you come up
455 with interesting improvements, please contribute them back.
460 If your simulation hangs in a communication, this is probably because one host
461 is sending data that is not routable in your platform. Make sure that you only
462 use routes of length 1, and that any host is connected to the platform.
463 Arguably, SimGrid could detect this situation and report it, but unfortunately,
464 this is still to be done.