如何提升UDP发包效率

695 views
Skip to first unread message

yayv

unread,
Oct 2, 2012, 5:59:45 AM10/2/12
to sh...@googlegroups.com
hi 各位, 
我这几天在尝试用UDP跑满千兆网卡,但无论怎样也跑不到.

如果直接使用 while(1) 的循环发送,可以达到380Mbps左右; 如果使用 libev, 可以达到320Mbps左右. 直觉上感觉应该对系统做一些优化,但实在不知道该怎样分析瓶颈.

多谢

-- 
yayv
Sent with Sparrow

Chaos Eternal

unread,
Oct 2, 2012, 6:45:30 AM10/2/12
to sh...@googlegroups.com
mtu开大点。

> --
> -- You received this message because you are subscribed to the Google Groups
> Shanghai Linux User Group group. To post to this group, send email to
> sh...@googlegroups.com. To unsubscribe from this group, send email to
> shlug+un...@googlegroups.com. For more options, visit this group at
> https://groups.google.com/d/forum/shlug?hl=zh-CN
>
>

liyaoshi

unread,
Oct 2, 2012, 7:26:00 AM10/2/12
to sh...@googlegroups.com
jumbo frame

2012/10/2 Chaos Eternal <chaose...@shlug.org>

yayv

unread,
Oct 2, 2012, 8:49:23 AM10/2/12
to sh...@googlegroups.com
是个办法,还有可以不改MTU的办法吗?

-- 
yayv
Sent with Sparrow

kevin lee

unread,
Oct 3, 2012, 1:47:25 AM10/3/12
to sh...@googlegroups.com
用pktgen发包。我测过,可以跑到970多M

2012/10/2 yayv <yay...@gmail.com>



--
Best Regards,
Kevin Lee

none_nobody

unread,
Oct 3, 2012, 2:40:50 AM10/3/12
to sh...@googlegroups.com
先用 tcpdump 将需要发的包抓下来。慢速发的也不要紧 ;

用 tcprewrite 将抓来的文件改写好原mac , 目标 mac , 源 ip 目标 ip.

生成 cache

用 tcpreplay 播发,速度可控,只要不是很小的包,可以想发多少就发多少,精确控制PPS.




On Wednesday, October 3, 2012 1:47:53 PM UTC+8, kevin-lee wrote:
用pktgen发包。我测过,可以跑到970多M

kevin lee

unread,
Oct 3, 2012, 3:02:46 AM10/3/12
to sh...@googlegroups.com
pktgen是内核自带的发包模块,只需要简单的把发包参数设置下就OK了,目的IP,目的mac都是可以设置到一个范围的,包大小,包数等都可以直接设置。感觉比自己去抓包,再改,再发要方便的多。

--
-- You received this message because you are subscribed to the Google Groups Shanghai Linux User Group group. To post to this group, send email to sh...@googlegroups.com. To unsubscribe from this group, send email to shlug+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/shlug?hl=zh-CN
 
 

Alex Zhang

unread,
Oct 3, 2012, 4:50:18 PM10/3/12
to sh...@googlegroups.com
上次去 Facebook 的时候,他们的工程师说 Linux 的 UDP 性能本身有问题,他们的内核小组重写了协议栈。

--
Difan Zhang (@tifan)
System Administrator | Google Inc.
http://difan.org.cn/ | http://blog.osqdu.org/

none_nobody

unread,
Oct 3, 2012, 11:46:11 PM10/3/12
to sh...@googlegroups.com

神,不要让狭隘蒙蔽了我的眼睛。


yayv

unread,
Oct 4, 2012, 9:11:25 PM10/4/12
to sh...@googlegroups.com

感谢kevin, 感谢这个信息,我研究下.


-- 
yayv
Sent with Sparrow

yayv

unread,
Oct 4, 2012, 9:11:55 PM10/4/12
to sh...@googlegroups.com
真NB, 会在新版本的内核出现这个补丁吗?

-- 
yayv
Sent with Sparrow

Alex Zhang

unread,
Oct 5, 2012, 2:34:50 AM10/5/12
to sh...@googlegroups.com
没听说他们把这玩意儿开源了


--
Alex Difan Zhang (@tifan)
http://difan.org.cn/


On Thursday, October 4, 2012 at 6:11 PM, yayv wrote:

> 真NB, 会在新版本的内核出现这个补丁吗?
>
> --
> yayv
> Sent with Sparrow (http://www.sparrowmailapp.com/?sig)
>
>
> On 2012年10月4日Thursday at 上午4:50, Alex Zhang wrote:
>
> > 上次去 Facebook 的时候,他们的工程师说 Linux 的 UDP 性能本身有问题,他们的内核小组重写了协议栈。
> >
> > --
> > Difan Zhang (@tifan)
> > System Administrator | Google Inc.
> > http://difan.org.cn/ | http://blog.osqdu.org/
> >
> >
> > 在 2012年10月3日 上午12:02,kevin lee <xyu....@gmail.com (mailto:xyu....@gmail.com)> 写道:
> > > pktgen是内核自带的发包模块,只需要简单的把发包参数设置下就OK了,目的IP,目的mac都是可以设置到一个范围的,包大小,包数等都可以直接设置。感觉比自己去抓包,再改,再发要方便的多。
> > > 可参考这个:http://www.linuxfoundation.org/collaborate/workgroups/networking/pktgen
> > >
> > >
> > > 2012/10/3 none_nobody <lyx...@gmail.com (mailto:lyx...@gmail.com)>
> > > >
> > > > 先用 tcpdump 将需要发的包抓下来。慢速发的也不要紧 ;
> > > >
> > > > 用 tcprewrite 将抓来的文件改写好原mac , 目标 mac , 源 ip 目标 ip.
> > > >
> > > > 生成 cache
> > > >
> > > > 用 tcpreplay 播发,速度可控,只要不是很小的包,可以想发多少就发多少,精确控制PPS.
> > > >
> > > >
> > > >
> > > >
> > > > On Wednesday, October 3, 2012 1:47:53 PM UTC+8, kevin-lee wrote:
> > > > >
> > > > > 用pktgen发包。我测过,可以跑到970多M
> > > > --
> > > > -- You received this message because you are subscribed to the Google
> > > > Groups Shanghai Linux User Group group. To post to this group, send email to
> > > > sh...@googlegroups.com (mailto:sh...@googlegroups.com). To unsubscribe from this group, send email to
> > > > shlug+un...@googlegroups.com (mailto:shlug+un...@googlegroups.com). For more options, visit this group at
> > > > https://groups.google.com/d/forum/shlug?hl=zh-CN
> > >
> > >
> > >
> > >
> > >
> > >
> > > --
> > > Best Regards,
> > > Kevin Lee
> > >
> > > --
> > > -- You received this message because you are subscribed to the Google Groups
> > > Shanghai Linux User Group group. To post to this group, send email to
> > > sh...@googlegroups.com (mailto:sh...@googlegroups.com). To unsubscribe from this group, send email to
> > > shlug+un...@googlegroups.com (mailto:shlug+un...@googlegroups.com). For more options, visit this group at
> > > https://groups.google.com/d/forum/shlug?hl=zh-CN
> >
> >
> >
> > --
> > -- You received this message because you are subscribed to the Google Groups Shanghai Linux User Group group. To post to this group, send email to sh...@googlegroups.com (mailto:sh...@googlegroups.com). To unsubscribe from this group, send email to shlug+un...@googlegroups.com (mailto:shlug+un...@googlegroups.com). For more options, visit this group at https://groups.google.com/d/forum/shlug?hl=zh-CN
>
>
>
> --
> -- You received this message because you are subscribed to the Google Groups Shanghai Linux User Group group. To post to this group, send email to sh...@googlegroups.com (mailto:sh...@googlegroups.com). To unsubscribe from this group, send email to shlug+un...@googlegroups.com (mailto:shlug+un...@googlegroups.com). For more options, visit this group at https://groups.google.com/d/forum/shlug?hl=zh-CN
>
>



yayv

unread,
Oct 5, 2012, 2:37:57 AM10/5/12
to sh...@googlegroups.com
嗯,我用来做测试的机器是一台MacBook Air+ Thunderbolt转千兆 , 另一台是Amd64的pc+PCI的千兆网卡, 如果Linux的UDP协议栈有问题, 总不能freebsd的也有类似的问题吧,我用macbook Air的状况是一样的.



-- 
yayv
Sent with Sparrow

-- You received this message because you are subscribed to the Google Groups Shanghai Linux User Group group. To post to this group, send email to sh...@googlegroups.com. To unsubscribe from this group, send email to shlug+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/shlug?hl=zh-CN

Chaos Eternal

unread,
Oct 5, 2012, 6:27:07 AM10/5/12
to sh...@googlegroups.com
你拿netpref先压一下线速?


2012/10/5 yayv <yay...@gmail.com>:

Justin Wong

unread,
Oct 6, 2012, 2:11:30 AM10/6/12
to sh...@googlegroups.com
我这里两台计算机(桌面机)用6类线千兆对连用 iperf 测试

TCP 能到 850Mbps
udp 只有 1.05Mbps

但是考虑到可能是iperf的udp测速本身不完美(比如自己实现的包确认机制之类),于是再开openVPN over
UDP,在此基础上跑用iperf测TCP速度,也只有 350Mbps左右,跑的时候CPU都没有满因此不太可能是openVPN的瓶颈。

Linux的UDP协议栈的确不是为大数据量优化的,速度很受限制

2012/10/5 Chaos Eternal <chaose...@shlug.org>:

--
Open Source,Open Mind

Blog: http://bigeagle.me/
E-mail: bige...@xdlinux.info

yayv

unread,
Oct 7, 2012, 9:39:53 AM10/7/12
to sh...@googlegroups.com
iperf测试udp,需要增加一个参数  -b 1000M , 不然默认限速是1M

-- 
yayv
Sent with Sparrow

艾军

unread,
Oct 7, 2012, 10:49:15 AM10/7/12
to sh...@googlegroups.com
用iperf绝对可以测试到你的最大速度。
我是stone

none_nobody

unread,
Oct 7, 2012, 10:09:12 PM10/7/12
to sh...@googlegroups.com

先证明你的网络环境和测试都没有问题,再怀疑Linux协议栈吧。

 

Linux的UDP协议栈的确不是为大数据量优化的,速度很受限制


yayv

unread,
Oct 7, 2012, 11:24:46 PM10/7/12
to sh...@googlegroups.com
目前已经证实的问题是,网卡的质量很重要.


-- 
yayv
Sent with Sparrow

On 2012年10月8日Monday at 上午10:09, none_nobody wrote:


先证明你的网络环境和测试都没有问题,再怀疑Linux协议栈吧。

 

Linux的UDP协议栈的确不是为大数据量优化的,速度很受限制


none_nobody

unread,
Oct 7, 2012, 11:46:25 PM10/7/12
to sh...@googlegroups.com
x86 平台,抓包唯有 PF_RING-DNA,ntop 上卖 license (per MAC address) for 1 Gbit Intel PCI Express cards (e1000e,igb). 99.euro

想过破解之使用的有没有?

发包过程中,能够精确控制PPS 对测试丢包等也很重要。


On Monday, October 8, 2012 11:25:02 AM UTC+8, liuce.cn wrote:
目前已经证实的问题是,网卡的质量很重要.


Chaos Eternal

unread,
Oct 7, 2012, 11:52:31 PM10/7/12
to sh...@googlegroups.com
破解就不要来这里问了吧。

none_nobody

unread,
Oct 7, 2012, 11:58:30 PM10/7/12
to sh...@googlegroups.com
其实我有点骚,因为我破解了一次。

个么我还是闷骚算了。

On Monday, October 8, 2012 11:52:36 AM UTC+8, Chaos Eternal wrote:
破解就不要来这里问了吧。


寒天秋

unread,
Oct 9, 2012, 2:38:23 AM10/9/12
to sh...@googlegroups.com
sysctl 把buffer开大一点。
 
在国内到荷兰的622M 专线上,350ms延迟,UDP可以跑到512Mbps+,iperf测试,丢包<0.01%,基于debian2.6标准内核。

2012/10/8 none_nobody <lyx...@gmail.com>

liyaoshi

unread,
Oct 9, 2012, 2:40:42 AM10/9/12
to sh...@googlegroups.com


2012/10/9 寒天秋 <zh....@gmail.com>

sysctl 把buffer开大一点。
 
在国内到荷兰的622M 专线上,350ms延迟,UDP可以跑到512Mbps+,iperf测试,丢包<0.01%,基于debian2.6标准内核。
你这个是ATM,跟ethernet 不一样

ATM 是48字节定长包,是同步网 

寒天秋

unread,
Oct 9, 2012, 6:55:45 AM10/9/12
to sh...@googlegroups.com


2012/10/9 liyaoshi <liya...@gmail.com>



2012/10/9 寒天秋 <zh....@gmail.com>
sysctl 把buffer开大一点。
 
在国内到荷兰的622M 专线上,350ms延迟,UDP可以跑到512Mbps+,iperf测试,丢包<0.01%,基于debian2.6标准内核。
你这个是ATM,跟ethernet 不一样

ATM 是48字节定长包,是同步网 
 
 
其实国内段是走的共享的科技网,香港出口到荷兰是Lightpath。
 
如果他是专网,网络质量正常,不应该这么低。如果是共享带宽,网络拥塞或是其他防火墙等因素,也有可能这么低使用率。

sniperpr

unread,
Oct 30, 2012, 2:24:59 AM10/30/12
to sh...@googlegroups.com, yay...@gmail.com
请问 雷电接口的 eth网卡, 水果原厂的那个质量不靠谱吗?

2012/10/8 yayv <yay...@gmail.com>



--
DDNAS系列!

adam.huang

Reply all
Reply to author
Forward
0 new messages