You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-16Lines changed: 16 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,25 +4,28 @@ This discrete-event network simulator is based on [`simpy`](https://simpy.readth
4
4
5
5
## Installation
6
6
7
-
First, launch the terminal and create a new `conda` environment (say, called `ns.py`):
7
+
### From PyPI
8
8
9
9
```shell
10
-
$ conda update conda
11
-
$ conda create -n ns.py python=3.9
12
-
$ conda activate ns.py
10
+
pip install ns.py
13
11
```
14
12
15
-
Then, install `ns.py` using `pip`:
13
+
### Local development with uv
16
14
17
-
```shell
18
-
$ pip install ns.py
19
-
```
15
+
1. Install [uv](https://docs.astral.sh/uv/getting-started/installation/) if it's not already on your machine.
16
+
2. Sync the project and provision a Python 3.13 virtual environment:
20
17
21
-
That's it! You can now try to run some examples in the `examples/` directory. To upgrade Python packages in the current environment, run the command:
18
+
```shell
19
+
uv sync
20
+
```
22
21
23
-
```shell
24
-
$ python upgrade_packages.py
25
-
```
22
+
3. Run commands through `uv run` so they pick up the synced environment. For example:
23
+
24
+
```shell
25
+
uv run examples/basic.py
26
+
```
27
+
28
+
`uv sync` installs `ns.py` in editable mode along with its dependencies, so subsequent `uv run …` invocations (tests, builds, examples) share the exact same interpreter and packages.
26
29
27
30
## Current network components
28
31
@@ -90,8 +93,6 @@ The network components that have already been implemented include:
90
93
91
94
## Current examples (in increasing levels of complexity)
92
95
93
-
Some of these examples requires installing `matplotlib`. It has not been included in the list of dependencies in `ns.py`, and needs to be installed separately in the current Python environment.
94
-
95
96
*`basic.py`: A basic example that connects two packet generators to a network wire with a propagation delay distribution, and then to a packet sink. It showcases `DistPacketGenerator`, `PacketSink`, and `Wire`.
96
97
97
98
*`overloaded_switch.py`: an example that contains a packet generator connected to a downstream switch port, which is then connected to a packet sink. It showcases `DistPacketGenerator`, `PacketSink`, and `Port`.
@@ -126,7 +127,7 @@ Similar to the emulation mode in the ns-3 simulator, `ns.py` supports an *emulat
126
127
<imgsrc="https://github.com/TL-System/ns.py/blob/main/docs/emulation/emulation_mode.svg"alt="High-level overview of ns.py's emulation mode"/>
127
128
</p>
128
129
129
-
`examples/real_traffic/proxy.py` has been provided as an example that shows how a real-world client and server can communicate using a simulated network environment as the proxy, and how `ProxyPacketGenerator` and `ProxySink` are to be used to achieve this objective.
130
+
`examples/real_traffic/proxy.py` has been provided as an example that shows how a real-world client and server can communicate using a simulated network environment as the proxy, and how `ProxyPacketGenerator` and `ProxySink` are to be used to achieve this objective.
130
131
131
132
### Testing the emulation mode with simple TCP and UDP echo servers
Most often, the mapping between flow IDs and per-flow parameters, such as weights in a Weighted Fair Queueing scheduler or priorities in a Static Priority scheduler, need to be stored in a dictionary, and then used to initialized these schedulers. An optional (but not recommended) style is to assign consecutive integers as flow IDs to the flows throughout the entire network, and then use simple lists of per-flow parameters to initialize the schedulers. In this case, flow IDs will be directly used as indices to look up these lists to find the parameter values.
0 commit comments