Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
enoslib-tutorials
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
discovery
enoslib-tutorials
Commits
989619a3
Commit
989619a3
authored
2 months ago
by
SIMONIN Matthieu
Browse files
Options
Downloads
Patches
Plain Diff
Examplify the use of roles.with_{alias,ip}
parent
771b88c4
Branches
main
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
g5k/04_network_emulation.ipynb
+5
-2
5 additions, 2 deletions
g5k/04_network_emulation.ipynb
with
5 additions
and
2 deletions
g5k/04_network_emulation.ipynb
+
5
−
2
View file @
989619a3
...
...
@@ -172,7 +172,10 @@
"source": [
"import pandas as pd\n",
"stats = en.Netem.fping_stats(\"star_topology\")\n",
"pd.DataFrame(stats, columns=[\"src\", \"dest\", \"ping values\"])"
"df =pd.DataFrame(stats, columns=[\"src\", \"dest\", \"ping values\"])\n",
"df[\"src_roles\"] = df[\"src\"].apply(lambda x: roles.with_alias(x))\n",
"df[\"dest_roles\"] = df[\"dest\"].apply(lambda x: roles.with_ip(x))\n",
"df"
]
},
{
...
...
@@ -623,7 +626,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.1
1.2
"
"version": "3.1
2.3
"
},
"toc-showcode": false,
"toc-showmarkdowntxt": false
...
...
%% Cell type:markdown id:loved-sandwich tags:
# Emulating some network conditions
---
-
Website: https://discovery.gitlabpages.inria.fr/enoslib/index.html
-
Instant chat: https://framateam.org/enoslib
-
Source code: https://gitlab.inria.fr/discovery/enoslib
---
## Prerequisites
<div
class=
"alert alert-block alert-warning"
>
<ul>
<li>
⚠️ Make sure you've run the one time setup for your environment
</li>
<li>
⚠️ Make sure you're running this notebook under the right kernel
</li>
</ul>
</div>
%% Cell type:code id:957183a1-3602-4f73-93fd-d52c24842bc0 tags:
```
python
import
enoslib
as
en
en
.
check
()
```
%% Cell type:markdown id:e0c0148f-a781-46ac-9541-bfadf261450e tags:
## First example: a star topology

### Reservation
%% Cell type:code id:f798ca67-5ce2-4273-af14-0f0886a16656 tags:
```
python
import
enoslib
as
en
_
=
en
.
init_logging
()
conf
=
(
en
.
G5kConf
.
from_settings
(
job_type
=
[],
walltime
=
"
01:00:00
"
,
job_name
=
"
labs_netem
"
)
.
add_machine
(
roles
=
[
"
city
"
,
"
paris
"
],
cluster
=
"
parasilo
"
,
nodes
=
1
,
)
.
add_machine
(
roles
=
[
"
city
"
,
"
berlin
"
],
cluster
=
"
parasilo
"
,
nodes
=
1
,
)
.
add_machine
(
roles
=
[
"
city
"
,
"
londres
"
],
cluster
=
"
parasilo
"
,
nodes
=
1
,
)
.
finalize
()
)
provider
=
en
.
G5k
(
conf
)
roles
,
networks
=
provider
.
init
()
```
%% Cell type:code id:11a29ed6-7839-4818-97ad-653038afba55 tags:
```
python
roles
```
%% Cell type:code id:21e4bf24-c22b-4451-8006-a682546080a9 tags:
```
python
networks
```
%% Cell type:markdown id:eff50aa2-5926-408d-a0ac-589a1e9ee982 tags:
### Applying the network constraints
%% Cell type:code id:1f07dd25-7ac3-41f3-a069-eb6d749c42be tags:
```
python
roles
=
en
.
sync_info
(
roles
,
networks
)
netem
=
en
.
Netem
()
(
netem
.
add_constraints
(
"
delay 5ms
"
,
roles
[
"
paris
"
],
symmetric
=
True
)
.
add_constraints
(
"
delay 10ms
"
,
roles
[
"
londres
"
],
symmetric
=
True
)
.
add_constraints
(
"
delay 15ms
"
,
roles
[
"
berlin
"
],
symmetric
=
True
)
)
netem
.
deploy
()
```
%% Cell type:markdown id:4de4648c-699c-4da9-9d28-82b75b4ff48f tags:
### Checking the network constraints
%% Cell type:code id:35b982ec-7a4c-40b1-8b28-d39aa82f0ac4 tags:
```
python
netem
.
validate
(
output_dir
=
"
star_topology
"
)
```
%% Cell type:code id:a0bd3f4c-9c74-44e6-b097-273151f565ab tags:
```
python
import
pandas
as
pd
stats
=
en
.
Netem
.
fping_stats
(
"
star_topology
"
)
pd
.
DataFrame
(
stats
,
columns
=
[
"
src
"
,
"
dest
"
,
"
ping values
"
])
df
=
pd
.
DataFrame
(
stats
,
columns
=
[
"
src
"
,
"
dest
"
,
"
ping values
"
])
df
[
"
src_roles
"
]
=
df
[
"
src
"
].
apply
(
lambda
x
:
roles
.
with_alias
(
x
))
df
[
"
dest_roles
"
]
=
df
[
"
dest
"
].
apply
(
lambda
x
:
roles
.
with_ip
(
x
))
df
```
%% Cell type:code id:a4f1c464-38fb-4db2-93a1-0766f722ca43 tags:
```
python
roles
```
%% Cell type:code id:77f6689a-ef1b-4f31-924a-fc2c611dbc79 tags:
```
python
netem
.
destroy
()
```
%% Cell type:markdown id:cc13b8ab-1811-4ed2-b739-5bd96a496b51 tags:
## Second example: a more flexible topology

%% Cell type:code id:d11a646c-a1a7-406b-b881-33f4dfa515d2 tags:
```
python
roles
=
en
.
sync_info
(
roles
,
networks
)
```
%% Cell type:code id:1a1bf198-b580-4770-a059-956ac3c2672a tags:
```
python
netem
=
en
.
NetemHTB
()
(
netem
.
add_constraints
(
src
=
roles
[
"
paris
"
],
dest
=
roles
[
"
londres
"
],
delay
=
"
5ms
"
,
rate
=
"
1gbit
"
,
symetric
=
True
,
)
.
add_constraints
(
src
=
roles
[
"
paris
"
],
dest
=
roles
[
"
berlin
"
],
delay
=
"
10ms
"
,
rate
=
"
1gbit
"
,
symetric
=
True
,
)
.
add_constraints
(
src
=
roles
[
"
londres
"
],
dest
=
roles
[
"
berlin
"
],
delay
=
"
15ms
"
,
rate
=
"
1gbit
"
,
symetric
=
True
,
)
)
```
%% Cell type:code id:a6fdb44c-2dfe-43f8-b016-cd5d0b1c8712 tags:
```
python
_
=
netem
.
deploy
()
```
%% Cell type:code id:761283d5-dbdb-4a01-bff2-b3436849d5e4 tags:
```
python
netem
.
validate
(
output_dir
=
"
custom_topology
"
)
```
%% Cell type:code id:c7b2f1ff-0446-48b2-912f-cdaea9881021 tags:
```
python
import
enoslib
as
en
import
pandas
as
pd
stats
=
en
.
Netem
.
fping_stats
(
"
custom_topology
"
)
pd
.
DataFrame
(
stats
,
columns
=
[
"
src
"
,
"
dest
"
,
"
ping values
"
])
```
%% Cell type:code id:f700e78d-fc0e-4526-a599-8d2cb84e72c0 tags:
```
python
netem
.
destroy
()
```
%% Cell type:markdown id:b3d4aa17-33d1-497f-b418-5b0c35b0f281 tags:
### Filter on specific network
%% Cell type:code id:1a68136d-1d12-4b0d-a8be-fa2a8ece2c57 tags:
```
python
# enable ipv6
en
.
run_command
(
"
dhclient -6 br0
"
,
roles
=
roles
)
# sync the info
roles
=
en
.
sync_info
(
roles
,
networks
)
```
%% Cell type:code id:d95bc786-d4b4-4ca4-a363-f5457affc308 tags:
```
python
networks
```
%% Cell type:code id:91758b1d-9c57-4f4f-8979-04ce2d694b30 tags:
```
python
ipv6_network
=
networks
[
"
prod
"
][
1
]
ipv6_network
```
%% Cell type:code id:f3c4d488-e102-4a9a-b8b4-30f6dd1c2c94 tags:
```
python
netem
=
en
.
NetemHTB
()
(
netem
.
add_constraints
(
src
=
roles
[
"
paris
"
],
dest
=
roles
[
"
londres
"
],
delay
=
"
5ms
"
,
rate
=
"
1gbit
"
,
symmetric
=
True
,
networks
=
[
ipv6_network
]
)
.
add_constraints
(
src
=
roles
[
"
paris
"
],
dest
=
roles
[
"
berlin
"
],
delay
=
"
10ms
"
,
rate
=
"
1gbit
"
,
symmetric
=
True
,
networks
=
[
ipv6_network
]
)
.
add_constraints
(
src
=
roles
[
"
londres
"
],
dest
=
roles
[
"
berlin
"
],
delay
=
"
15ms
"
,
rate
=
"
1gbit
"
,
symmetric
=
True
,
networks
=
[
ipv6_network
]
)
)
```
%% Cell type:code id:c9e32e27-05d8-4715-ba18-2580f400ec06 tags:
```
python
netem
.
deploy
()
```
%% Cell type:code id:80d59e6c-fdbf-497b-a3ca-cc92711eb770 tags:
```
python
netem
.
validate
(
output_dir
=
"
custom_topology_ipv6
"
)
```
%% Cell type:code id:18172c7b-1dc6-4959-834c-80b32f2ba8fe tags:
```
python
import
enoslib
as
en
import
pandas
as
pd
stats
=
en
.
Netem
.
fping_stats
(
"
custom_topology_ipv6
"
)
pd
.
DataFrame
(
stats
,
columns
=
[
"
src
"
,
"
dest
"
,
"
ping values
"
])
```
%% Cell type:code id:b60392b8-7de6-4974-a7eb-f32c9e14007b tags:
```
python
provider
.
destroy
()
```
%% Cell type:markdown id:146e5c01-34a1-480e-a7bd-d0c8bc469bf3 tags:
## Scaling
With this we can emulate a multiple Datacenter topology. Intra datacenter link are subject to LAN links while inter-datacenter topology are subject to WAN links.

%% Cell type:code id:8d82b069-a6c7-4d0f-b32a-ec9f07a4ba48 tags:
```
python
conf
=
(
en
.
VMonG5kConf
.
from_settings
(
job_name
=
"
labs_netem
"
)
.
add_machine
(
roles
=
[
"
city
"
,
"
paris
"
],
cluster
=
"
parasilo
"
,
number
=
5
,
flavour
=
"
tiny
"
)
.
add_machine
(
roles
=
[
"
city
"
,
"
londres
"
],
cluster
=
"
parasilo
"
,
number
=
5
,
flavour
=
"
tiny
"
)
.
add_machine
(
roles
=
[
"
city
"
,
"
berlin
"
],
cluster
=
"
parasilo
"
,
number
=
5
,
flavour
=
"
tiny
"
)
.
finalize
()
)
conf
```
%% Cell type:code id:c0b067f8-a63d-4bd3-8599-a03a13b9d914 tags:
```
python
vmon5k
=
en
.
VMonG5k
(
conf
)
```
%% Cell type:code id:45cc0b6e-2c30-45d9-8ff7-3abcd23d868c tags:
```
python
``
`
%%
Cell
type
:
code
id
:
3
b38edcd
-
3138
-
4
a53
-
bfde
-
81
f264256a55
tags
:
```
python
vm_roles, vm_networks = vmon5k.init()
```
%% Cell type:code id:6f16f011-d4c4-4e27-86bf-dfb81bd6d4be tags:
```
python
vm_roles = en.sync_info(vm_roles, vm_networks)
```
%% Cell type:code id:c36934b0-149d-4912-aa72-7796a32c0cfa tags:
```
python
netem = en.NetemHTB()
(
netem.add_constraints(
src=vm_roles["paris"],
dest=vm_roles["londres"],
delay="5ms",
rate="1gbit",
symmetric=True,
)
.add_constraints(
src=vm_roles["paris"],
dest=vm_roles["berlin"],
delay="10ms",
rate="1gbit",
symmetric=True,
)
.add_constraints(
src=vm_roles["londres"],
dest=vm_roles["berlin"],
delay="15ms",
rate="1gbit",
symmetric=True,
)
)
netem
```
%% Cell type:code id:6c26602a-63bb-4494-82f5-a51bf62303a0 tags:
```
python
_ = netem.deploy()
```
%% Cell type:code id:22cc6f9a-6edb-4734-9999-2ca83b69b0f0 tags:
```
python
netem.validate(output_dir="scaling_topology")
```
%% Cell type:code id:0211d7cd-18f4-4ebf-8c6a-c322046c5b1c tags:
```
python
import enoslib as en
import pandas as pd
stats = en.Netem.fping_stats("scaling_topology")
pd.DataFrame(stats, columns=["src", "dest", "ping values"])
```
%% Cell type:code id:77387025-fa39-4b4f-94ef-0c92bd4d76e5 tags:
```
python
netem.destroy()
```
%% Cell type:code id:789589ed tags:
```
python
provider.destroy()
```
%% Cell type:code id:7ef0788b-f14f-4931-a6c0-329e7c655a60 tags:
```
python
```
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment