当前位置: 首页 > news >正文

专业旅游网站建设app开发者需要更新此app

专业旅游网站建设,app开发者需要更新此app,wordpress 还原备份数据库备份,wordpress 图片丢失背景 近日做实验,需要限制一些机子的带宽以达到模拟的效果。在网上搜索了一阵子,结合自己实操的经验,潦草写下这篇文章,供自己与有需要的人参考。 环境: Ubuntu 22.04.1 LTS 安装 wondershaper 和 speedtest-cli w…

背景

近日做实验,需要限制一些机子的带宽以达到模拟的效果。在网上搜索了一阵子,结合自己实操的经验,潦草写下这篇文章,供自己与有需要的人参考。

环境: Ubuntu 22.04.1 LTS

安装 wondershaper 和 speedtest-cli

wondershaper 是一个用来管理带宽的工具,使用它可以快速地设置一台机子上某个网口的上行和下行最大带宽。

首先从github上拉取最新的包
git clone https://github.com/magnific0/wondershaper.git
然后安装
cd wondershaper
sudo make install

speedtest-cli 是一个测量网速的工具,可以用它来验证 wondershaper 是否设置成功。
sudo apt install speedtest-cli
安装完成后可以运行一下,测试本机当前的网速,测速过程有些慢,可能需要两三分钟。
speedtest
这是我的结果

hh@pc02:~$ speedtest
Retrieving speedtest.net configuration...
Testing from China Unicom (58.249.112.15)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Telstra International (Hong Kong) [60.86 km]: 26.282 ms
Testing download speed................................................................................
Download: 28.95 Mbit/s
Testing upload speed......................................................................................................
Upload: 35.80 Mbit/s

查看本机的网口

运行
ifconfig
即可看到本机的网口,从中选择你要设置的网口。

hh@pc02:~$ ifconfig
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500inet 192.168.3.5  netmask 255.255.255.0  broadcast 192.168.3.255inet6 fe80::3eec:efff:feb1:9b40  prefixlen 64  scopeid 0x20<link>ether 3c:ec:ef:b1:9b:40  txqueuelen 1000  (以太网)RX packets 91440274  bytes 105110205902 (105.1 GB)RX errors 0  dropped 3063  overruns 0  frame 0TX packets 84440960  bytes 100752219041 (100.7 GB)TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0eno2: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500ether ac:1f:6b:87:59:3a  txqueuelen 1000  (以太网)RX packets 0  bytes 0 (0.0 B)RX errors 0  dropped 0  overruns 0  frame 0TX packets 0  bytes 0 (0.0 B)TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0device interrupt 16  memory 0xaae00000-aae20000

我选择对 eno1 网口进行设置。

配置 wondershaper

首先创建配置文件
sudo vim /etc/systemd/wondershaper.conf
在其中写入以下内容

[wondershaper]# Adapter
IFACE="eno1"# Download rate in Kbps
DSPEED="5120"# Upload rate in Kbps
USPEED="1024"

其中三个参数分别是想要设置的网口名称、网口下载带宽和网口上传带宽。这里我将下载带宽设置为5Mbps,上传带宽设置为1Mbps。
如果发现这个文件已经存在,则直接修改这三个参数即可,其它不用管。

然后创建以下文件
sudo vim /etc/systemd/system/wondershaper.service
在其中写入以下内容

[Unit]
Description=Bandwidth shaper/Network rate limiter
After=network-online.target
Wants=network.target[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/systemd/wondershaper.conf
ExecStart=/usr/local/sbin/wondershaper -a $IFACE -d $DSPEED -u $USPEED
ExecStop=/usr/local/sbin/wondershaper -c -a $IFACE[Install]
WantedBy=multi-user.target

注意,ExecStart和ExecStop这两个命令用到了刚刚安装的wondershaper,如果你的wondershaper不是安装在/usr/local/sbin/wondershaper这个目录,则需要修改一下。可以通过 which wondershaper看看包所在的目录。

启动和关闭 wondershaper

完成上一步的配置后,运行
sudo systemctl enable --now wondershaper.service以启动wondershaper服务,开始对指定网口进行限速。
你可以通过
systemctl status wondershaper.service 查看该服务的启动情况,以下是我的结果,说明启动成功了。

h@pc02:~/wondershaper$ systemctl status wondershaper.service
● wondershaper.service - Bandwidth shaper/Network rate limiterLoaded: loaded (/etc/systemd/system/wondershaper.service; enabled; vendor preset: enabled)Active: active (exited) since Thu 2023-11-09 20:50:47 CST; 1min 48s agoProcess: 738786 ExecStart=/usr/local/sbin/wondershaper -a $IFACE -d $DSPEED -u $USPEED (code=exited, status=0/SUCCESS)Main PID: 738786 (code=exited, status=0/SUCCESS)

测试当前的网速
speedtest
可以看到网速成功降下来了

huanglab@pc02:~/wondershaper$ speedtest
Retrieving speedtest.net configuration...
Testing from China Unicom (58.249.112.15)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Telstra International (Hong Kong) [60.86 km]: 21.886 ms
Testing download speed................................................................................
Download: 4.74 Mbit/s
Testing upload speed......................................................................................................
Upload: 1.38 Mbit/s

不过上传速度好像超出了我设置的1Mbps…

总之整个过程大概就是这样啦。
如果用完想恢复原来的带宽设置,只需取消wondershaper的服务即可,运行以下命令:
systemctl disable --now wondershaper.service
重新用speedtest测量一下网速,应该可以恢复设置之前的样子了。

更改带宽配置

完成第一次带宽配置后,如果之后想重新配置带宽,只需修改wondershaper.conf,并且
先disable
sudo systemctl disable --now wondershaper.service
再enable
sudo systemctl enable --now wondershaper.service
相当于重新启动该服务,使用新的参数。

更方便的测试方法

过了几天发现一个更方便地测试带宽的方法,介绍如下。
假设你已经按照前面的指引安装和配置了wondershaper,接下来只需安装 iperf3。
sudo apt-get install iperf3
iperf3是一个测试工具,可以测试两台机器之间的带宽。

将一台机器作为服务端,运行:
iperf3 -s
该机器会开始监听。

将另一台服务器作为客户端,运行:
iperf3 -c [服务器的ip]

hh@:~$ iperf3 -c 192.168.3.2
Connecting to host 192.168.3.2, port 5201
[  5] local 192.168.3.4 port 41590 connected to 192.168.3.2 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec   114 MBytes   958 Mbits/sec    0    393 KBytes
[  5]   1.00-2.00   sec   112 MBytes   942 Mbits/sec    0    393 KBytes
[  5]   2.00-3.00   sec   112 MBytes   943 Mbits/sec    0    411 KBytes
[  5]   3.00-4.00   sec   112 MBytes   942 Mbits/sec    0    411 KBytes
[  5]   4.00-5.00   sec   112 MBytes   942 Mbits/sec    0    430 KBytes
[  5]   5.00-6.00   sec   112 MBytes   942 Mbits/sec    0    430 KBytes
[  5]   6.00-7.00   sec   112 MBytes   941 Mbits/sec    0    430 KBytes
[  5]   7.00-8.00   sec   112 MBytes   941 Mbits/sec    0    430 KBytes
[  5]   8.00-9.00   sec   112 MBytes   936 Mbits/sec    0    430 KBytes
[  5]   9.00-10.00  sec   112 MBytes   941 Mbits/sec    0    430 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec  1.10 GBytes   943 Mbits/sec    0             sender
[  5]   0.00-10.00  sec  1.10 GBytes   941 Mbits/sec                  receiveriperf Done.

测试大约10秒钟,这是没限制带宽之前的网速。
使用wondershaper限制客户端的带宽之后,再次测试,结果如下:

hh@:~$ iperf3 -c 192.168.3.2
Connecting to host 192.168.3.2, port 5201
[  5] local 192.168.3.4 port 41594 connected to 192.168.3.2 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  1.00 MBytes  8.41 Mbits/sec    0   74.9 KBytes
[  5]   1.00-2.00   sec   509 KBytes  4.17 Mbits/sec    0   74.9 KBytes
[  5]   2.00-3.00   sec   509 KBytes  4.17 Mbits/sec    0   74.9 KBytes
[  5]   3.00-4.00   sec   679 KBytes  5.56 Mbits/sec    0   74.9 KBytes
[  5]   4.00-5.00   sec   509 KBytes  4.17 Mbits/sec    0   74.9 KBytes
[  5]   5.00-6.00   sec   509 KBytes  4.17 Mbits/sec    0   74.9 KBytes
[  5]   6.00-7.00   sec   679 KBytes  5.56 Mbits/sec    0   74.9 KBytes
[  5]   7.00-8.00   sec   509 KBytes  4.17 Mbits/sec    0   74.9 KBytes
[  5]   8.00-9.00   sec   509 KBytes  4.17 Mbits/sec    0   74.9 KBytes
[  5]   9.00-10.00  sec   679 KBytes  5.56 Mbits/sec    0   74.9 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec  5.97 MBytes  5.01 Mbits/sec    0             sender
[  5]   0.00-10.00  sec  5.55 MBytes  4.65 Mbits/sec                  receiveriperf Done.

可以看到网速明显地降下来了。

参考

https://averagelinuxuser.com/limit-bandwidth-linux/#install-wondershaper
https://wangchujiang.com/linux-command/c/speedtest-cli.html

http://www.15wanjia.com/news/50253.html

相关文章:

  • 网站建设与管理学什么百度如何推广产品
  • 网站首页横版图怎么做最打动人心的广告语
  • 室内设计做效果图可以接单的网站seo网站推广服务
  • 使用joomla的网站网站宣传推广文案
  • 苏州实力做网站公司有哪些上海最新事件
  • wordpress两个站点文章同步广告外链购买交易平台
  • 贵阳手机网站制作免费域名解析网站
  • 什么网站做淘宝素材比较好百度快照怎么做
  • 网站做推广搜索引擎优化seo应用
  • cad二次开发网站营销网址
  • 汽车o2o网站建设软文推广网站
  • 吉林城市建设学校网站移动建站模板
  • 用国外服务器做网站广州疫情最新动态
  • 毕业论文个人网站建设个人网站设计图片
  • 美国主机网站建设数据分析培训班
  • 给网站做选题百度浏览器app下载
  • 上海免费网站建设模板推荐百度指数关键词工具
  • wordpress垃圾账号注册武汉网络优化知名乐云seo
  • 网站关键词符号简述网站建设流程
  • 企业网站欣赏网络营销工具和方法
  • 做网站要学那些东西投放广告的渠道有哪些
  • 怎么样做个网站seo外包
  • 中山做网站优化我的百度购物订单
  • 安监局网站做应急预案备案常见的营销手段
  • 兰州易天网站建设公司有哪些?市场调研
  • 网站建设黄页惠州seo按天计费
  • 赣州企业做网站品牌推广策略有哪几种
  • 招聘网站开发人员东莞做网络推广的公司
  • wordpress类似qq空间巩义网站优化公司
  • 用DW给网站做后台百度关键字优化精灵