Upload
ryan-torres
View
43
Download
0
Embed Size (px)
DESCRIPTION
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. - PowerPoint PPT Presentation
Citation preview
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
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.
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
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
Network Simulator
Install ns :
Get file ns-allinone-2.26.tar.gz
輸入 tar zxvf ns-allinone-2.26.tar.gz
p.s 假設在根目錄下輸入此指令
Network Simulator
進入 ns-allinone-2.26 資料夾
執行 ./install
Network Simulator
安裝完成後 , 設定環境變數 . 把 /ns-allinone-2.26/bin:/root/ns-allinone-2.2
6/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 環境變數 .
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
Network Simulator - Template
#Create a simulator objectset ns [new Simulator]
#Open the nam trace fileset nf [open out.nam w]$ns namtrace-all $nf
#Define a 'finish' procedureproc 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
Network Simulator
Two nodes, one linkset n0 [$ns node]
set n1 [$ns node]
$ns duplex-link $n0 $n1 1Mb 10ms DropTail
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
Network Simulator
#Create a Null agent (a traffic sink) and attach it to node n1set 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"
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 SFQSFQ (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
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
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"
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
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
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
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]
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
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
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
# 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";
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 。
Trace file
$ns use-newtrace: 目前這道指令的 new trace support 只
有在無線模擬中才可以,未來應該可以擴展到 ns 其餘的功能上。
Trace file
s -t 1.511681090 -Hs 1 -Hd -1 -Ni 1 -Nx 390.00 -Ny 385.00 -Nz 0.00 –Ne -1.000000 -N1 RTR -Nw --- -Ma 0 -Md 0 -Ms 0 -Mt 0 -Is 1.255 –Id -1.255 –It message -I1 32 -If 0 -Ii 1 -Iv 32
Explanation of new trace format Event type: 第一個欄位是描述事件的形式,有以下四種形式 s send( 傳送 ) r receive item[d]drop( 接收或是捨棄 ) f forward( 轉寄 ) General tag: 第二個欄位用 "-t" 是表示時間或是全區設定 (global setting) -t time -t *(global setting)
Node property tags: 這一個欄位表示 Node 的特性
-Ni node id -Nx node's x-coordinate(x 軸 )-Ny node's y-coordinate-Nz node's z-coordinate-Ne node energy level-Nl trace level,such as AGT(agent),RTR(router),MAC-Nw 事件的理由,捨棄 packet 的不同理由如下:
"END" DROP_END_OF_SIMULATION"COL" DROP_MAC_COLLISION"DUP" DROP_MAC_DUPLICATE"ERR" DROP_MAC_PACKET_ERROR"RET" DROP_MAC_RETRY_COUNT_EXCEEDED"STA" DROP_MAC_INVALID"BSY" DROP_MAC_BUSY"NRTE" DROP_RTR_NO_ROUTE i.e 沒有有用的 route 。"LOOP" DROP_RTR_ROUTE_LOOP i.e 有 routing 的迴圈。"TTL"DROP_RTR_TTL i.e TTL(Time to live) i.e 封包可以存活的時間趨近於
零。"TOUT" DROP_RTR_QTIMEOUT i.e 封包存活時間到了。"CBK" DROP_RTR_MAC_CALLBACK"IFQ" DROP_IFQ_QFULL_ i.e IFQ 沒有緩衝空間了"ARP" DROP_IFQ_ARP_FULL i.e 被 ARP 捨棄"OUT" DROP_OUTSIDE_SUBNET i.e 被正在在它 domain 外面的 node 接
收 routing 更新的 base stations 所捨棄。
Packet information at IP level: 提供在 IP 層的資訊
-Is source address.source port number -Id destination address.destinaton port number-It packet type-Il packet size-If flow id-Ii unique id-Iv ttl value
Next hop info: 提供下一個 hop 的資訊
-Hs id for this node-Hd id for next hop toward the destination
Packet info at MAC level: 提供在 MAC 層的資訊
-Ma duration-Md dst's ethernet address-Ms src's ethernet address-Mt ethernet type