NS2 - Wireless Network Ming-Feng Yang. 2 2 Outline Basic wireless model Extensions wireless model Example - Ad hoc network Example – WLAN Example – Mobile.

Slides:



Advertisements
Similar presentations
Jump to first page NS Tutorial: mobile and wireless network simulation Ya Xu USC/ISI June 18, 1999.
Advertisements

Wireless world in NS Padma Haldar USC/ISI.
NS-2 (network simulator) NS by example παρουσίαση Κων/νος Τρούλος.
Brief Intro to ns2: The most widely used Network Simulator COMP5416 Advanced Network Technologies Based on: Marc Greis's
Ns-2 Tutorial Exercise (1) Multimedia Networking Group, The Department of Computer Science, UVA Jianping Wang Adopted from Nicolas’s slides Jianping Wang,
NS Tutorial (For CMPE 252 A) By Duy Nguyen 10/25/2012.
Network Simulator (NS) Prof. Nelson L. S. da Fonseca State University of Campinas, Brazil.
Introduction to NS. Information Main website Documentation, mailing list archive, tutorial Location of Source codes –C++ files.
Introduction to Wireless simulations Shao-Cheng Wang.
Simulation of GPRS MS-BS Interface Using ns-Network Simulator Dual Degree Presentation by Richa Jain (96D07007) Department of Electrical Engineering, Indian.
報告者:黃亮維 NS2 Chapter 26 Trace Support. Outline  Trace Support ‧ OTcl Helper Functions  Library support and examples  The C++ Trace Class  Trace File.
Network Simulator 2 Tejas Vasavada.
1 Network Simulator (NS-2). 2 講義 Network Simulator (NS2) Part 1: 下載 Part 2: 安裝與測試 Part 3: 劇本 Part 4: 數據.
Katz, Stoica F04 EECS 122 Introduction to Computer Networks (Fall 2003) Network simulator 2 (ns-2) Department of Electrical Engineering and Computer Sciences.
CprE 543x – ns-2 Tutorial Zak Abichar, Dept of Electrical and Computer Engineering Iowa State University Ames,
Day 3 Outline Multicast example (from Day 2) Wireless Misc. utilities
Yinfei Pan SUNY Binghamton Computer Science
1 Modified Schedule Day 2 Network AniMator (nam) Examples simple.tcl mcast.tcl Day 3 Wireless (ad-hoc)
Submitters: Stella Pantofel Michael Halperin Igor Berman
Jump to first page NS Tutorial: mobile and wireless network simulation Ya Xu USC/ISI September 10th, 1999.
1 2nd European ns-2 Workshop Polly Huang ETH Zurich April 18 & 19, 2001.
EECS122 - UCB1 Measurements and Modeling Table of Contents 1. Measurements Measurements 2. Modeling and its Shortcomings Modeling and its Shortcomings.
Ns Simulation of IEEE SC546 Project (Fall 2002) SOO IL KIM JISUN YOON
Introduction to Network Simulator NS-2 Part II
Routing in Mobile Ad-Hoc Networks An M.Tech. Project by Srinath Perur Guide: Prof. Sridhar Iyer.
Simulators for Sensor Networks Sagnik Bhattacharya 9/12/2001.
NS2 Tutorial Aga Zhang Dependable Computing Lab. Outline Introduction Fundamental Skills - Tcl and OTcl Network Simulator - ns-2 Study Project - Mobile.
Network Simulator 2(NS2) Yingyue Xu 8/25/2015. Overview: The Network simulator (NS): discrete event simulator for networks. supports wired, wireless,
Network Simulator (NS2) 1 Tutorial on Network Simulator (NS2) Hemant Kumar Rath Infonet Lab, Dept of Electrical Engineering IIT Bombay, Mumbai
Wireless Networking and Systems CSE 590 ns2 tutorial.
Introduction to ns-2 Noun Choi Oct. 11, Outline Background ns-2 Internals Short demo Troubleshooting Reference links Q & A.
1 Introduction to Ns-2 Zhibin WU WINLAB, ECE Dept. Rutgers U.
1 / 10 Mobile Networking in ns Speaker : Mark Yang
NS2 Tutorial for CS740 Jianming Wu *modified from Aga Zhang.
Introduction to Mobility & Network Simulator 2 (NS-2)
NS2 tutorial ChihHeng, Ke ( 柯志亨 ) Phd Candidate, EE Department, NCKU MSN:
Define options(1/2) #channel type set val(chan) Channel/WirelessChannel # radio-propagation model set val(prop) Propagation/TwoRayGround # network interface.
MOBILE IP SOMULATION IN NS2 Presenter: 吳寶緣. Outlines  Overview  Hierarchical Address Format  Hierarchical Address Format-ex  MoblieIP Demo  Additional.
Network Simulator-2 Sandeep singla 1998A2A7540. NS-2 A discrete event simulator Focused on modeling network protocols –Wired, wireless –TCP,UDP,unicast,multicast.
TNK092: Network Simulation - Nätverkssimulering Lecture 3: TCP Vangelis Angelakis.
NetFlow Very useful for traffic analysis Very useful for traffic analysis Standard sampler: Standard sampler: –Cisco Netflow –Juniper Traffic Sampling.
1 Network Simulator Tutorial. 2 Network Simulation * Motivation: Learn fundamentals of evaluating network performance via simulation Overview: fundamentals.
Internet Computing KUT Youn-Hee Han
Network Simulator ns-2. 2 Agenda Introduction Interface Tcl and OTcl TclCL Simulator Wired network Wireless network Program Assignment.
Chapter 15 The Addressing Structure in NS. The Default Address Format 32 lower bits for port-id, 1 higher bit for mcast and the rest 32 higher bits for.
Quality evaluation of MPEG4 video transmission over GPRS networks.. Presented by: Abdullah M. Rana Multimedia Communication.
1 Network Simulation and Testing Polly Huang EE NTU
1 NS Fundamentals. USC INFORMATION SCIENCES INSTITUTE 2 OTcl and C++: The Duality C++ OTcl Pure C++ objects Pure OTcl objects C++/OTcl split objects ns.
1 Introduction to NS-2 r Tutorial overview of NS m Create basic NS simulation r Walk-through a simple example m Model specification m Execution and trace.
NS2-TCP Internet Computing KUT ( Youn-Hee Han It is licensed under a Creative Commons Attribution.
Network Simulator Tutorial Wireless Networks. Acknowledgements Material is taken from the presentations by Jim Kurose, University of Massachusetts, Amherst.
CDA6530: Performance Models of Computers and Networks Chapter 10: Introduction to Network Simulator (NS2) TexPoint fonts used in EMF. Read the TexPoint.
The Creation of NS2 Simulated Environment ( 1 ) LI Chengbo
TNK092: Network Simulation - Nätverkssimulering Lecture #1: Course basics and a first taste of NS2 Vangelis Angelakis Ph.D.
Use of Mobility models in ns-2 Karthik Dantu Shyam Kapadia.
NS-2 Shahin Shayandeh December 2004 Session 1. Ns-2, the Network Simulator  A discrete event simulator Simple model  Focused on modeling network protocols.
Network Simulator with Mobile IP 2003 Huang – Yu Liu.
DMET 602: Networks and Media Lab Amr El Mougy Yasmeen EssamAlaa Tarek.
1 Network Simulator 2 Install Chao-Ying Chiu
DMET 602: Networks and Media Lab
Network Simulator Tutorial
Basics of NS-2 Training in TCL script
Chapter 16 Mobile Networking in ns
Choe, Hyun Jung (Stella)
Introduction to ns-2: “The” Network Simulator
Planned Activities on Computer Networks for Sunday Academy
Karthik Sadasivam Banuprasad Samudrala
NS2 tutorial ChihHeng, Ke (柯志亨) Phd Candidate, EE Department, NCKU
Introduction to ns-2 Noun Choi Oct. 11, 2007.
TexPoint fonts used in EMF.
Presentation transcript:

NS2 - Wireless Network Ming-Feng Yang

2 2 Outline Basic wireless model Extensions wireless model Example - Ad hoc network Example – WLAN Example – Mobile IP

3 3 Basic wireless model Creating wireless topology set topo [new Topography] $topo load_flatgrid $opt(x) $opt(y) # where opt(x) and opt(y) are the boundaries used in simulation

4 4 Basic wireless model Configure the node $ns_ node-config -adhocRouting DSDV or DSR or TORA or AODV \ -topoInstance $topo \ -addressType flat or hierarchical or expanded\ -wiredRouting ON \ -mobileIP ON \ -llType LL \ -macType Mac/802_11 \ -antType Antenna/OmniAntenna \ -propType Propagation/TwoRayGround \ -phyType Phy/WirelessPhy \ -channelType Channel/WirelessChannel \ -ifqType Queue/DropTail/PriQueue \ -ifqLen \ -agentTrace ON or OFF \ -routerTrace ON or OFF \ -macTrace ON or OFF \ -movementTrace ON or OFF MobileIP Wired-cum-wireless

5 5 Basic wireless model Node movement $node set X_ $node set Y_ $node set Z_ # Start-position $ns at $time $node setdest # Future destinations

6 6 Basic wireless model New traces format $ns use-newtrace s -t Hs 1 -Hd -1 -Ni 1 -Nx Ny Nz Ne Nl RTR -Nw --- -Ma 0 -Md 0 -Ms 0 -Mt 0 -Is Id It message -Il 32 -If 0 -Ii 0 -Iv 32 event s,r,d,f time id for next hop destination node id node’s x-coordinate node’s z-coordinate node’s y-coordinate node energy level trace level reason for this event duration dest’s ethernet addr source’s ethernet addr ethernet type source’s addr.port dest’s addr.port packet type packet size flow id unique id ttl value -H: next hop info -N: node info -M: MAC level info -I: IP level info

7 7 Basic wireless model Movement scenario generator cd ns-allinone-2.27/ns-2.27/indep-utils/cmu-scen-gen/setdest./setdest -n 3 -p 2.0 -s t 300 -x 600 -y 600 > pattern-file Num-of-nodesPause-timeMax-speedSim-timeTopo-boundary source pattern-file set god_ [God instance] $ns_ at "$node_(2) setdest ” $ns_ at "$node_(1) setdest ” $ns_ at "$node_(0) setdest ” $god_ set-dist $god_ set-dist $god_ set-dist $node_(2) set Z_ $node_(2) set Y_ $node_(2) set X_ $node_(1) set Z_ $node_(1) set Y_ $node_(1) set X_ $node_(0) set Z_ $node_(0) set Y_ $node_(0) set X_ :

8 8 Basic wireless model Traffic scenario generator ns cbrgen.tcl -type tcp -nn 25 -seed 0.0 -mc 8 > pattern-file ns cbrgen.tcl -type cbr -nn 10 -seed 1.0 -mc 8 -rate 4.0 > pattern-file CBR-or-TCPNum-of-nodesRandom-seedMax-connectionCBR-rate source pattern-file # nodes: 10, max conn: 8, send rate: 0.25, seed: 1.0 # 1 connecting to 2 at time set udp_(0) [new Agent/UDP] $ns_ attach-agent $node_(1) $udp_(0) set null_(0) [new Agent/Null] $ns_ attach-agent $node_(2) $null_(0) set cbr_(0) [new Application/Traffic/CBR] $cbr_(0) set packetSize_ 512 $cbr_(0) set interval_ 0.25 $cbr_(0) set random_ 1 $cbr_(0) set maxpkts_ $cbr_(0) attach-agent $udp_(0) $ns_ connect $udp_(0) $null_(0) $ns_ at "$cbr_(0) start“ :

9 9 Extensions wireless model wired-cum-wireless $ns_ node-config -addressType hierarchical AddrParams set domain_num_ 2 lappend cluster_num 2 1 AddrParams set cluster_num_ $cluster_num lappend eilastlevel AddrParams set nodes_num_ $eilastlevel set temp { } for {set i 0} {$i < $num_wired_nodes} {incr i} { set W($i) [$ns_ node [lindex $temp $i]] } $ns_ node-config -wiredRouting ON set temp { } set BS(0) [$ns_ node [lindex $temp 0]] $BS(0) random-motion 0 $ns_ node-config -wiredRouting OFF for {set j 0} {$j < $opt(nn)} {incr j} { set node_($j) [ $ns_ node [lindex $temp [expr $j+1]] ] $node_($j) base-station [AddrParams addr2id [$BS(0) node-addr]] } W(0) W(1) BS(0) node_(1) node_(0) node_(2) domain 0 domain 1 cluster 0 cluster 1 cluster 0 0,0,0 0,1,0 1,0,0 1,0,1 1,0,2 1,0,3

10 Extensions wireless model Mobile IP $ns_ node-config -mobileIP ON set HA [$ns_ node 1.0.0] set FA [$ns_ node 2.0.0] $HA random-motion 0 $FA random-motion 0 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 W(0) W(1) HA MH FA

11 Example - Ad hoc network Traffic: node(0) to node(1)

12 Example - Ad hoc network Traffic: node(0) to node(1)

13 Example - Ad hoc network Traffic: node(0) to node(1)

14 Example - Ad hoc network set val(chan)Channel/WirelessChannel;# channel type set val(prop)Propagation/TwoRayGround;# radio-propagation model set val(netif)Phy/WirelessPhy;# network interface type set val(mac)Mac/802_11;# MAC type set val(ifq)Queue/DropTail/PriQueue;# interface queue type set val(ll)LL ;# link layer type set val(ant)Antenna/OmniAntenna ;# antenna model set val(ifqlen)50 ;# max packet in ifq set val(nn)3 ;# number of nodes set val(rp)DSDV ;# routing protocol set val(x)500 ;# X dimension of topography set val(y)400 ;# Y dimension of topography set val(stop)150;# time of simulation end # Define options set ns [new Simulator] set tracefd [open out.tr w] set namtrace [open out.nam w] $ns trace-all $tracefd $ns namtrace-all-wireless $namtrace $val(x) $val(y)

15 Example - Ad hoc network set topo [new Topography] $topo load_flatgrid $val(x) $val(y) # Create a topology object that keeps track of movements of nodes within the topological boundary create-god $val(nn) # God object is used to store global information about the state of the environment, network or nodes $ns node-config-adhocRouting $val(rp) \ -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 ON \ -macTrace OFF \ -movementTrace ON # Configure the nodes

16 Example - Ad hoc network for {set i 0} {$i < $val(nn) } { incr i } { set node_($i) [$ns node] $node_($i) random-motion 0;# disable random motion } # Create the specified number of nodes [$val(nn)] and "attach" them to the channel $node_(0) set X_ 5.0 $node_(0) set Y_ 5.0 $node_(0) set Z_ 0.0 $node_(1) set X_ $node_(1) set Y_ $node_(1) set Z_ 0.0 $node_(2) set X_ $node_(2) set Y_ $node_(2) set Z_ 0.0 # Provide initial location of nodes $ns at 10.0 "$node_(0) setdest " $ns at 30.0 "$node_(1) setdest " $ns at "$node_(0) setdest " # Generation of movements

17 Example - Ad hoc network set tcp [new Agent/TCP] set sink [new Agent/TCPSink] $ns attach-agent $node_(0) $tcp $ns attach-agent $node_(1) $sink $ns connect $tcp $sink set ftp [new Application/FTP] $ftp attach-agent $tcp $ns at 10.0 "$ftp start" # Set up a TCP connection between node_(0) and node_(1) for {set i 0} {$i < $val(nn)} { incr i } { $ns initial_node_pos $node_($i) 40 } # Define node initial position in NAM, 40 defines the node size for NAM for {set i 0} {$i < $val(nn) } { incr i } { $ns at $val(stop) "$node_($i) reset"; } # Telling nodes when the simulation ends

18 Example - Ad hoc network $ns at $val(stop) "$ns nam-end-wireless $val(stop)" $ns at $val(stop) "stop" proc stop {} { global ns tracefd namtrace $ns flush-trace close $tracefd close $namtrace exec nam out.nam & exit 0 } # ending nam and the simulation $ns run

19 Example - WLAN Traffic: node(3) to node(0), node(1) to node(5),

20 Example - WLAN Traffic: node(3) to node(0), node(1) to node(5),

21 Example - WLAN Traffic: node(3) to node(0), node(1) to node(5),

22 Example - WLAN Traffic: node(3) to node(0), node(1) to node(5),

23 Example - WLAN 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) 3 ;# number of mobilenodes set opt(rp) DSDV ;# routing protocol set opt(x) 300 ;# x coordinate of topology set opt(y) 300 ;# y coordinate of topology set opt(stop) 30 ;# time to stop simulation set opt(ftp1-start) 5.0 set opt(ftp2-start) 5.0 set num_wired_nodes 2 set num_bs_nodes 1 # Define options

24 Example - WLAN set ns [new Simulator] set tracefd [open out.tr w] set namtrace [open out.nam w] $ns trace-all $tracefd $ns namtrace-all-wireless $namtrace $opt(x) $opt(y) $ns node-config -addressType hierarchical AddrParams set domain_num_ 2 ;# number of domains lappend cluster_num 2 1 ;# number of clusters in each domain AddrParams set cluster_num_ $cluster_num lappend eilastlevel 1 1 4;# number of nodes in each cluster of each domain AddrParams set nodes_num_ $eilastlevel # set up for hierarchical routing set topo [new Topography] $topo load_flatgrid $opt(x) $opt(y) # Create a topology object that keeps track of movements of nodes within the topological boundary create-god [expr $opt(nn) + $num_bs_nodes] # God object is used to store global information about the state of the environment, network or nodes

25 Example - WLAN set temp { } ;# hierarchical addresses for wired domain for {set i 0} {$i < $num_wired_nodes} {incr i} { set W($i) [$ns node [lindex $temp $i]] } #Create wired nodes $ns node-config -adhocRouting $opt(rp) \ -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 # Configure for base-station node

26 Example - WLAN set temp { } ;# hierarchical addresses to be used for wireless domain set BS(0) [$ns node [lindex $temp 0]] $BS(0) random-motion 0 ;# disable random motion #create base-station node $BS(0) set X_ $BS(0) set Y_ $BS(0) set Z_ 0.0 # provide some co-ord (fixed) to base-station node $ns node-config -wiredRouting OFF for {set j 0} {$j < $opt(nn)} {incr j} { set node_($j) [ $ns node [lindex $temp [expr $j+1]] ] $node_($j) base-station [AddrParams addr2id [$BS(0) node-addr]] } # create mobilenodes in the same domain as BS(0) and configure for mobilenodes $ns duplex-link $W(0) $W(1) 5Mb 2ms DropTail $ns duplex-link $W(1) $BS(0) 5Mb 2ms DropTail #create links between wired and BS nodes $ns duplex-link-op $W(0) $W(1) orient down $ns duplex-link-op $W(1) $BS(0) orient left-down

27 Example - WLAN set tcp1 [new Agent/TCP] set sink1 [new Agent/TCPSink] $ns attach-agent $node_(0) $tcp1 $ns attach-agent $W(0) $sink1 $ns connect $tcp1 $sink1 $tcp1 set fid_ 1 set ftp1 [new Application/FTP] $ftp1 attach-agent $tcp1 $ns at $opt(ftp1-start) "$ftp1 start" # setup first TCP connection set tcp2 [new Agent/TCP] $tcp2 set class_ 2 set sink2 [new Agent/TCPSink] $ns attach-agent $W(1) $tcp2 $ns attach-agent $node_(2) $sink2 $ns connect $tcp2 $sink2 $tcp2 set fid_ 2 set ftp2 [new Application/FTP] $ftp2 attach-agent $tcp2 $ns at $opt(ftp2-start) "$ftp2 start" # setup second TCP connection

28 Example - WLAN $node_(0) set X_ $node_(0) set Y_ $node_(0) set Z_ 0.0 $node_(1) set X_ $node_(1) set Y_ $node_(1) set Z_ 0.0 $node_(2) set X_ 20.0 $node_(2) set Y_ 20.0 $node_(2) set Z_ 0.0 # Provide initial location of nodes $ns at 10.0 "$node_(0) setdest " $ns at 15.0 "$node_(1) setdest " $ns at 5.0 "$node_(2) setdest " # Generation of movements

29 Example - WLAN for {set i } {$i < $opt(nn) } {incr i} { $ns at $opt(stop) "$node_($i) reset"; } $ns at $opt(stop) "$BS(0) reset"; # Tell all nodes when the simulation ends $ns at $opt(stop) "$ns nam-end-wireless $opt(stop)" $ns at $opt(stop) "stop" proc stop {} { global ns tracefd namtrace $ns flush-trace close $tracefd close $namtrace exec nam out.nam & exit 0 } # ending nam and the simulation $ns run

30 Example – Mobile IP Traffic: node(0) to node(4)

31 Example – Mobile IP Traffic: node(0) to node(4)

32 Example – Mobile IP Traffic: node(0) to node(4)

33 Example – Mobile IP Traffic: node(0) to node(4)

34 Example – Mobile IP Traffic: node(0) to node(4)

35 Example – Mobile IP 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(rp) DSDV ;# routing protocol set opt(x) ;# x coordinate of topology set opt(y) ;# y coordinate of topology set opt(stop) 50.0 ;# time to stop simulation set opt(ftp1-start) 0.0 set num_wired_nodes 2 set num_bs_nodes 2 # Define options

36 Example – Mobile IP set ns [new Simulator] set tracefd [open out.tr w] set namtrace [open out.nam w] $ns trace-all $tracefd $ns namtrace-all-wireless $namtrace $opt(x) $opt(y) $ns color 1 Red $ns node-config -addressType hierarchical 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 ;# number of nodes in each cluster of each domain AddrParams set nodes_num_ $eilastlevel # set up for hierarchical routing set topo [new Topography] $topo load_flatgrid $opt(x) $opt(y) # Create a topology object that keeps track of movements of nodes within the topological boundary

37 Example – Mobile IP create-god [expr $opt(nn) + $num_bs_nodes] # God object is used to store global information about the state of the environment, network or nodes set temp { } ;# hierarchical addresses for wired domain for {set i 0} {$i < $num_wired_nodes} {incr i} { set W($i) [$ns node [lindex $temp $i]] } #Create wired nodes $ns node-config -mobileIP ON \ -adhocRouting $opt(rp) \ -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 # Configure for ForeignAgent and HomeAgent nodes

38 Example – Mobile IP set HA_ [$ns node 1.0.0] set FA_ [$ns node 2.0.0] $HA_ random-motion 0 $FA_ random-motion 0 # Create HA and FA $HA_ set X_ $HA_ set Y_ $HA_ set Z_ 0.0 $FA_ set X_ $FA_ set Y_ $FA_ set Z_ 0.0 # Position (fixed) for base-station nodes (HA & FA). $ns node-config -wiredRouting OFF set MH_ [$ns node 1.0.1] set HAaddress [AddrParams addr2id [$HA_ node-addr]] [$MH_ set regagent_] set home_agent_ $HAaddress # note address of MH indicates its in the same domain as HA. $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 # create links between wired and BaseStation nodes

39 Example – Mobile IP set tcp1 [new Agent/TCP] set sink1 [new Agent/TCPSink] $ns attach-agent $W(0) $tcp1 $ns attach-agent $MH_ $sink1 $ns connect $tcp1 $sink1 $tcp1 set fid_ 1 set ftp1 [new Application/FTP] $ftp1 attach-agent $tcp1 $ns at $opt(ftp1-start) "$ftp1 start" # setup TCP connections between a wired node and the MobileHost $MH_ set X_ $MH_ set Y_ $MH_ set Z_ 0.0 # Provide initial location of MH $ns at 5.0 "$MH_ setdest " # MH starts to move towards FA $ns at 25.0 "$MH_ setdest " # goes back to HA $ns initial_node_pos $MH_ 10 # Define initial node position in NAM

40 Example – Mobile IP $ns at $opt(stop) "$MH_ reset"; $ns at $opt(stop) "$HA_ reset"; $ns at $opt(stop) "$FA_ reset"; # Tell all nodes when the simulation ends $ns at $opt(stop) "$ns nam-end-wireless $opt(stop)" $ns at $opt(stop) "stop" proc stop {} { global ns tracefd namtrace $ns flush-trace close $tracefd close $namtrace exec nam out.nam & exit 0 } # ending nam and the simulation $ns run