如何对不同应用或端口数据包手动设置延迟或者丢包?

66 views
Skip to first unread message

刘老板

unread,
Oct 12, 2016, 3:20:30 AM10/12/16
to USTC_LUG
课题需要,我们想对网络通讯中不同的应用手动设置一定的延迟或者丢包。请问各位大神指点一些好用的指令或者开源软件。谢谢!!!

Shanker Wang

unread,
Oct 12, 2016, 3:21:38 AM10/12/16
to ustc...@googlegroups.com
tc


在 2016年10月12日,15:20,刘老板 <liuchua...@gmail.com> 写道:

课题需要,我们想对网络通讯中不同的应用手动设置一定的延迟或者丢包。请问各位大神指点一些好用的指令或者开源软件。谢谢!!!

--
您收到此邮件是因为您订阅了Google网上论坛上的“USTC_LUG”群组。
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到ustc_lug+u...@googlegroups.com
访问此群组:https://groups.google.com/group/ustc_lug
要查看更多选项,请访问https://groups.google.com/d/optout

Yousong Zhou

unread,
Oct 12, 2016, 4:56:33 AM10/12/16
to ustc...@googlegroups.com
2016-10-12 15:21 GMT+08:00 Shanker Wang <shanker...@gmail.com>:
> tc
>
> http://lartc.org/lartc.pdf
>

netem, http://www.linuxfoundation.org/collaborate/workgroups/networking/netem

举个例子:sudo tc qdisc add dev lo root handle 1:0 netem delay 10ms

yousong

刘老板

unread,
Oct 12, 2016, 9:15:27 AM10/12/16
to USTC_LUG
tc指令调研过,但是tc只能设置延迟吧,并不能设置丢包,有懂的人知道手动设置丢包的方法吗?

在 2016年10月12日星期三 UTC+8下午3:20:30,刘老板写道:
课题需要,我们想对网络通讯中不同的应用手动设置一定的延迟或者丢包。请问各位大神指点一些好用的指令或者开源软件。谢谢!!!

Shanker Wang

unread,
Oct 12, 2016, 9:30:23 AM10/12/16
to ustc...@googlegroups.com, 刘老板
iptables,依概率匹配,丢包。

man iptables-extensions

   statistic
       This module matches packets based on some statistic condition.  It sup‐
       ports two distinct modes settable with the --mode option.

       Supported options:

       --mode mode
              Set  the matching mode of the matching rule, supported modes are
              random and nth.

       [!] --probability p
              Set the probability for a packet to be randomly matched. It only
              works  with  the  random mode. p must be within 0.0 and 1.0. The
              supported granularity is in 1/2147483648th increments.

       [!] --every n
              Match one packet every nth packet. It works only  with  the  nth
              mode (see also the --packet option).

       --packet p
              Set the initial counter value (0 <= p <= n-1, default 0) for the
              nth mode.


Yousong Zhou

unread,
Oct 12, 2016, 11:31:23 AM10/12/16
to ustc...@googlegroups.com
2016-10-12 21:15 GMT+08:00 刘老板 <liuchua...@gmail.com>:
> tc指令调研过,但是tc只能设置延迟吧,并不能设置丢包,有懂的人知道手动设置丢包的方法吗?
>

qdisc的报文队列控制,delay, loss,
corruption都是能很直接控制的,netem就是做这个事情的,大约你没有细看链接内容,或者邮件被过滤掉了?

yousong

> 在 2016年10月12日星期三 UTC+8下午3:20:30,刘老板写道:
>>
>> 课题需要,我们想对网络通讯中不同的应用手动设置一定的延迟或者丢包。请问各位大神指点一些好用的指令或者开源软件。谢谢!!!
>

刘传彬的谷歌邮箱

unread,
Oct 12, 2016, 2:07:57 PM10/12/16
to ustc...@googlegroups.com
谢谢指教,确实是我疏忽,tc指令可以设置丢包。
还有一个问题,tc 或者iptables 能对指定端口设置不同规则吗?比如5060端口摄制最大带宽1m,对8080设置延迟100ms?
多谢指教
--
您收到此邮件是因为您订阅了 Google 网上论坛的“USTC_LUG”群组。

Shanker Wang

unread,
Oct 12, 2016, 3:10:07 PM10/12/16
to ustc...@googlegroups.com
可以的,tc 有 selector,

StarBrilliant

unread,
Oct 12, 2016, 3:35:43 PM10/12/16
to USTC_LUG
有人把 tc 和 iptables 包装了一下,起名叫 Comcast。
https://github.com/tylertreat/comcast
可以体验一下:免费享受 Comcast 级别的网络体验(误)

刘传彬的谷歌邮箱

unread,
Oct 12, 2016, 10:11:45 PM10/12/16
to ustc...@googlegroups.com
谢谢Wang,pdf我正在看。

在 2016年10月12日 下午3:21,Shanker Wang <shanker...@gmail.com>写道:
在 2016年10月12日,15:20,刘老板 <liuchua...@gmail.com> 写道:

课题需要,我们想对网络通讯中不同的应用手动设置一定的延迟或者丢包。请问各位大神指点一些好用的指令或者开源软件。谢谢!!!

--
您收到此邮件是因为您订阅了Google网上论坛上的“USTC_LUG”群组。
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到ustc_lug+unsubscribe@googlegroups.com

访问此群组:https://groups.google.com/group/ustc_lug
要查看更多选项,请访问https://groups.google.com/d/optout

--
您收到此邮件是因为您订阅了Google网上论坛上的“USTC_LUG”群组。
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到ustc_lug+unsubscribe@googlegroups.com

刘传彬的谷歌邮箱

unread,
Oct 13, 2016, 12:00:25 AM10/13/16
to ustc...@googlegroups.com
针对不同端口的策略,你说的tc的 selector指的是分成不同class,然后不同包match ip dport flowid 这样设置?
还是tc自带selector 的选项?
谢谢!

在 2016年10月13日 上午3:10,Shanker Wang <shanker...@gmail.com>写道:
可以的,tc 有 selector,

在 2016年10月13日,02:07,刘传彬的谷歌邮箱 <liuchua...@gmail.com> 写道:

谢谢指教,确实是我疏忽,tc指令可以设置丢包。
还有一个问题,tc 或者iptables 能对指定端口设置不同规则吗?比如5060端口摄制最大带宽1m,对8080设置延迟100ms?
多谢指教

2016年10月12日星期三,Yousong Zhou <yszho...@gmail.com> 写道:
2016-10-12 21:15 GMT+08:00 刘老板 <liuchua...@gmail.com>:
> tc指令调研过,但是tc只能设置延迟吧,并不能设置丢包,有懂的人知道手动设置丢包的方法吗?
>

qdisc的报文队列控制,delay, loss,
corruption都是能很直接控制的,netem就是做这个事情的,大约你没有细看链接内容,或者邮件被过滤掉了?

                yousong

> 在 2016年10月12日星期三 UTC+8下午3:20:30,刘老板写道:
>>
>> 课题需要,我们想对网络通讯中不同的应用手动设置一定的延迟或者丢包。请问各位大神指点一些好用的指令或者开源软件。谢谢!!!
>
> --
> 您收到此邮件是因为您订阅了Google网上论坛上的“USTC_LUG”群组。
> 要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到ustc_lug+unsubscribe@googlegroups.com

> 访问此群组:https://groups.google.com/group/ustc_lug
> 要查看更多选项,请访问https://groups.google.com/d/optout

--
您收到此邮件是因为您订阅了 Google 网上论坛的“USTC_LUG”群组。
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到ustc_lug+unsubscribe@googlegroups.com

访问此群组:https://groups.google.com/group/ustc_lug
要查看更多选项,请访问 https://groups.google.com/d/optout

--
您收到此邮件是因为您订阅了Google网上论坛上的“USTC_LUG”群组。
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到ustc_lug+unsubscribe@googlegroups.com

访问此群组:https://groups.google.com/group/ustc_lug
要查看更多选项,请访问https://groups.google.com/d/optout

--
您收到此邮件是因为您订阅了Google网上论坛上的“USTC_LUG”群组。
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到ustc_lug+unsubscribe@googlegroups.com

Zhang Zhengjun

unread,
Oct 13, 2016, 12:04:34 AM10/13/16
to ustc...@googlegroups.com
也可以用iptables打上mark,tc里根据mark匹配

On Thu, Oct 13, 2016 at 12:00 刘传彬的谷歌邮箱 <liuchua...@gmail.com> wrote:
针对不同端口的策略,你说的tc的 selector指的是分成不同class,然后不同包match ip dport flowid 这样设置?
还是tc自带selector 的选项?
谢谢!
在 2016年10月13日 上午3:10,Shanker Wang <shanker...@gmail.com>写道:
可以的,tc 有 selector,

在 2016年10月13日,02:07,刘传彬的谷歌邮箱 <liuchua...@gmail.com> 写道:

谢谢指教,确实是我疏忽,tc指令可以设置丢包。
还有一个问题,tc 或者iptables 能对指定端口设置不同规则吗?比如5060端口摄制最大带宽1m,对8080设置延迟100ms?
多谢指教

2016年10月12日星期三,Yousong Zhou <yszho...@gmail.com> 写道:
2016-10-12 21:15 GMT+08:00 刘老板 <liuchua...@gmail.com>:
> tc指令调研过,但是tc只能设置延迟吧,并不能设置丢包,有懂的人知道手动设置丢包的方法吗?
>

qdisc的报文队列控制,delay, loss,
corruption都是能很直接控制的,netem就是做这个事情的,大约你没有细看链接内容,或者邮件被过滤掉了?

                yousong

> 在 2016年10月12日星期三 UTC+8下午3:20:30,刘老板写道:
>>
>> 课题需要,我们想对网络通讯中不同的应用手动设置一定的延迟或者丢包。请问各位大神指点一些好用的指令或者开源软件。谢谢!!!
>
> --
> 您收到此邮件是因为您订阅了Google网上论坛上的“USTC_LUG”群组。
> 要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到ustc_lug+u...@googlegroups.com

> 访问此群组:https://groups.google.com/group/ustc_lug
> 要查看更多选项,请访问https://groups.google.com/d/optout

--
您收到此邮件是因为您订阅了 Google 网上论坛的“USTC_LUG”群组。
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到ustc_lug+u...@googlegroups.com

访问此群组:https://groups.google.com/group/ustc_lug
要查看更多选项,请访问 https://groups.google.com/d/optout

--
您收到此邮件是因为您订阅了Google网上论坛上的“USTC_LUG”群组。
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到ustc_lug+u...@googlegroups.com

访问此群组:https://groups.google.com/group/ustc_lug
要查看更多选项,请访问https://groups.google.com/d/optout

--
您收到此邮件是因为您订阅了Google网上论坛上的“USTC_LUG”群组。
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到ustc_lug+u...@googlegroups.com

访问此群组:https://groups.google.com/group/ustc_lug
要查看更多选项,请访问https://groups.google.com/d/optout

--
您收到此邮件是因为您订阅了Google网上论坛上的“USTC_LUG”群组。
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到ustc_lug+u...@googlegroups.com

刘传彬的谷歌邮箱

unread,
Oct 13, 2016, 12:05:59 AM10/13/16
to ustc...@googlegroups.com
嗯嗯,我调研了一下好像也只有这个办法。
谢谢!^_^

Zhang Zhengjun <siyanm...@gmail.com>于2016年10月13日 周四下午12:04写道:

Zhang Cheng

unread,
Oct 13, 2016, 12:07:03 AM10/13/16
to USTC LUG
我来跑个题。

建议楼主统一一下所有邮件客户端里的发件人姓名,不要一会儿“刘老板”,一会儿“刘传彬的谷歌邮箱”。

2016-10-12 15:20 GMT+08:00 刘老板 <liuchua...@gmail.com>:
课题需要,我们想对网络通讯中不同的应用手动设置一定的延迟或者丢包。请问各位大神指点一些好用的指令或者开源软件。谢谢!!!

--
您收到此邮件是因为您订阅了Google网上论坛上的“USTC_LUG”群组。
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到ustc_lug+unsubscribe@googlegroups.com

访问此群组:https://groups.google.com/group/ustc_lug
要查看更多选项,请访问https://groups.google.com/d/optout



--
Cheng,
Best Regards

刘传彬的谷歌邮箱

unread,
Oct 13, 2016, 12:07:56 AM10/13/16
to USTC LUG
因为有时是电脑在线,有时用的是手机回复。

Zhang Cheng <steph...@gmail.com>于2016年10月13日 周四下午12:07写道:
我来跑个题。

建议楼主统一一下所有邮件客户端里的发件人姓名,不要一会儿“刘老板”,一会儿“刘传彬的谷歌邮箱”。
2016-10-12 15:20 GMT+08:00 刘老板 <liuchua...@gmail.com>:
课题需要,我们想对网络通讯中不同的应用手动设置一定的延迟或者丢包。请问各位大神指点一些好用的指令或者开源软件。谢谢!!!

--
您收到此邮件是因为您订阅了Google网上论坛上的“USTC_LUG”群组。
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到ustc_lug+u...@googlegroups.com

访问此群组:https://groups.google.com/group/ustc_lug
要查看更多选项,请访问https://groups.google.com/d/optout



--
Cheng,
Best Regards

--
您收到此邮件是因为您订阅了Google网上论坛上的“USTC_LUG”群组。
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到ustc_lug+u...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages