- py::class_<simgrid::s4u::Link, std::unique_ptr<simgrid::s4u::Link, py::nodelete>> link(m, "Link", "Network link");
- link.def("set_latency", py::overload_cast<const std::string&>(&simgrid::s4u::Link::set_latency), "Set the latency");
- link.def("set_latency", py::overload_cast<double>(&simgrid::s4u::Link::set_latency), "Set the latency");
- link.def("set_sharing_policy", &simgrid::s4u::Link::set_sharing_policy, "Set sharing policy for this link");
- link.def("seal", &simgrid::s4u::Link::seal, "Seal this link");
- link.def_property_readonly(
- "name",
- [](const simgrid::s4u::Link* self) {
- return std::string(self->get_name().c_str()); // Convert from xbt::string because of MC
- },
- "The name of this link");
- py::enum_<simgrid::s4u::Link::SharingPolicy>(link, "SharingPolicy")
- .value("NONLINEAR", simgrid::s4u::Link::SharingPolicy::NONLINEAR)
- .value("WIFI", simgrid::s4u::Link::SharingPolicy::WIFI)
- .value("SPLITDUPLEX", simgrid::s4u::Link::SharingPolicy::SPLITDUPLEX)
- .value("SHARED", simgrid::s4u::Link::SharingPolicy::SHARED)
- .value("FATPIPE", simgrid::s4u::Link::SharingPolicy::FATPIPE)
+ py::class_<Link, std::unique_ptr<Link, py::nodelete>> link(m, "Link",
+ "Network link. See the C++ documentation for details.");
+ link.def("set_latency", py::overload_cast<const std::string&>(&Link::set_latency),
+ py::call_guard<py::gil_scoped_release>(),
+ "Set the latency as a string. Accepts values with units, such as ‘1s’ or ‘7ms’.\nFull list of accepted "
+ "units: w (week), d (day), h, s, ms, us, ns, ps.")
+ .def("set_latency", py::overload_cast<double>(&Link::set_latency), py::call_guard<py::gil_scoped_release>(),
+ "Set the latency as a float (in seconds).")
+ .def("set_bandwidth", &Link::set_bandwidth, py::call_guard<py::gil_scoped_release>(),
+ "Set the bandwidth (in byte per second).")
+ .def(
+ "set_bandwidth_profile",
+ [](Link* l, const std::string& profile, double period) {
+ l->set_bandwidth_profile(simgrid::kernel::profile::ProfileBuilder::from_string("", profile, period));
+ },
+ py::call_guard<py::gil_scoped_release>(),
+ "Specify a profile modeling the external load according to an exhaustive list. "
+ "Each line of the profile describes timed events as ``date bandwidth`` (in bytes per second). "
+ "For example, the following content describes a link which bandwidth changes to 40 Mb/s at t=4, and to 6 "
+ "Mb/s at t=8:\n\n"
+ ".. code-block:: python\n\n"
+ " \"\"\"\n"
+ " 4.0 40000000\n"
+ " 8.0 60000000\n"
+ " \"\"\"\n\n"
+ ".. warning:: Don't get fooled: bandwidth and latency profiles of links contain absolute values,"
+ " while speed profiles of hosts contain ratios.\n\n"
+ "The second function parameter is the periodicity: the time to wait after the last event to start again over "
+ "the list. Set it to -1 to not loop over.")
+ .def(
+ "set_latency_profile",
+ [](Link* l, const std::string& profile, double period) {
+ l->set_latency_profile(simgrid::kernel::profile::ProfileBuilder::from_string("", profile, period));
+ },
+ py::call_guard<py::gil_scoped_release>(),
+ "Specify a profile modeling the external load according to an exhaustive list. "
+ "Each line of the profile describes timed events as ``date latency`` (in seconds). "
+ "For example, the following content describes a link which latency changes to 1ms (0.001s) at t=1, and to 2s "
+ "at t=2:\n\n"
+ ".. code-block:: python\n\n"
+ " \"\"\"\n"
+ " 1.0 0.001\n"
+ " 2.0 2\n"
+ " \"\"\"\n\n"
+ ".. warning:: Don't get fooled: bandwidth and latency profiles of links contain absolute values,"
+ " while speed profiles of hosts contain ratios.\n\n"
+ "The second function parameter is the periodicity: the time to wait after the last event to start again over "
+ "the list. Set it to -1 to not loop over.")
+ .def(
+ "set_state_profile",
+ [](Link* l, const std::string& profile, double period) {
+ l->set_state_profile(simgrid::kernel::profile::ProfileBuilder::from_string("", profile, period));
+ },
+ "Specify a profile modeling the churn. "
+ "Each line of the profile describes timed events as ``date boolean``, where the boolean (0 or 1) tells "
+ "whether the link is on. "
+ "For example, the following content describes a link which turns off at t=1 and back on at t=2:\n\n"
+ ".. code-block:: python\n\n"
+ " \"\"\"\n"
+ " 1.0 0\n"
+ " 2.0 1\n"
+ " \"\"\"\n\n"
+ "The second function parameter is the periodicity: the time to wait after the last event to start again over "
+ "the list. Set it to -1 to not loop over.")
+
+ .def("turn_on", &Link::turn_on, py::call_guard<py::gil_scoped_release>(), "Turns the link on.")
+ .def("turn_off", &Link::turn_off, py::call_guard<py::gil_scoped_release>(), "Turns the link off.")
+ .def("is_on", &Link::is_on, "Check whether the link is on.")
+
+ .def("set_sharing_policy", &Link::set_sharing_policy, py::call_guard<py::gil_scoped_release>(),
+ "Set sharing policy for this link")
+ .def("set_concurrency_limit", &Link::set_concurrency_limit, py::call_guard<py::gil_scoped_release>(),
+ "Set concurrency limit for this link")
+ .def("set_host_wifi_rate", &Link::set_host_wifi_rate, py::call_guard<py::gil_scoped_release>(),
+ "Set level of communication speed of given host on this Wi-Fi link")
+ .def_static("by_name", &Link::by_name, "Retrieves a Link from its name, or dies")
+ .def("seal", &Link::seal, py::call_guard<py::gil_scoped_release>(), "Seal this link")
+ .def_property_readonly(
+ "name", [](const Link* self) { return self->get_name(); }, "The name of this link")
+ .def_property_readonly("bandwidth", &Link::get_bandwidth,
+ "The bandwidth (in bytes per second) (read-only property).")
+ .def_property_readonly("latency", &Link::get_latency, "The latency (in seconds) (read-only property).");
+
+ py::enum_<Link::SharingPolicy>(link, "SharingPolicy")
+ .value("NONLINEAR", Link::SharingPolicy::NONLINEAR)
+ .value("WIFI", Link::SharingPolicy::WIFI)
+ .value("SPLITDUPLEX", Link::SharingPolicy::SPLITDUPLEX)
+ .value("SHARED", Link::SharingPolicy::SHARED)
+ .value("FATPIPE", Link::SharingPolicy::FATPIPE)