Presentation is loading. Please wait.

Presentation is loading. Please wait.

Network Simulator with Mobile IP 2003 Huang – Yu Liu.

Similar presentations


Presentation on theme: "Network Simulator with Mobile IP 2003 Huang – Yu Liu."— 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/0150installredh at.php http://linux.vbird.org/linux_basic/0150installredh at.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] ns-2.1b8[OLD] / ns-2.24[NEW] released on Wed June 06 11:05:52 PDT 2001

7

8

9

10

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

12

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

14

15

16

17

18 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 環境變數.

19 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

20

21

22

23 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

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

25

26 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

27 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"

28

29 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

30

31 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

32 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"

33

34

35 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

36 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

37

38 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

39 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]

40 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

41 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

42 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

43 # 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";

44

45

46

47

48

49

50 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 。

51 Trace file $ns use-newtrace: 目前這道指令的 new trace support 只有 在無線模擬中才可以,未來應該可以擴 展到 ns 其餘的功能上。

52 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)

53 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 所捨棄。

54 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


Download ppt "Network Simulator with Mobile IP 2003 Huang – Yu Liu."

Similar presentations


Ads by Google