1 / 107

2nd European ns-2 Workshop Day 2

Join the 2nd European ns-2 workshop for in-depth learning on ns-2 fundamentals, making changes, extending ns-2 with new components, and case studies. Learn about wired and wireless networks, TCP, UDP, network dynamics, and more. Don't miss out on this opportunity to explore advanced topics in ns-2!

harolda
Download Presentation

2nd European ns-2 Workshop Day 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. 2nd European ns-2 WorkshopDay 2 Polly Huang ETH Zurich http://www.tik.ee.ethz.ch/~huang 18 & 19 April

  2. Schedule: Yesterday 9-9.50 overview/intro/essential/getting started 10-10.50 tcl/otcl/ns-2 fundamentals 11-11.50 examples - TCP, RED, multicast, web, wireless Lunch break 1.30-2.20 lab 1 setup/running examples 2.30-3.20 lab 2 tcl/otcl exercises 3.30-4.20 lab 3 simple ns-2 exercise 4.30-5.00 discussion/feedback

  3. Schedule: Today 9-9.50 recap/wired internal 10-10.50 wireless internal/making changes 11-11.50 extending ns-2/case studies Lunch break 1.30-2.20 lab 4 intermediate ns-2 exercise 2.30-3.20 lab 5 getting data you want 3.30-4.20 lab 6 advanced topic (TBD) 4.30-5.00 discussion/feedback

  4. Event Scheduler ns-2 tclcl Network Component otcl tcl Interpreter With Extensions tcl8.0

  5. Example Script n0 n1 set ns [new Simulator] set n0 [$ns node] set n1 [$ns node] set ftp [new Application/FTP] $ftp attach-agent $tcp $ns at 0.2 "$ftp start" $ns at 1.2 ”exit" $ns run $ns duplex-link $n0 $n1 1.5Mb 10ms DropTail set tcp [$ns create-connection TCP $n0 TCPSink $n1 0]

  6. Basic ns-2: Covered wired & wireless unicast & multicast TCP & UDP errors & network dynamics ns & nam tracing application-level support

  7. Basic ns-2: Also But... • mobile IP • satellite • DiffServ • emulation

  8. Outline for This Morning • ns-2 Internal • Making changes • New components • in otcl • otcl and C++ Linkage • in C++ • Debugging

  9. ns-2 Internals • Discrete Event Scheduler • Network Topology • Routing • Transport • Application • Packet Flow • Packet Format

  10. Discrete Event Scheduler time_, uid_, next_, handler_ head_ -> head_ -> handler_ -> handle() insert time_, uid_, next_, handler_

  11. n0 n1 Port Classifier Multicast Node dmux_ Addr Classifier classifier_ Node entry Node entry dmux_ entry_ entry_ Multicast Classifier classifier_ multiclassifier_ Network Topology - Node Unicast Node

  12. n0 n1 n1 entry_ head_ enqT_ queue_ deqT_ link_ ttl_ drophead_ drpT_ Network Topology - Link

  13. n0 n1 Port Classifier Addr Classifier n1 entry_ Node entry 0 head_ dmux_ enqT_ queue_ deqT_ link_ ttl_ 1 entry_ classifier_ drophead_ drpT_ Routing

  14. n0 n1 Port Classifier Port Classifier Addr Classifier Addr Classifier 0 1 dmux_ dmux_ 1 0 entry_ entry_ classifier_ classifier_ Link n1-n0 Routing (cont.) Link n0-n1

  15. dst_addr_=0 dst_port_=0 dst_addr_=1 dst_port_=0 Agent/TCPSink Agent/TCP agents_ 1 0 1 0 Transport n0 n1 Port Classifier Port Classifier Addr Classifier Addr Classifier 0 0 agents_ dmux_ dmux_ Link n0-n1 entry_ entry_ classifier_ classifier_ Link n1-n0

  16. dst_addr_=0 dst_port_=0 dst_addr_=1 dst_port_=0 0 1 1 0 Application n0 n1 Port Classifier Port Classifier Application/FTP Addr Classifier Addr Classifier Agent/TCPSink Agent/TCP 0 0 agents_ agents_ dmux_ dmux_ Link n0-n1 entry_ entry_ classifier_ classifier_ Link n1-n0

  17. dst_addr_=0 dst_port_=0 dst_addr_=1 dst_port_=0 0 1 1 0 Packet Flow n0 n1 Port Classifier Port Classifier Application/FTP Addr Classifier Addr Classifier Agent/TCPSink Agent/TCP 0 0 Link n0-n1 entry_ entry_ Link n1-n0

  18. ts_ cmn header ptype_ ip header uid_ tcp header size_ rtp header iface_ trace header ... Packet Format header data

  19. ns-2 Wireless Internal Packet headers Mobile node Wireless channel

  20. ts_ cmn header ptype_ IP header uid_ ...... size_ LL wireless headers iface_ MAC 802_11 ARP ...... Wireless Packet Format header data

  21. Classifier: Forwarding Agent: Protocol Entity Node Entry LL: Link layer object IFQ: Interface queue MAC: Mac object PHY: Net interface Portrait of A Mobile Node port classifier Node protocol agent 255 routing agent addr classifier defaulttarget_ ARP LL LL LL IFQ IFQ MAC MAC Propagation and antenna models PHY PHY MobileNode CHANNEL

  22. Mobile Node: Layer 2 • Link Layer • Same as LAN, but with a separate ARP module • Interface queue • Give priority to routing protocol packets • Mac Layer • IEEE 802.11 • RTS/CTS/DATA/ACK for all unicast packets • DATA for all broadcast packets

  23. Mobile Node: Layer 1 • Network interface (PHY) • Parameters based on Direct Sequence Spread Spectrum (WaveLan) • Interface with: antenna and propagation models • Update energy: transmission and reception • Radio Propagation Model • Friss-space attenuation(1/r2) at near distance • Two-ray Ground (1/r4) at far distance • Antenna • Omni-directional, unity-gain

  24. Wireless Channel • Duplicate packets to all mobile nodes attached to the channel except the sender • It is the receiver’s responsibility to decide if it will accept the packet • Collision is handled at individual receiver • O(N2) messages  grid keeper

  25. Grid-keeper: An Optimization

  26. Outline for This Morning • ns-2 Internal • Making changes • New components • in otcl • otcl and C++ Linkage • in C++ • debugging

  27. Making Changes • In otcl space • source • recompile • in C++ space • recompile

  28. Adding New Components • in otcl • otcl and C++ linkage • in C++

  29. New Component Purely in otcl • Additional <new_stuff>.tcl file • source <new_stuff>.tcl • Adding new files • change Makefile (NS_TCL_LIB), tcl/lib/ns- lib.tcl • recompile

  30. C S C R cross traffic msg agent Example: Agent/Message n2 n4 128Kb, 50ms n0 n1 10Mb, 1ms 10Mb, 1ms n3 n5

  31. Agent/Message pkt: 64 bytes of arbitrary string Receiver-side processing • A UDP agent (without UDP header) • Up to 64 bytes user message • Good for fast prototyping a simple idea • Usage requires extending ns functionality S R

  32. Agent/Message: Step 1 • Define sender class Sender –superclass Agent/Message # Message format: “Addr Op SeqNo” Sender instproc send-next {} { $self instvar seq_ agent_addr_ $self send “$agent_addr_ send $seq_” incr seq_ global ns $ns at [expr [$ns now]+0.1] "$self send-next" }

  33. Agent/Message: Step 2 • Define sender packet processing Sender instproc recv msg { $self instvar agent_addr_ set sdr [lindex $msg 0] set seq [lindex $msg 2] puts "Sender gets ack $seq from $sdr" }

  34. Agent/Message: Step 3 • Define receiver packet processing Class Receiver –superclass Agent/Message Receiver instproc recv msg { $self instvar agent_addr_ set sdr [lindex $msg 0] set seq [lindex $msg 2] puts “Receiver gets seq $seq from $sdr” $self send “$addr_ ack $seq” }

  35. Agent/Message: Step 4 • Scheduler and tracing # Create scheduler set ns [new Simulator] # Turn on Tracing set fd [new “message.nam” w] $ns namtrace-all $fd

  36. Agent/Message: Step 5 • Topology for {set i 0} {$i < 6} {incr i} { set n($i) [$ns node] } $ns duplex-link $n(0) $n(1) 128kb 50ms DropTail $ns duplex-link $n(1) $n(4) 10Mb 1ms DropTail $ns duplex-link $n(1) $n(5) 10Mb 1ms DropTail $ns duplex-link $n(0) $n(2) 10Mb 1ms DropTail $ns duplex-link $n(0) $n(3) 10Mb 1ms DropTail $ns queue-limit $n(0) $n(1) 5 $ns queue-limit $n(1) $n(0) 5

  37. Agent/Message: Step 6 • Routing # Packet loss produced by queueing # Routing protocol: let’s run distance vector $ns rtproto DV

  38. Agent/Message: Step 7 • Cross traffic set udp0 [new Agent/UDP] $ns attach-agent $n(2) $udp0 set null0 [new Agent/NULL] $ns attach-agent $n(4) $null0 $ns connect $udp0 $null0 set exp0 [new Application/Traffic/Exponential] $exp0 set rate_ 128k $exp0 attach-agent $udp0 $ns at 1.0 “$exp0 start”

  39. Agent/Message: Step 8 • Message agents set sdr [new Sender] $sdr set packetSize_ 1000 set rcvr [new Receiver] $rcvr set packetSize_ 40 $ns attach $n(3) $sdr $ns attach $n(5) $rcvr $ns connect $sdr $rcvr $ns connect $rcvr $sdr $ns at 1.1 “$sdr send-next”

  40. Agent/Message: Step 9 • End-of-simulation wrapper (as usual) $ns at 2.0 finish proc finish {} { global ns fd $ns flush-trace close $fd exit 0 }

  41. Agent/Message: Result • Example output > ./ns msg.tcl Receiver gets seq 0 from 0 Sender gets ack 0 from 1 Receiver gets seq 1 from 0 Sender gets ack 1 from 1 Receiver gets seq 2 from 0 Sender gets ack 2 from 1 Receiver gets seq 3 from 0 Sender gets ack 3 from 1 Receiver gets seq 4 from 0 Sender gets ack 4 from 1 Receiver gets seq 5 from 0

  42. Add Your Changes into ns ns-allinone Tcl8.0 TK8.0 OTcl tclcl ns-2 nam-1 C++ code ... tcl mcast lib ... ex test mysrc examples msg.tcl validation tests OTcl code

  43. Add Your Change into ns • tcl/lib/ns-lib.tcl Class Simulator … source ../mysrc/msg.tcl • Makefile NS_TCL_LIB = \ tcl/mysrc/msg.tcl \ … • Or: change Makefile.in, make distclean, then ./configure --enable-debug

  44. Extending ns in C++ • Adding code in <new_stuff>.{cc,h} files • Change Makefile • make depend • recompile

  45. Guidelines • Decide position in class hierarchy • I.e., which class to derive from? • Create new packet header (if necessary) • Create C++ class, fill in methods • Define otcl linkage (if any) • Write otcl code (if any) • Build (and debug)

  46. Important Basics • class hierarchy • otcl and C++ linkage

  47. Class Hierarchy TclObject NsObject Connector Classifier Queue Delay Agent Trace AddrClassifier McastClasifier DropTail RED TCP Enq Deq Drop Reno SACK

  48. otcl and C++: The Duality Pure OTcl objects Pure C++ objects C++/OTcl split objects C++ OTcl ns

  49. C++/otcl Linkage

  50. TclObject • Basic hierarchy in ns for split objects • Mirrored in both C++ and otcl • Example set tcp [new Agent/TCP] $tcp set packetSize_ 1024 $tcp advanceby 5000

More Related