1 / 54

Network Simulator with Mobile IP

Network Simulator with Mobile IP. 2003 Huang – Yu Liu. Overview. Introduction Install Simulation Simulation for Mobile IP. 安裝 Linux. 深入 Linux 建構與管理 第三版 楊文誌 著 , 旗標出版社 http://linux.vbird.org/linux_basic/0150installredhat.php. Network Simulator.

ryan-torres
Download Presentation

Network Simulator with Mobile IP

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Network Simulator with Mobile IP 2003 Huang – Yu Liu

  2. Overview • Introduction • Install • Simulation • Simulation for Mobile IP

  3. 安裝 Linux • 深入Linux 建構與管理 第三版 楊文誌 著, 旗標出版社 • http://linux.vbird.org/linux_basic/0150installredhat.php

  4. Network Simulator • A Collaboration between researchers at UC Berkeley, USC/ISI, and Xerox PARC全錄帕洛奧圖研究中心. • The simulator is written in C++; it uses OTcl as a command and configuration interface.

  5. Network Simulator • Tcl - Tool Command Language • OTcl – Object Tcl • http://bmrc.berkeley.edu/research/cmt/cmtdoc/otcl/ • http://bmrc.berkeley.edu/research/cmt/cmtdoc/otcl/tutorial.html

  6. Network Simulator • ns-2.1b10[OLD VERSION NO] / ns-2.26[NEW VERSION NO] Released on Wed Feb 26 11:40:51 PST 2003 • ns-2.1b8[OLD] / ns-2.24[NEW] released on Wed June 06 11:05:52 PDT 2001

  7. Network Simulator • Install ns : Get file ns-allinone-2.26.tar.gz • 輸入 tar zxvf ns-allinone-2.26.tar.gz p.s 假設在根目錄下輸入此指令

  8. Network Simulator • 進入 ns-allinone-2.26 資料夾 • 執行 ./install

  9. Network Simulator • 安裝完成後, 設定環境變數. • 把 /ns-allinone-2.26/bin:/root/ns-allinone-2.26/tcl8.3.2/unix:/ns-allinone-2.26/tk8.3.2/unix放到你的PATH環境變數. • 把 /ns-allinone-2.26/otcl-1.0a8, /ns-allinone-2.26/lib, 放到你的LD_LIBRARY_PATH環境變數. • 把 /ns-allinone-2.26/tcl8.3.2/library放到你的TCL_LIBRARY環境變數.

  10. Network Simulator • export PATH=$PATH: /ns-allinone-2.26/bin:/root/ns-allinone-2.26/tcl8.3.2/unix:/ns-allinone-2.26/tk8.3.2/unix • export TCL_LIBRARY= /ns-allinone-2.26/tcl8.3.2/library

  11. Network Simulator - Template #Create a simulator object set ns [new Simulator] #Open the nam trace file set nf [open out.nam w] $ns namtrace-all $nf #Define a 'finish' procedure proc finish {} { global ns nf $ns flush-trace #Close the trace file close $nf #Execute nam on the trace file exec nam out.nam & exit 0 } # Insert your own code for topology creation # and agent definitions, etc. here #Call the finish procedure after 5 seconds simulation time $ns at 5.0 "finish" #Run the simulation $ns run

  12. Network Simulator • Two nodes, one link set n0 [$ns node] set n1 [$ns node] $ns duplex-link $n0 $n1 1Mb 10ms DropTail

  13. Network Simulator • #Create a UDP agent and attach it to node n0 set udp0 [new Agent/UDP] $ns attach-agent $n0 $udp0 • # Create a CBR traffic source and attach it to udp0 set cbr0 [new Application/Traffic/CBR] $cbr0 set packetSize_ 500 $cbr0 set interval_ 0.005 $cbr0 attach-agent $udp0

  14. Network Simulator • #Create a Null agent (a traffic sink) and attach it to node n1 set null0 [new Agent/Null] $ns attach-agent $n1 $null0 • #Connect the traffic source with the traffic sink $ns connect $udp0 $null0 • #Schedule events for the CBR agent $ns at 0.5 "$cbr0 start" $ns at 4.5 "$cbr0 stop"

  15. Network Simulator • #Create links between the nodes $ns duplex-link $n0 $n2 1Mb 10ms DropTail $ns duplex-link $n1 $n2 1Mb 10ms DropTail $ns duplex-link $n3 $n2 1Mb 10ms SFQ • SFQ (stochastic fair queueing) $ns duplex-link-op $n0 $n2 orient right-down $ns duplex-link-op $n1 $n2 orient right-up $ns duplex-link-op $n2 $n3 orient right

  16. Network Simulator • #Define different colors for data flows $ns color 1 Blue $ns color 2 Red $udp0 set class_ 1 $udp1 set class_ 2 • #Monitor the queue for the link between node 2 and node 3 $ns duplex-link-op $n2 $n3 queuePos 0.5

  17. Network Simulator • #Connect the traffic sources with the traffic sink $ns connect $udp0 $null0 $ns connect $udp1 $null0 • #Schedule events for the CBR agents $ns at 0.5 "$cbr0 start" $ns at 1.0 "$cbr1 start" $ns at 4.0 "$cbr1 stop" $ns at 4.5 "$cbr0 stop"

  18. NS2 - Wireless • set val(chan) Channel/WirelessChannel • set val(prop) Propagation/TwoRayGround • set val(netif) Phy/WirelessPhy • set val(mac) Mac/802_11 • set val(ifq) Queue/DropTail/PriQueue • set val(ll) LL • set val(ant) Antenna/OmniAntenna • set val(x) 670 ;# X dimension of the topography • set val(y) 670 ;# Y dimension of the topography • set val(ifqlen) 50 ;# max packet in ifq • set val(seed) 0.0 • set val(adhocRouting) DSR • set val(nn) 3 ;# how many nodes are simulated • set val(cp) "cbr-3-test" • set val(sc) "scen-3-test" • set val(stop) 400.0 ;# simulation time

  19. NS2 - Wireless • # setup topography object set topo [new Topography] • # define topology • $topo load_flatgrid $val(x) $val(y) • # • # Create God • # • set god_ [create-god $val(nn)] • #global node setting • $ns_ node-config -adhocRouting $val(adhocRouting) \ • -llType $val(ll) \ • -macType $val(mac) \ • -ifqType $val(ifq) \ • -ifqLen $val(ifqlen) \ • -antType $val(ant) \ • -propType $val(prop) \ • -phyType $val(netif) \ • -channelType $val(chan) \ • -topoInstance $topo \ • -agentTrace ON \ • -routerTrace OFF \ • -macTrace OFF

  20. NS2 - MobileIP • set opt(chan) Channel/WirelessChannel ;# channel type • set opt(prop) Propagation/TwoRayGround ;# radio-propagation model • set opt(netif) Phy/WirelessPhy ;# network interface type • set opt(mac) Mac/802_11 ;# MAC type • set opt(ifq) Queue/DropTail/PriQueue ;# interface queue type • set opt(ll) LL ;# link layer type • set opt(ant) Antenna/OmniAntenna ;# antenna model • set opt(ifqlen) 50 ;# max packet in ifq • set opt(nn) 1 ;# number of mobilenodes • set opt(adhocRouting) DSDV ;# routing protocol • set opt(cp) "" ;# cp file not used • set opt(sc) "" ;# node movement file. • set opt(x) 670 ;# x coordinate of topology • set opt(y) 670 ;# y coordinate of topology • set opt(seed) 0.0 ;# random seed • set opt(stop) 250 ;# time to stop simulation • set opt(ftp1-start) 100.0 • set num_wired_nodes 2

  21. NS2 - MobileIP • AddrParams set domain_num_ 3 ;# number of domains • lappend cluster_num 2 1 1 ;# number of clusters in each domain • AddrParams set cluster_num_ $cluster_num • lappend eilastlevel 1 1 2 1 ;# number of nodes in each cluster • AddrParams set nodes_num_ $eilastlevel ;# of each domain • # Create HA and FA • set HA [$ns_ node 1.0.0] • set FA [$ns_ node 2.0.0]

  22. NS2 - MobileIP • # Configure for ForeignAgent and HomeAgent nodes • $ns_ node-config -mobileIP ON \ • -adhocRouting $opt(adhocRouting) \ • -llType $opt(ll) \ • -macType $opt(mac) \ • -ifqType $opt(ifq) \ • -ifqLen $opt(ifqlen) \ • -antType $opt(ant) \ • -propType $opt(prop) \ • -phyType $opt(netif) \ • -channelType $opt(chan) \ • -topoInstance $topo \ • -wiredRouting ON \ • -agentTrace ON \ • -routerTrace OFF \ • -macTrace OFF

  23. NS2 - MobileIP • # create a mobilenode that would be moving between HA and FA. • # note address of MH indicates its in the same domain as HA. • $ns_ node-config -wiredRouting OFF • set MH [$ns_ node 1.0.1] • set node_(0) $MH • set HAaddress [AddrParams addr2id [$HA node-addr]] • [$MH set regagent_] set home_agent_ $HAaddress

  24. NS2 - MobileIP • # MH starts to move towards FA • $ns_ at 100.000 "$MH setdest 640.0000 610.0000000 20.0000000" • # goes back to HA • $ns_ at 200.00000 "$MH setdest 2.000000 2.0000000 20.000000“ • # create links between wired and BaseStation nodes • $ns_ duplex-link $W(0) $W(1) 5Mb 2ms DropTail • $ns_ duplex-link $W(1) $HA 5Mb 2ms DropTail • $ns_ duplex-link $W(1) $FA 5Mb 2ms DropTail

  25. # setup TCP connections between a wired node and the MobileHost • set tcp1 [new Agent/TCP] • $tcp1 set class_ 2 • set sink1 [new Agent/TCPSink] • $ns_ attach-agent $W(0) $tcp1 • $ns_ attach-agent $MH $sink1 • $ns_ connect $tcp1 $sink1 • set ftp1 [new Application/FTP] • $ftp1 attach-agent $tcp1 • $ns_ at $opt(ftp1-start) "$ftp1 start“ • # Tell all nodes when the siulation ends • for {set i 0} {$i < $opt(nn) } {incr i} { • $ns_ at $opt(stop).0 "$node_($i) reset"; • } • $ns_ at $opt(stop).0 "$HA reset"; • $ns_ at $opt(stop).0 "$FA reset";

  26. Trace file • r 0.950460571 _62_ MAC --- 0 LEE 44 [0 ffffffff 0 800]---[0:255 -1:255 1 0] [0x8 0 0 0 0] • 這個紀錄說明著是node62在MAC層收到這個packet,packet header type 是”Lee”,packet數是0,packet的大小是44 bytes,目的地是 -1表示是在broadcasting,source port and destination port都是255。

More Related