{"id":21336123,"url":"https://github.com/lcodecorex/weaknetwork","last_synced_at":"2025-07-29T00:08:26.594Z","repository":{"id":211028658,"uuid":"76026923","full_name":"lcodecorex/WeakNetwork","owner":"lcodecorex","description":"A software package of OpenWrt that can help you to build a perfect weak network environment. (一个方便搭建并配置弱网测试环境的软件包。)","archived":false,"fork":false,"pushed_at":"2016-12-13T12:17:46.000Z","size":17794,"stargazers_count":38,"open_issues_count":1,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-06T19:38:36.151Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Lua","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/lcodecorex.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-09T10:42:14.000Z","updated_at":"2025-03-14T03:20:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"2542f707-9d75-4ec2-872f-300d5b3c3574","html_url":"https://github.com/lcodecorex/WeakNetwork","commit_stats":null,"previous_names":["lcodecorex/weaknetwork"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lcodecorex/WeakNetwork","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lcodecorex%2FWeakNetwork","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lcodecorex%2FWeakNetwork/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lcodecorex%2FWeakNetwork/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lcodecorex%2FWeakNetwork/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lcodecorex","download_url":"https://codeload.github.com/lcodecorex/WeakNetwork/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lcodecorex%2FWeakNetwork/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267606553,"owners_count":24114748,"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","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-11-21T23:51:13.922Z","updated_at":"2025-07-29T00:08:26.589Z","avatar_url":"https://github.com/lcodecorex.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WeakNetwork\nA software package of OpenWrt that can help you to build a perfect weak network environment. (一个方便搭建并配置完美弱网测试环境的软件包。)\n\n因业务需求，笔者需要搭建一个弱网环境，来测试设备在弱网环境下的表现。现在已有一些弱网模拟工具，微软有Network Emulator for Windows Toolkit（NEWT），Facebook有Augmented Traffic Control（ATC），这些方式要么是通过代理，要么就是只能实现wifi丢包，我们需要模拟网口的丢包，因此只能借助于开源的OpenWrt linux系统，调用其tc命令来控制流量，实现丢包、传输延时等。\n\n![](./weaknetwork_show.jpg)\n\n![](./netem.png)\n\n![](./nettc.png)\n\n`dist`目录是笔者编译好的软件包和已经带弱网包的极壹和极三的固件。`luci-app-weaknetwork_1.0-1_all.ipk`弱网模拟软件包与硬件无关，理论上带有netem工具的OpenWrt系统都可以正常安装使用。\n\n`openwrt-build-base.zip`包含了极壹和极三的编译基础包，已经配置好，加入了弱网包，make menuconfig之后再make就行(会下载其它依赖)。\n\n## 使用弱网环境包的方式\n### 方式一：直接在OpenWrt系统中安装ipk软件包\n前提条件：路由器固件需要支持**netem**工具，若安装软件包后操作无效，可以尝试方式二(编译固件)\n\na) 方式1：在OpenWrt Web管理页面中安装\n\n//需要在系统 --\u003e 软件包 --\u003e 配置，添加包的配置信息，暂时不可用\n\nb) 方式2：使用ssh安装\n```\nscp luci-app-weaknetwork.ipk root@192.168.1.1:/tmp/uci-app-weaknetwork.ipk\n```\n\n进入ssh:\n```\ncd /tmp\nopkg update\nopkg install uci-app-weaknetwork.ipk\n```\n\n### 方式二：重新编译路由器OpenWrt固件\n#### 1. 安装必要工具\n```\nsudo apt-get install  libncurses5-dev  zlib1g-dev  gawk  flex  patch   git-core g++   subversion\n```\n#### 2. 把`luci-app-weaknetwork`文件夹整体复制到`你的固件包/openwrt-ar71xx/package`目录下，若没有这个目录，就是`你的固件包/openwrt-ramips/package`下，总是就是OpenWrt存放package软件包的地方。\n#### 3. 支持netem工具\n修改固件包目录下的一个`config-xxx`的文件（更建议在menuconfig里面修改）并取消前面的注释符：\n```\nCONFIG_PACKAGE_kmod-netem=y\nCONFIG_PACKAGE_kmod-sched-core=y\nCONFIG_PACKAGE_kmod-sched=y\n```\n\n#### 4. make menuconfig\n进入固件包下执行上述命令，看有没有LuCI相关配置，如果没有的话，需要更新一下：\n\na) 更新openwrt包(luci包等)\n```\n./scrips/feeds update -a\n./scrips/feeds install -a -p\n```\n\n也可以只更新luci包：\n \n ```\n./scripts/feeds update packages luci\n./scripts/feeds install -a -p luci\n```\n\nb) 之后按如下方式配置下：\n```\nTarget System (x86)\n       Subtarget (Generic)\n       Target Profile (Generic)\n       Target Image --\u003e\n              \u003c \u003e jffs2\n              \u003c \u003e squashfs\n              \u003c \u003e tgz\n              \u003c* \u003e Build VMware image files (VMDK). Requires qemu-img\n \n       Network --\u003e\n              \u003c*\u003e uhttpd\n \n       LuCI --\u003e\n          Collections --\u003e\n               \u003c * \u003e luci\n          Applications--\u003e\n              \u003c* \u003e luci-app-ddns\n              \u003c* \u003e luci-app-firewall\n              \u003c* \u003e luci-app-ntpc\n              \u003c* \u003e luci-app-samba\n          Themes--\u003e全选\n          Translations --\u003e\n              \u003c* \u003e luci-i18n-chinese\n```\n\nc) 进入`LuCI --\u003e Applications --\u003e luci-app-weaknetwork`,选中\n\nd) 进入`Network --\u003e WebServers/Proxies  --\u003e pdnsd`，一个dns代理服务器，取消该项的选中，可能是由于要翻墙的原因，笔者这里不取消编译不能通过\n\n#### 5.编译\n命令行输入`make V=99`（编译时显示详细信息）\n\n#### 6. 刷写固件\n```\nscp recovery.bin root@192.168.199.1:/tmp/recovery.bin  #拷贝你的固件到此\ncd /tmp\nsysupgrade -F -n recovery.bin\n```\n\n重启，完成！\n\n注：带宽限制需要内核支持CBQ队列，若带宽限制设置无效，可能是当前的内核不支持。\n\n![](http://lcodecorex.github.io/assets/blogImg/weak-network-bridge.png)\n\n更多相关内容可以查看笔者的[博客](http://lcodecorex.github.io/2016/11/10/%E6%9E%81%E5%A3%B9%20+%20OpenWRT%20+%20tc:netem%20%E6%90%AD%E5%BB%BA%E5%BC%B1%E7%BD%91%E7%8E%AF%E5%A2%83/)。","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flcodecorex%2Fweaknetwork","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flcodecorex%2Fweaknetwork","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flcodecorex%2Fweaknetwork/lists"}