Skip to content

Commit

Permalink
Init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Ignacio Peletier committed Jun 2, 2021
0 parents commit 0a4d38d
Show file tree
Hide file tree
Showing 11 changed files with 787 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea
env/
91 changes: 91 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Network Emulation

This is a simple wrapper to concatenate network conditions using `tc-netem `
by means of a simple configuration file.

### Configuration Files
The configuration files have the following structure:

```
{
"name": "example",
"interface": "wlp3s0",
"events": {
"1": {
"duration": 5000,
"rules": [
"clear"
]
},
"2": {
"duration": 15000,
"rules": [
"delay 30ms 10ms distribution normal",
"loss 0.1% 0.25%"
]
},
"3": {
"duration": 10000,
"rules": [
"delay 50ms"
]
},
"4": {
"duration": 5000,
"rules": [
"clear"
]
}
}
}
```

`name`: name of the experiment.

`interface`: interface where the network conditions will be applied.

`events`: list of ordered network conditions.

Each `event` should be tagged by an integer that indicates the order. The
range should be from 1 to N, being N the number of events that will be applied.

Inside the event `duration` indicates in milliseconds the duration of the
network conditions.

`rules` is a list of the conditions that will be applied during the event.
This is where the filters from `tc-netem` should be written. For more info,
take a look at the [tc-netem docs](http://man7.org/linux/man-pages/man8/tc-netem.8.html).

A special rule, that has nothing to do with the `tc-netem` commands has been
created. This rule means that all conditions will be cleared. It is recommended
to always have this rule as the last one to make sure the network conditions are
cleared once the simulation has been finished. It can also be used to add
intervals in the simulation with no conditions applied.

It is important to note that each event **overwrites** its predecessor. If
a condition needs to be kept from an event, it should be included in the next event.

### Explanation of [example.json](configs/example.json)

Here follows an explanation of the example provided in the repo.

The configuration is named `example` and the conditions will be applied to
the interface `wlp3s0`. It has a total of 4 events:

1. The first event lasts 5 seconds and there are no conditions applied.
2. Applies a delay that follows a gaussian distribution of mean 30ms and
standard deviation (jitter) of 10ms. It also adds a 0.1% packet loss with
a correlation of 0.25%. This correlation is used to simulate burst errors. This
event has a duration of 15 seconds.
3. This event is 10 second long and adds a constant 50ms delay.
4. The simulation is finished by 5 seconds of cleared conditions,



### Notes

The code has been tested with python 3.6.9. There is no need of additional python libraries.

When specifying the jitter with a rule such as `delay 30ms 10ms`, an
erroneous behaviour has been noted, so it is better to fix the distribution,
such as `delay 30ms 10ms distribution normal`.
31 changes: 31 additions & 0 deletions configs/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "example",
"interface": "wlp3s0",
"events": {
"1": {
"duration": 5000,
"rules": [
"clear"
]
},
"2": {
"duration": 15000,
"rules": [
"delay 30ms 10ms distribution normal",
"loss 0.1% 0.25%"
]
},
"3": {
"duration": 10000,
"rules": [
"delay 50ms"
]
},
"4": {
"duration": 5000,
"rules": [
"clear"
]
}
}
}
60 changes: 60 additions & 0 deletions configs/experiment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"name": "test",
"interface": "wlp3s0",
"events": {
"1": {
"duration": 20000,
"rules": [
"rate 10mbit"
]
},
"2": {
"duration": 3000,
"rules": [
"rate 10mbit",
"delay 10ms 1ms distribution normal"
]
},
"3": {
"duration": 3000,
"rules": [
"rate 10mbit",
"delay 15ms 1ms distribution normal"
]
},
"4": {
"duration": 6000,
"rules": [
"rate 10mbit",
"delay 20ms 2ms distribution normal",
"loss 1%"
]
},
"5": {
"duration": 3000,
"rules": [
"rate 10mbit",
"delay 15ms 1ms distribution normal"
]
},
"6": {
"duration": 3000,
"rules": [
"rate 10mbit",
"delay 10ms 1ms distribution normal"
]
},
"7": {
"duration": 85000,
"rules": [
"rate 10mbit"
]
},
"8": {
"duration": 1000,
"rules": [
"clear"
]
}
}
}
102 changes: 102 additions & 0 deletions configs/experiment_long_valley.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"name": "test",
"interface": "wlp3s0",
"events": {
"1": {
"duration": 20000,
"rules": [
"rate 10mbit"
]
},
"2": {
"duration": 3000,
"rules": [
"rate 9mbit"
]
},
"3": {
"duration": 3000,
"rules": [
"rate 8mbit"
]
},
"4": {
"duration": 3000,
"rules": [
"rate 7mbit"
]
},
"5": {
"duration": 3000,
"rules": [
"rate 6mbit"
]
},
"6": {
"duration": 3000,
"rules": [
"rate 5mbit"
]
},
"7": {
"duration": 3000,
"rules": [
"rate 4mbit"
]
},
"8": {
"duration": 43000,
"rules": [
"rate 3mbit"
]
},
"9": {
"duration": 3000,
"rules": [
"rate 4mbit"
]
},
"10": {
"duration": 3000,
"rules": [
"rate 5mbit"
]
},
"11": {
"duration": 3000,
"rules": [
"rate 6mbit"
]
},
"12": {
"duration": 3000,
"rules": [
"rate 7mbit"
]
},
"13": {
"duration": 3000,
"rules": [
"rate 8mbit"
]
},
"14": {
"duration": 3000,
"rules": [
"rate 9mbit"
]
},
"15": {
"duration": 261000,
"rules": [
"rate 10mbit"
]
},
"16": {
"duration": 1000,
"rules": [
"clear"
]
}
}
}
102 changes: 102 additions & 0 deletions configs/experiment_rate_limit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"name": "test",
"interface": "wlp3s0",
"events": {
"1": {
"duration": 20000,
"rules": [
"rate 10mbit"
]
},
"2": {
"duration": 3000,
"rules": [
"rate 9mbit"
]
},
"3": {
"duration": 3000,
"rules": [
"rate 8mbit"
]
},
"4": {
"duration": 3000,
"rules": [
"rate 7mbit"
]
},
"5": {
"duration": 3000,
"rules": [
"rate 6mbit"
]
},
"6": {
"duration": 3000,
"rules": [
"rate 5mbit"
]
},
"7": {
"duration": 3000,
"rules": [
"rate 4mbit"
]
},
"8": {
"duration": 3000,
"rules": [
"rate 3mbit"
]
},
"9": {
"duration": 3000,
"rules": [
"rate 4mbit"
]
},
"10": {
"duration": 3000,
"rules": [
"rate 5mbit"
]
},
"11": {
"duration": 3000,
"rules": [
"rate 6mbit"
]
},
"12": {
"duration": 3000,
"rules": [
"rate 7mbit"
]
},
"13": {
"duration": 3000,
"rules": [
"rate 8mbit"
]
},
"14": {
"duration": 3000,
"rules": [
"rate 9mbit"
]
},
"15": {
"duration": 301000,
"rules": [
"rate 10mbit"
]
},
"16": {
"duration": 1000,
"rules": [
"clear"
]
}
}
}
Loading

0 comments on commit 0a4d38d

Please sign in to comment.