[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ns] emulation problems



You need to make a few changes in your script:

--- zhi guo <[email protected]> wrote:
> Hi��all
> 
> I installed FreeBSD in a PC. I wrote a tcl file and
> run it on NSE. 
> Following figure is the topology.
> 
> 
> 	   +--------------+       +---------------+        
>   +--------------+
> 	   | 192.168.0.47 |	<---->| 192.168.0.139 |	 <---->
>   | 192.168.0.53 |
> 	   +--------------+	      +---------------+        
>   +--------------+
> 			client												server
> 			win2000              FreeBSD						win2000
> 
> 
> I want to use 192.168.0.139 to emulate RAW IP
> package drop, delay and reorder.
> I added static route in both client and server as:
> (1) route add 192.168.0.53 mask 255.255.255.255
> 192.168.0.139; (2) route add 192.168.0.47 mask
> 255.255.255.255 192.168.0.139, respectively. 
> 
> Now client and server can ping each other. The tcl
> file is:
> ############### start
> set owdelay 10ms
> 
> set clientaddr "192.168.0.47"
> set serveraddr "192.168.0.53"
> set ns [new Simulator] 
> 
> $ns use-scheduler RealTime
> 
> set ipforw [exec sysctl -n net.inet.ip.forwarding]
> if { $ipforw } 
> {
> 	puts "can not run with ip forwarding enabled"
> 	exit 1
> }
> 
> set card0 [new Network/Pcap/Live]
> $card0 set promisc_ true
> $card0 open readonly rl0; #r10 is the net interface
> 
> set IPout [new Network/IP]
> $IPout open writeonly
> 
> $card0 filter "dst $clientaddr or dst $serveraddr";

Your packets are being duplicated because you are
using the same interface for reading and writing the
packets. Since your filter is configured to intercept
packets for either destination. even the packets that
you send out using the raw ip agent will be
intercepted by it and sent back to the emulation, and
this will result in an infinite loop within the
topology !!! To get around this problem use the
following filter:

card0 filter "dst $clientaddr or dst $serveraddr and
(not ether src $myether)" ;

where you will have to set the variable myether to
your ethernet card's hardware address(obtained by
ifconfig on Unices).This way, packets that are sent
out by your machine will not be intercepted by the
emulation.

> # only packets for client and server
> 
> set AgentCard [new Agent/Tap]
> set AgentOut [new Agent/Tap]
> 
> $AgentCard network $card0 
> $AgentOut network $IPout
> 
> set node0 [$ns node]
> set node1 [$ns node]
> 
> $ns simplex-link $node0 $node1 100Mb $owdelay
> DropTail
> 
> $ns attach-agent $node0 $AgentCard
> $ns attach-agent $node1 $AgentOut
> 

> $AgentCard target $AgentOut;  #???_(1)
> $ns simplex-connect $AgentCard $AgentOut

Instead of the 2 lines above you can use:
$ns connect $AgentCard $AgentOut


> 
> puts "start..."
> puts "The MAC address is: [$card0 linkaddr]"
> $ns run ; # start emulation
> ############### end
>                                            
> My question is: 
> 1.	I deem one net card is enough for my application
> in 192.168.0.139. Is that right?

Yes,you can use one card.

> 2.  If I delete the line marked with "???_(1)", when
> client pings server, nse will complain:
> 
> ns: scheduler going backwards in time from 10.671681
> to 10.669548
> ns: scheduler going backwards in time from 10.675796
> to 10.671762
> ns: scheduler going backwards in time from 10.680889
> to 10.677453
> .....
> 

This happens because of the excessive load your
emulation generates because of the loop..it should not
happen after the modifications, if your traffic load
isnt too high.

> at the same time, client(win2000) prints:
> 
> Reply from 192.168.0.47: bytes=32 time=20ms TTL=128
> Reply from 192.168.0.47: bytes=32 time=30ms TTL=128
> Reply from 192.168.0.47: bytes=32 time=50ms TTL=128
> Reply from 192.168.0.47: bytes=32 time=60ms TTL=128
> Reply from 192.168.0.47: bytes=32 time=130ms TTL=128
> Reply from 192.168.0.47: bytes=32 time=130ms TTL=128
> Reply from 192.168.0.47: bytes=32 time=401ms TTL=128
> Reply from 192.168.0.47: bytes=32 time=130ms TTL=128
> Reply from 192.168.0.47: bytes=32 time=130ms TTL=128
> Reply from 192.168.0.47: bytes=32 time=120ms TTL=128
> Reply from 192.168.0.47: bytes=32 time=130ms TTL=128
> ......
> 
> I want to know where the bug is and why I cannot
> control the delay time.
> 
> 3. If I do not delete the line "$AgentCard target
> $AgentOut;  #???_(1)", NSE will not complain but the
> delay 
> will remain as 50ms:
> 
> C:\>PING 192.168.0.47 -t
> Pinging 192.168.0.47 with 32 bytes of data:
> 
> Reply from 192.168.0.47: bytes=32 time<10ms TTL=128
> Reply from 192.168.0.47: bytes=32 time=20ms TTL=128
> Reply from 192.168.0.47: bytes=32 time=30ms TTL=128
> Reply from 192.168.0.47: bytes=32 time=50ms TTL=128
> Reply from 192.168.0.47: bytes=32 time=51ms TTL=128
> Reply from 192.168.0.47: bytes=32 time=50ms TTL=128
> Reply from 192.168.0.47: bytes=32 time=50ms TTL=128
> Reply from 192.168.0.47: bytes=32 time=50ms TTL=128
> Reply from 192.168.0.47: bytes=32 time=50ms TTL=128
> 
> 
> I found nse duplicated every package thousands times
> and sent them. Why? And how to amend the tcl file to
> realize the RAW IP delay and drop emulation.?
> These problems are harassing me for weeks.  :(
> Any help will be appreciated. Thank you.
>  
>             zhi guo
>             [email protected]
> 
> 

Hope the solutions above can help and your harassment
ceases.  :)

Regards

Anurag Goel

Senior Undergraduate Student
B.Tech Computer Science
Indian Institute of Technology
New Delhi


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/