您的位置:首页 > 运维架构 > Linux

安装 NIST net 的步骤及使用(nistnet-2.0.12b针对linux-2.4.20-8)on RedHat9.0

2009-03-05 15:06 941 查看
原本打算直接在已经安装的CentOS 5.0上安装它,可惜花了一天时间来编译内核,配置,设置...最后还是徒劳,不得不决定采用以下方式来完成!

一.下载RedHat9.0:http://ftp.redhat.com/pub/redhat/linux/9/en/iso/i386/shrike-i386-discX.iso ,X取1,2,3。或者假设你已经拥有RedHat9.0的安装盘!

二.安装RedHat9.0。(都是默认!其实如果之前安装过的话,应该选择一些有用的组件在安装系统时装上,很有用的,以后必须要装的!)
三.NND,下载的三个光盘不够,还差一个,就是内核源码的安装盘,去下载:http://rpm.pbone.net/ 上有很多这样的rpm,缺少什么,都可以上去找,一般能找到!这里是linux的又一天堂网站啊!记住了!下载kernel-source-2.4.20-8.i386.rpm!或者到http://www.redhat.com上去找也能找到!安装:
#rpm –ivh kernel-source-2.4.20-8.i386.rpm,之后便生成/usr/src/linux-2.4.20-8。出问题的话,先完成第四步在回头来做这一步。[后来重装RedHat9.0时选择了自定义安装,装好后,到/usr/src/下,还真有linux-2.4.20-8目录,才知道默认安装是不装内核源代码的]
四.由于是采用的一路默认安装系统,所以,后来发现后有很多需要补全的东东:一个一个的补全安装太麻烦了,烦到大脑抽筋...所以建议,系统设置à添加删除软件包à根据需要选择安装,可以选择从网上下载安装,或者是从光盘导入安装!
五.下载nistnet2.0.12X,X取a,b,c:
a:不知道有啥用。
b:对应linux-2.4.xx。
c:对应linux-2.6.xx。(这一项有点扯,其实还是老老实实用b吧,这个会出老多问题!后来才知道这里的2.6.xx指的是2.6.13以下版本而已!)
经检验,还是在2.4.20-8上安装比较容易,网上支持很多,否则又要脑袋抽筋了。
地址:http://snad.ncsl.nist.gov/nistnet/install.htmlhttp://snad.ncsl.nist.gov/nistnet/ 或者http://sourceforge.net/projects/nistnet/
六.准备安装:(引自 http://blog.csdn.net 的用户pmunix的文章《搭建广域网模拟器nistnet.2.0.12步骤》)
1. 解压nistnet:#tar –zxvf nistnet.2.0.12b.tar.gz。得到nistnet.2.0.12b,再建立软连接:#ln –s nistnet.2.0.12b nistnet。
2. 先试一下直接安装,一般出错或者提示错误:我的就提示需要重新生成内核!
3. 所以,做如下操作:
#cd /usr/src/linux2.4.20-8 //(内核源码所在目录)
#make mrproper // 删除不稳定的.O文件和.config配置文件
#make menuconfig // 调出修改内核工具
配置如下:
Loadable module support à
Set version information no all module symbols --off
Character devices à
Enhanced Real Time Clock Suppot --M
设置以上这两项!
/*据说是采用#make xconfig也可以,而且更直观,但是我其中一次这样(#make xconfig)配置了,最后还是没安装成功,不知道有没有关系。后来干脆就#make menuconfig了,还真的安装成功了...*/
# make dep // 连接程序代码和函数库
# make clean //删不必要的模块
# make bzImage //生成内核文件
# cp /usr/src/linux2.4.20-8/arch/i386/boot/bzImage /boot/vmlinuz-2.4.20-8_new
#make modules // 编译外挂模块
# make modules_install //安装编译完成的模块
#make install
///*把新的内核和相关文件复制到正确的目录,并修改grub.conf文件,在grub 菜单会添加一个新的内核启动选项。不过redhat下有些时候某些版本make install有点问题,所以也可以自己修改,把原来的内核注释掉就行了:(没测试过以下步骤哦!)
1>. #cp $linux-source-src/arch/i386/boot/bzImag /boot/vmlinuz-2.xxxx
2>. #cp $linux-source-src/System.map /boot/System.map-2.xxxx
3>. #cd /boot, 然后删除以前的System, vmlinuz的软连接
4>. 建立新的软连接:
#ln -s vmlinuz-2.xxxx vmlinuz
#ln -s System.map-2.xxxx System.map
5>. 制作img, 貌似IDE硬盘不需要, scsi的必须制作:
#mkinitrd /boot/initrd-2.xxxx.img 2.xxxx
6>. 修改grub:
备份以前的grub
#cd /boot/grub
#cp grub.conf grub.conf.bak
#vi grub.conf
添加如下3行, 这里一定要保存以前的内核配置,否则起不来的话,只能在grub界面上用按"e"键手工修改grub来加载正常的内核,非常的麻烦!
title Red Hat Linux (2.xxxx)
root (hd0,0)
kernel /vmlinuz-2.xxxx ro root=LABEL=/
/* 注意这里如果写成LABEL, 启动的时候提示kernel panic:VFS Unable to mount root fs on 00:00就要将root=修改为/dev/hd*的形式 */
#initrd /initrd-2.xxxx.img
修改grub.conf (/boot/grub/grub.conf , add a new title and the root path) 编译启动文件*///
# reboot
...
重启后,选择启动的系统:Red Hat Linux(2.4.20-8custom)
七.配置网络:NISTnet要安装在Linux环境下的双网卡主机上。
(1) 环境:三台直接相连的计算机主机如图:

CLINET1<-------->NISTnet<-------->CLINET2

其中NISTnet上有两块网卡eth0、eth1,分别与CLINET1、CLINET2相连。“------”代表网线。
(2)需求:将NISTnet配置为路由器模式,用来在CLINET1、CLINET2之间转发报文。
(3)方法:将三台主机按照环境所要求用交叉线直接连网后,为三台主机分配网段并配置IP地址。
网段及IP地址分配如下:

主机名=============所在网段==============分配IP================默认网关

CLINET1========192.168.2.0/24 =========192.168.2.2/24=========192.168.2.1
NISTnet========192.168.2.0/24 =========eth1:192.168.2.1/24 ===eth0 (可以通过Xwindows设置)
================192.168.1.0/24 =========eth0:192.168.1.1/24 ===eth1 (可以通过Xwindows设置)
CLINET2========192.168.1.0/24 =========192.168.1.2/24 ========192.168.1.1

【注意】按照上表所示分别将主机IP地址配置好,其中要注意的是,要想使NISTnet具有报文转发功能,在NISTnet上检查/proc/sys/net/ipv4/ip_forward中的值是否为1,命令:

#cat /proc/sys/net/ipv4/ip_forward
如果显示其值不为1而是0, 输入以下命令:
#echo 1 > /proc/sys/net/ipv4/ip_forward /*打开IP转发功能*/
建议:路由设置也可以设置成NAT模式,这样更方便,使局域网中的每台机器都能用你的NIST net;
备注:打开包的转发功能通过执行以下几个步骤:
#echo 1 > /proc/sys/net/ipv4/ip_forward //打开IP转发
#iptables –t nat –F //清除原有的nat表中的规则
#iptables –F //清除原有的filter中的规则
#iptables –P FORWARD ACCEPT //缺省允许IP转发
#iptables –t nat –A POSTROUTING –o eth0 –j MASQUERADE //在公网出口进行地址伪装,这样即使以后公网地址修改了也不用重新设置规则。
(4)验证:
CLINET1 ping 网关:#ping 192.168.2.1;#ping 192.168.1.1
CLINET1 ping CLINET2:#ping 192.168.1.2
CLINET2 ping 网关:#ping 192.168.1.1;#ping 192.168.2.1
CLINET2 ping CLINET1:#ping 192.168.2.2
上面的要求都能ping通才OK哦!
八.安装nistnet:
#cd /usr/local/src/nistnet
#./configure //其间都选择noà有人这么说,不过我还是一路yes了...
#make
#make install
/*安装完成,居然没有错,这是这几天以来第一次安装这个nistnet成功!那个高兴啊!*/
九.测试nistnet的安装是否成功:
以root账户运行,否则可能出现“No such device”的错误!但事实上已经存在了...
#./Load.Nistnet
èMD,提示模块rtc不能加载:
第一次:[root@localhost nistnet]# ./Load.Nistnet
rtc module removed - you may want to reinstall it (with insmod rtc) after you are done with nistnet
Using /lib/modules/2.4.20-8custom/misc/nistnet.o
nistnet module installed
第二次以后:[root@localhost nistnet]# ./Load.Nistnet
rmmod: module rtc is not loaded
Couldn't find rtc module - /dev/rtc will be mostly unusable after running nistnet. Sorry about that....
To prevent this message, recompile rtc (Enhanced Real Time Clock Support, under character devices) as module.
Using /lib/modules/2.4.20-8custom/misc/nistnet.o
insmod: a module named nistnet already exists
nistnet module installed
虽然rtc有问题,但是都提到了nistnet安装成功...
找到一篇 http://forums.fedoraforum.org/archive/index.php/t-80139.html 产生同样错误的帖子,一篇解答http://linux.derkeiler.com/Newsgroups/comp.os.linux.networking/2007-03/msg00158.html 的帖子。经一步步检查发现:
(1) rtc模块已经编译;因为通过了以下检查:
#cd /usr/src/linux-2.4.20-8
#find . -name rtc.o –print
期望输出:
./drivers/char/rtc.o
假如输出不是以上这样一行,那么就是rtc还没编译,尝试:
#grep RTC .config
期望输出:
CONFIG_RTC=m
(可能还有其他,但是只关心这么一行是否存在).
假如存在上面这一行,那么试一下:
#make clean;# make oldconfig;# make; #make modules;
这样有可能把rtc编译上;假如./config中没有这样一行,那么应该重新配置然后再编译。即#make clean;# make menuconfig或者#make xconfig;# make; #make modules;
(2) rtc模块已经安装过(这里不论是否安装成功);因为已经通过以下检查:
#find /lib/modules -name rtc.o -print
期望输出:
/lib/modules/2.4.20-8custom/kernel/drivers/char/rtc.o
假如没有,那么 #make modules_install 来建立它。
(3) 当前运行的内核确实是2.4.20-8custom,没有错;因为通过了检查:
#uname –r
期望输出:
2.4.20-8custom
(4) 但是,rtc模块安装后,并没有安装成功。所以,
#lsmod|grep rtc 后,没有出现期望的“rtc 7644 0 (autoclean)”输出。手动安装, #modprobe rtc或者#insmod rtc后,又出来问题:
/lib/modules/2.4.20-8custom/kernel/drivers/char/rtc.o: init_module: Input/output error
Hint: insmod errors can be caused by incorrect module parameters, including invalid IO or IRQ parameters.
You may find more information in syslog or the output from dmesg
/lib/modules/2.4.20-8custom/kernel/drivers/char/rtc.o:
insmod /lib/modules/2.4.20-8custom/kernel/drivers/char/rtc.o failed
/lib/modules/2.4.20-8custom/kernel/drivers/char/rtc.o: insmod rtc failed
显然是载入rtc模块时IO或者IRQ参数无效!
检验:[root@localhost nistnet]#dmesg
。。。
hdc: ATAPI 48X DVD-ROM drive, 198kB Cache, UDMA(33)
Uniform CD-ROM driver Revision: 3.12
cdrom: This disc doesn't have any tracks I recognize!
nistnet: Hello, world
Fast RTC Timer v1.0, based on RTC Driver v1.10d, rate 8192 Hz
grab_ip_rcv: Found ippt at c033f8f8
rtc: I/O port 112 is not free.
rtc: I/O port 112 is not free.
rtc: I/O port 112 is not free.
。。。
而且发现每执行一次[root@localhost nistnet]#modprobe rtc,就会多一条rtc: I/O port 112 is not free.日志。果然,装载rtc模块时,输入输出端口112忙!
这时候,我Google到一篇http://forum.soft32.com/linux2/Nistnet-work-help-ftopict40230.html 帖子,其中有包含这样内容的回复:“Nistnet should still work even without RTC being a module.”,即表示即使rct模块没有安装成功,nistnet一样可以运行(只是可能会不稳定) !至此,Nistnet可以工作了...
但是,解决这个问题是必须的:
(有待完成...)
十.开始测试:
1.以下是使用命令:#cnistnet -h
-u àup (on)
-d àdown (off)
-a src[:port[.protocol]] dest[:port[.prot]] [cos] èadd new
[--delay delay [delsigma[/delcorr]]]
[--drop drop_percentage[/drop_correlation]]
[--dup dup_percentage[/dup_correlation]]
[--bandwidth bandwidth]
[--drd drdmin drdmax [drdcongest]]
-r src[:port[.prot]] dest[:port[.prot]] [cos] àremove
-s src[:port[.prot]] dest[:port[.prot]] [cos] àsee stats
-S src[:port[.prot]] dest[:port[.prot]] [cos] àsee stats continuously
[-n] -R àread current settings (-n numerical format)
-D value àdebug on (value=0 none, 1 minimal,... 9 maximal)
-U àdebug off
-G àglobal stats
-K àkickstart the clock
-F àflush the queues
-h àthis help message
例子:为源IP为192.168.1.203:5060目的IP为192.168.100.156:5060的UDP流量增加10%丢包率,增加1s的延时,并且设置带宽为100M!执行下序命令:
#./Load.NistNet
#cnistnet -u
#cnistnet –a 192.168.1.203:5060 192.168.100.156:5060 --drop 10 --delay 1000 –bandwidth 100
【注意】使用此功能之前要使能Linux系统的路由功能,以便能够跨网段转发:
使能Linux路由功能的命令是:#echo 1 > /proc/sys/net/ipv4/ip_forward
查看路由功能是否启动的命令是:#cat /proc/sys/net/ipv4/ip_forward
如果终端显示‘1’则表明路由功能启动成功,如果显示‘0’则表示路由没有成功启动。
2.或者使用:#xnistnet
图形界面的,一目了然,使用方便...
更详细使用参看NISTnet官方网站上的使用手册:http://snad.ncsl.nist.gov/nistnet/usage.html
十一. 结尾:
通过NISTnet可以将单台的Linux PC机设置成为路由器,可以模拟各种网络环境。NISTnet的更多信息请访问NISTnet网站:www-x.antd.nist.gov/nistnet/index.html
有关NISTnet问题可直接与nistnet-dev@antd.nist.gov联系。NISTnet WAN模拟器常见问题请见:www-x.antd.nist.gov/nistnet/faq.html。NISTnet软件的使用由用户承担风险。Maxim对使用NISTnet可能得到的结果、精确性、可靠性或本软件提供或包含的任何信息内容或者服务不做任何担保。如果您对TDMoP产品或Maxim电信产品的其他方面有更多的问题,请通过电子邮件telecom.support@dalsemi.com (English only)或电话(01) 972-371-6555 (美国)联络我们的电信应用支持(English only)。Linux是Linus Torvalds的注册商标。Red Hat是Red Hat, Inc.的注册商标。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: