{"id":16191901,"url":"https://github.com/streamr-dev/lnem","last_synced_at":"2025-04-07T14:48:36.585Z","repository":{"id":46649127,"uuid":"352904394","full_name":"streamr-dev/lnem","owner":"streamr-dev","description":"Lighweight Network EMulator","archived":false,"fork":false,"pushed_at":"2021-10-12T09:55:30.000Z","size":15,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-03T00:56:40.738Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/streamr-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-30T07:09:13.000Z","updated_at":"2024-12-26T08:50:24.000Z","dependencies_parsed_at":"2022-09-22T14:25:29.853Z","dependency_job_id":null,"html_url":"https://github.com/streamr-dev/lnem","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamr-dev%2Flnem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamr-dev%2Flnem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamr-dev%2Flnem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamr-dev%2Flnem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/streamr-dev","download_url":"https://codeload.github.com/streamr-dev/lnem/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247675627,"owners_count":20977376,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T08:07:39.433Z","updated_at":"2025-04-07T14:48:36.549Z","avatar_url":"https://github.com/streamr-dev.png","language":"Shell","readme":"# Lightweight Network EMulator\n\nLightweight Network EMulator simplifies integration testing of network applications on Linux. It is implemented as a collection of easy-to-use \nBash scripts on top of Linux network namespaces and Netem.\n\n## How it works \nLightweight Network EMulator creates a number of Linux network namespaces and places them in a star topology around the host machine. \nThe network namespaces are named blue1, blue2, ... , blueN. Each network namespace is connected to the host with the help of a pair of virtual ethernet devices. For network namespace blueN, the virtual ethernet devices are named vethrealN and vethvirtualN, respectively. The device vethvirtualN is only visible\nfrom the namespace blueN, and the device vethrealN is visible from the host. The connection between the vethrealN and vethvirtualN devices is traffic-shaped using Netem and the tc command to introduce emulated latency, and limits for the uplink and downlink bandwidth. The emulated network uses the 10.240.0.0/12 network range. In case of emulated  networks with less than 255 namespaces, the IP adderess of the device vethrealN is 10.240.N.1 and the IP address of device vethvirtualN 10.240.N.2, respectively. All routing towards the other network namespaces and the Internet goes through the host machine.\n\n\n\n\n\n\n```\n                                          Internet \n                                             |                                       \n  ___________________                        |                         ___________________\n |                   |                       |                        |                   |\n |  vethvirtual1     |----- vethreal1 ----- host ----- vethreal2 -----|  vethvirtual2     |  \n |  10.240.1.2       |      10.240.1.1       |         10.240.2.1     |  10.240.2.2       |\n |  namespace blue1  |                       |                        |  namespace blue2  |\n |___________________|                       |                        |___________________|   \n                                         vethrealN\n                                         10.240.N.1  \n                                             |\n                                             |  \n                                             |\n                                     ___________________ \n                                    |                   |\n                                    |  vethvirtualN     |\n                                    |  10.240.N.2       |\n                                    |  namespace blueN  | \n                                    |___________________|   \n\n\n```\n\n## Prerequisites\n\n* A Linux host with a 5.x+ kernel and root privilleges  (use a dedicated virtual machine to stay safe)\n* The following Debian packages (or equivivalent):\n\n```\nsudo apt-get install iproute2\nsudo apt-get install net-tools\n```\n\n* Ensure that ipv4 forwarding is enabled (if pings will not go through this is most likely disabled)\n\n```\nsudo sysctl -w net.ipv4.ip_forward=1\nsudo sysctl -p /etc/sysctl.conf\n```\n\n[more info on how to make the ip forwarding change permanent](https://askubuntu.com/questions/311053/how-to-make-ip-forwarding-permanent)\n\n* You need a working nodejs and npm setup if you intend to install the scripts globally using npm. Alternatively you can directly execute the scripts from the bin folder \n\n## Installing using npm\n\n```\nsudo npm install -g @streamr/lnem\n```\n\n## Uninstalling using npm\n\n```\nsudo npm uninstall -g @streamr/lnem\n```\n\n## Connecting the emulated network to Internet through NAT\n\nIf you wish your emulated network to be able to connect to the Internet, you\ncan set uo NAT using the script: \n\n```\nsudo lnem-create-nat\n```\n\n## Disconnecting the emulated network from Internet\n\nThe NAT can be deleted using the script:\n\n```\nsudo lnem-delete-nat\n```\n\n## Usage examples\n\n## Measuring emulated network using ping and netperf\n\nInstall netperf \n\n```\nsudo apt-get install netperf\n```\n\nCreate a network namespace for the netperf server with download bandwidth limit of 1000 kbit/s, upload bandwidth limit of 2000 kbit/s, and\none-way latency of 10 ms between the namespace and the host machine.\n\n```\nsudo lnem-up --download 1000 --upload 2000 --latency 10 --num 1\n```\n\nCreate a network namespace for the netperf client with no limits. Notice that we give the offset parameter\nto start creating the network namespaces starting from namespace blue2, since namespace blue1 is already in use by the server.\n\n```\nsudo lnem-up --num 1 --offset 2\n```\n\nMeasure the RTT between the blue1 and blue2 network namespaces using ping\n\n```\nsudo ip netns exec blue2 ping 10.240.1.2\n```\n\nStart the netperf server in the blue1 namespace\n\n```\nsudo ip netns exec blue1 netserver -4 \u0026\n```\n\n\nRun the netperf client in the blue2 namespace, and instruct it to connect to the server running in namespace blue2. The result should\nbe close to 1 Mibit/s (the download bandwidth limit we set to the server's namespace)\n\n```\nsudo ip netns exec blue2 netperf -4 -H 10.240.1.2 \n```\n\nTo clean up, kill netperf server, and delete the two namespaces.\n\n```\nsudo pkill netserver\nsudo lnem-down -n 2\n```\n\n\n## License\n\nThis project is licensed under the MIT License.\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstreamr-dev%2Flnem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstreamr-dev%2Flnem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstreamr-dev%2Flnem/lists"}