在vxworks上移植netperf工具

来源:互联网 发布:美国儿童编程 编辑:程序博客网 时间:2024/06/08 20:01

最近需要测一下vxworks上的网络性能,在网上搜了一下,发现iperf支持vxworks,但是并没有找到对应的源码,加了一个vxworks的QQ群,里面有人提到自己就是用netperf在vxworks上测试网络性能的,因此决定将netperf移植到vxworks上。

手头上仅有vxworks镜像,且不支持wdb任务,因此没有办法在tornado上直接调试,只能利用tornado生成相关可执行程序,ftp下载到板子上,然后用ld命令加载。整体思路理清之后,现在需要利用tornado生成可执行程序。

在网上搜索一番之后,找到网页:

http://www.netperf.org/netperf/training/netperf-talk/0217.html

正文如下:

Re: Porting Netperf to VxWorks

Tom Pavel (pavel@slac.stanford.edu)
Wed, 04 Aug 1999 00:06:28 -0700

  • Messages sorted by: [ date ][ thread ][ subject ][ author ]
  • Next message: ygwl: "(no subject)"
  • Previous message: Bubeck, Leslie: "Porting Netperf to VxWorks"
  • In reply to: Bubeck, Leslie: "Porting Netperf to VxWorks"
>>>>> On Tue, 3 Aug 1999, "Bubeck, Leslie" <leslie.bubeck@lmco.com> writes:

> Does anyone know if Netperf has been ported to VxWorks?? I have just been
> tasked with this and I'd hate to reinvent the wheel if it has already been
> done.

I did some work on porting version 2.1pl3 to VxWorks Tornado on
PowerPC. Unfortunately, netperf had moved on from pl3, Rick was busy
working on v3, and I got busy on other projects, so these patches
never got integrated into production netperf.

I think my diffs would serve you well as a starting point. It
probably shouldn't be much work to move them forward to the latest 2.1
pl. You can get them from the mailing list archives or from
ftp://ftp.slac.stanford.edu/users/pavel/netperf-vxw.diffs

Caveats are that I concentrated on the TCP_STREAM test, and there are
some unsolved problems with the UDP tests. [One of them is that
VxWorks does not allow IOs to be interrupted by signals (even though
they define a SA_INTERRUPT), so one needs to make the IO loop always
do select() and then recv().] Also, being new to VxWorks, I tended to
solve my problems with the optional POSIX features (that are not
always included into VxWorks kernels). For wider applicability, one
might want to use native VxWorks timers, etc.

Ok. Hope this info is helpful to you. Feel free to contact me if I
can answer questions.

Tom Pavel

Stanford Linear Accelerator Center
pavel@slac.stanford.edu http://www.slac.stanford.edu/~pavel/

  • Next message: ygwl: "(no subject)"
  • Previous message: Bubeck, Leslie: "Porting Netperf to VxWorks"
  • In reply to: Bubeck, Leslie: "Porting Netperf to VxWorks"
日期是1999年8月,也够历史悠久了。。。这位前辈做过vxworks上的netperf(tcp可正常运行udp不保证),并且给出了相关的资料

打开下面的地址:

ftp://ftp.slac.stanford.edu/users/pavel/netperf-vxw.diffs

发现这位前辈的工作是基于netperf-2.1pl3上的,页面上的信息是移植时修改的文件与行数信息,并不是完整源码。

在netperf下载页

http://www.netperf.org/svn/netperf2/tags/

并没有找到netperf-2.1pl3,最相近的版本是netperf-2.1pl2,因此在netperf-2.1pl2的基础上来移植。

参考前辈提供的移植信息,一行行进行修改(用过diff命令的话可以很容易理解要修改的地方),完成了源码的修改。

ps:源码修改主要是针对win32或vxworks用到的头文件、函数、结构体的不同,出现频率比较高的语句有#ifdef VXWORKS  #else #endif等。

因为本人只需要在vxworks下工作,因此在每个有#ifdef VXWORKS的程序中,我都在最上面添了一句话:

#ifndef VXWORKS

#define VXWORKS

#endif

所以其实我完全可以把#ifdef WIN32 部分的内容给删掉的。。。留着吧。

下面需要考虑编译的问题。

先在tornado上新建一个程序,写最简单的helloworld,然后编译(参考了其他的资料,不赘述),接着删除helloworld程序,把源码复制到这个project文件夹下。

在该project里添加源码里的.c 和.h文件,然后利用tornado的build功能,生成Makefile文件,也生成了对应的.o文件,此时还缺少netperf.out  netserver.out两文件

比较前辈的Makefile和tornado上的Makefile,发现关键句在于:

NETSERVER_OBJS  = netserver.o nettest_bsd.o nettest_dlpi.o nettest_unix.o netlib.o netsh.o nettest_fore.o nettest_hippi.o nettest_xti.o nettest_ipv6.o
NETPERF_OBJS  = netperf.o netsh.o netlib.o nettest_bsd.o nettest_dlpi.o nettest_unix.o nettest_fore.o nettest_hippi.o nettest_xti.o nettest_ipv6.o

all: netperf.out netserver.out
netperf.out:$(NETPERF_OBJS)
$(LD) -o $@ -r $(NETPERF_OBJS) $(PRJ_LIBS) 
netserver.out:$(NETSERVER_OBJS) 
$(LD) -o $@ -r $(NETSERVER_OBJS) $(PRJ_LIBS)
如上是生成可执行文件的关键点,其中 LD=ldpentium            PRJ_LIBS=                   //空

打开cmd命令,进入到project所在文件,执行:

ldpentium -o netperf.out  -r netperf.o netsh.o netlib.o nettest_bsd.o nettest_dlpi.o nettest_unix.o nettest_fore.o nettest_hippi.o nettest_xti.o nettest_ipv6.o
ldpentium -o netserver.out -r netserver.o netsh.o netlib.o nettest_bsd.o nettest_dlpi.o nettest_unix.o nettest_fore.o nettest_hippi.o nettest_xti.o nettest_ipv6.o

即生成了netserver.out和netperf.out两个可执行文件。    

以上如果出现问题,请严格比对下是不是修改的时候有疏漏。

将两文件ftp到vxworks上,ld 加载,执行时语句类似于:

netperf "-t TCP_RR -H 192.168.2.73"

netserver "-p 12865"

如果有报错:

debug file: S_dosFsLib_FILE_NOT_FOUND

请将对应的netserver.c 或者netiperf.c文件中的debug信息注释掉。

0 0