1 / 46

Network Simulator (NS-2)

Network Simulator (NS-2). 講義. Network Simulator (NS2) Part 1: 下載 Part 2: 安裝與測試 Part 3: 劇本 Part 4: 數據. Part 1: 下載. http://www.isi.edu/nsnam/ns. Step 1. ns-allinone-2.33.tar.gz. 約 50MB UP. Step 2. Part 2: 安裝與測試. Setup for Linux-based systems If the file is put at /root

tadhg
Download Presentation

Network Simulator (NS-2)

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 (NS-2)

  2. 講義 • Network Simulator (NS2) • Part 1: 下載 • Part 2: 安裝與測試 • Part 3: 劇本 • Part 4: 數據

  3. Part 1: 下載

  4. http://www.isi.edu/nsnam/ns

  5. Step 1

  6. ns-allinone-2.33.tar.gz 約50MB UP Step 2

  7. Part 2: 安裝與測試

  8. Setup for Linux-based systems • If the file is put at /root • Step 1: cd /root • Step 2: tar zxvf ns-allinone-2.33.tar.gz • Step 3: cd /root/ns-allinone-2.33 • Step 4: ./install • Setup for windows-based systems • 安裝流程 • http://140.116.72.80/~smallko/ns2/setup.htm • 中文教學網站-柯志亨(Chih-Heng, Ke) • http://140.116.72.80/~smallko/ns2/ns2.htm

  9. Directory structure ns-allinone-2.33 ….. tcl8.4 tk8.4 bin ns-2.33 nam-1.12 Source node (C++) Execute files AODV aodv.cc, aodv.h, aodv_packet.h

  10. Overview for NS2 structure

  11. Part 3: 劇本1 Base station (original data server) Mobile host

  12. BS_MH_1.tcl • set ns_ [new Simulator] • set tracefd [open Trace w] • $ns_ trace-all $tracefd • set nf [open BS_MH_nam w] • $ns_ namtrace-all-wireless $nf 1550 1550 • set topo [new Topography] • $topo load_flatgrid 1550 1550 • create-god 3 • $ns_ node-config -adhocRouting AODV \ • -llType LL \ • -macType Mac/802_11 \ • -ifqType Queue/DropTail/PriQueue \ • -ifqLen 50 \ • -antType Antenna/OmniAntenna \ • -propType Propagation/TwoRayGround \ • -phyType Phy/WirelessPhy \ • -channelType Channel/WirelessChannel \ • -topoInstance $topo \ • -agentTrace ON \ • -routerTrace ON \ • -macTrace OFF \ • -movementTrace OFF

  13. for {set i 0} {$i < 3 } {incr i} { • set node_($i) [$ns_ node] • $node_($i) random-motion 0 • } • set udp0 [new Agent/UDP] • set null0 [new Agent/Null] • $ns_ attach-agent $node_(1) $udp0 • $ns_ attach-agent $node_(2) $null0 • $ns_ connect $udp0 $null0 • set cbr0 [new Application/Traffic/CBR] • $cbr0 set type_ CBR • $cbr0 set packet_size_ 500 • $cbr0 set interval_ 0.5 • $cbr0 attach-agent $udp0

  14. $node_(0) set X_ 1 • $node_(0) set Y_ 1 • $ns_ at 0 "$node_(0) setdest 1 1 1" • $node_(1) set X_ 500 • $node_(1) set Y_ 500 • $ns_ at 0 "$node_(1) setdest 500 500 1" • $node_(2) set X_ 500 • $node_(2) set Y_ 400 • $ns_ at 0 "$node_(2) setdest 500 400 1" • $ns_ at 100 "$cbr0 start" • $ns_ at 100 "$cbr0 stop" • $ns_ at 100 "stop" • proc stop {} { • global ns_ tracefd • $ns_ flush-trace • close $tracefd • exit 0 • } • $ns_ run

  15. 執行劇本 • Step 1: cd /root/ns-allinone-2.33 • Step 2: cd bin • Step 3: ./ns my_scenario.tcl • Option • Step 4: ./nam BS_MH_nam

  16. Useful additional program • NAM: Viewing network simulation traces and real world packet traces

  17. 自行撰寫劇本產生器 • Network size, Number of nodes, Simulation time • EX: ./scenario_generator 1500 1500 50 300 my_scenario.tcl • PS:這隻程式請自行撰寫,之後會繼續用到且延伸。 • 由於是產生”文字檔”,所以任何語言且可以。

  18. Event-driven for Node • 1. Create timer • AODV.h • AODV.cc Event 1 Simulation Time

  19. aodv.h

  20. aodv.h

  21. aodv.h

  22. aodv.cc

  23. aodv.cc

  24. aodv.cc

  25. aodv.h

  26. aodv.cc

  27. How to compile source code? • 1. cd /root/ns-allinone-2.33/ns-2.33 • 2. make

  28. aodv.cc

  29. aodv.cc

  30. aodv_packet.h

  31. aodv.cc

  32. aodv.cc

  33. aodv.cc

  34. aodv.h

  35. aodv.cc

  36. Part 4: 數據

  37. aodv.cc

  38. aodv.cc

  39. 劇本2: Measure the Round-Trip Time (RTT) Base station (original data server) Mobile host RTT (ms) Number of node:20, 50 Overall query rate: 5 Simulation time: 100 1000 100 200 300 400 500 data size (bytes)

More Related