Скачать презентацию Introduction to NS-3 Part — 2 Katsaros Konstantinos Скачать презентацию Introduction to NS-3 Part — 2 Katsaros Konstantinos

ns-3-workshop-part2.pptx

  • Количество слайдов: 16

Introduction to NS-3 Part - 2 Katsaros Konstantinos Ph. D Student PGSDP Workshop on Introduction to NS-3 Part - 2 Katsaros Konstantinos Ph. D Student PGSDP Workshop on NS-3 2 April 2012

Overview Ø Flow. Monitor Ø Smart Pointers Ø Packet Tags Ø Debugging Ø Visualization Overview Ø Flow. Monitor Ø Smart Pointers Ø Packet Tags Ø Debugging Ø Visualization Ø Creating a new Module Ø Advanced Simulation with NS-3 Ø NSC (Network Simulator Cradle) Ø MPI (Message Passing Interface) Ø EMU (Emulation) Konstantinos Katsaros 2

Flow Monitor • A common problem was identified – “how to easily extract flow Flow Monitor • A common problem was identified – “how to easily extract flow metrics from arbitrary simulations? ” • Existing solutions do not solve this problem effectively • The Flow Monitor solves the problem – Requires significant less programming time than NS-3 callback based tracing – A lot more efficient than ascii tracing • More data output methods (e. g. database and binary file) • More options to control level of detail stored in memory • Monitor multicast/broadcast flows Konstantinos Katsaros 3

Flow Monitor Measurements • • • time. First. Tx. Packet, time. Last. Tx. Packet Flow Monitor Measurements • • • time. First. Tx. Packet, time. Last. Tx. Packet begin and end times of the flow from the point of view of the receiver time. First. Rx. Packet, time. Last. Rx. Packet begin and end times of the flow from the point of view of the receiver delay. Sum, jitter. Sum sum of delay and jitter values tx. Bytes, tx. Packets number of transmitted bytes and packets rx. Bytes, rx. Packets number of received bytes and packets lost. Packets number of definitely lost packets times. Forwarded the number of times a packet has been reportedly forwarded, summed for all packets in the flow delay. Histogram, jitter. Histogram, packet. Size. Histogram versions for the delay, jitter, and packet sizes, respectively packets. Dropped, bytes. Dropped discriminates the losses by a reason code – DROP NO ROUTE no IPv 4 route found for a packet – DROP TTL EXPIRE a packet was dropped due to an IPv 4 TTL field decremented and reaching zero – DROP BAD CHECKSUM a packet had a bad IPv 4 header checksum and had to be dropped Konstantinos Katsaros 4

Flow Monitor Example Create a Flow. Monitor. Helper object Flow. Monirtor. Helper flowmon; Create Flow Monitor Example Create a Flow. Monitor. Helper object Flow. Monirtor. Helper flowmon; Create a pointer to Flow. Monirot class and install probes to all nodes Ptr monitor = flowmon. Install. All(); Configure histogram parameters Monitor->Set. Attribute (”Delay. Bin. Width”, Double. Value(0. 001)); Monitor->Set. Attribute (”Jitter. Bin. Width”, Double. Value (0. 001)); Run simulation Simulator: : Run (); Write results into an XML file monitor->Serialize. To. Xml. File (”results. xml”, True); Konstantinos Katsaros 5

Smart Pointer • NS 3 uses reference-counting smart pointers at its APIs to limit Smart Pointer • NS 3 uses reference-counting smart pointers at its APIs to limit memory leaks – Or “pass by value” or “pass by reference to const” where appropriate • A “smart pointer” behaves like a normal pointer (syntax) but does not lose memory when reference count goes to zero • Use them like built-in pointers: Ptr p = Create. Object (); p->method (); Konstantinos Katsaros 6

Packet Tags • Small chunks of information • Any number of tags can be Packet Tags • Small chunks of information • Any number of tags can be attached a packet • Tags are keyed by the a structure type itself E. g. : Ptr p; My. Tag tag; p->Add. Tag (tag); p->Peek. Tag (tag); • New tag types are defined similarly to header types • Tags can be used to: – Attach context information to a packet – Example: Net. Device attaches destination MAC address when queueing, retrieves it when dequeuing for transmission – Convey additional information across layers Konstantinos Katsaros 7

Debugging (1) • Assertions: NS_ASSERT (expression); – Aborts the program if expression evaluates to Debugging (1) • Assertions: NS_ASSERT (expression); – Aborts the program if expression evaluates to false – Includes source file name and line number • Unconditional Breakpoints: NS_BREAKPOINT (); – Forces an unconditional breakpoint, compiled in • Debug Logging (not to be confused with tracing!) – Purpose • Used to trace code execution logic • For debugging, not to extract results! – Properties • NS_LOG* macros work with C++ IO streams • E. g. : NS_LOG_UNCOND (”I have received ” << p->Get. Size () << ” bytes”); • NS_LOG macros evaluate to nothing in optimized builds • When debugging is done, logging does not get in the way of execution performance Konstantinos Katsaros 8

Debugging (2) • Logging levels: – – – – NS_LOG_ERROR (. . . ): Debugging (2) • Logging levels: – – – – NS_LOG_ERROR (. . . ): serious error messages only NS_LOG_WARN (. . . ): warning messages NS_LOG_DEBUG (. . . ): rare ad-hoc debug messages NS_LOG_INFO (. . . ): informational messages (eg. banners) NS_LOG_FUNCTION (. . . ): function tracing NS_LOG_PARAM (. . . ): parameters to functions NS_LOGIC (. . . ): control flow tracing within functions • Logging ”components” – Logging messages organized by components – Usually one component is one. cc source file – NS_LOG_COMPONENT_DEFINE ("Olsr. Agent"); • Displaying log messages. Two ways: – Programatically: • Log. Component. Enable("Olsr. Agent", LOG_LEVEL_ALL); – From the environment: • NS_LOG="Olsr. Agent". /my-program Konstantinos Katsaros 9

Visualization • Not integrated (directly) with ns-3 • Ns-3 creates “animation” file, visualizers use Visualization • Not integrated (directly) with ns-3 • Ns-3 creates “animation” file, visualizers use this as input and create the animation. – netanim, pyviz, and nam for ns-3 Konstantinos Katsaros 10

Net. Anim 3. 0 Features • Animate wired-links and wirelesslinks based simulations. • LTE-packets Net. Anim 3. 0 Features • Animate wired-links and wirelesslinks based simulations. • LTE-packets cannot be animated, but topology will be shown • Complete redesign using the QGraphics framework • Packet statistics with filter • Node position statistics with node trajectory (path of a mobile node) plotting • Improved window re-sizing and zooming http: //www. nsnam. org/wiki/index. php/Net. Anim Konstantinos Katsaros 11

Adding New Module • In order to create a new module in the NS Adding New Module • In order to create a new module in the NS 3, just run the create-module. py script that will create the basic structure of the module (examples, helper, test, model and the appropriate wscript ). • As of ns-3. 13 there is no need to add the module in ns 3 wscript, it is done automatically. Usage: . /create-module. py [options] modulename Then clean the project, configure and re-build it %. /waf distclean %. /waf configure %. /waf Konstantinos Katsaros 12

NSC • The Network Simulation Cradle (NSC) is a framework which allows real world NSC • The Network Simulation Cradle (NSC) is a framework which allows real world TCP/IP network stacks to be used inside a network simulator http: //www. nsnam. org/wiki/index. php/Network_Simulation_Cradle_Integration Konstantinos Katsaros 13

Distributed Simulation with MPI Ø MPI: Message Passing Interface Ø Library (and protocol) for Distributed Simulation with MPI Ø MPI: Message Passing Interface Ø Library (and protocol) for distributed applications Ø MPI simulator (as of ns-3. 8) Ø Nodes in the simulation assigned different System Ids Ø Nodes with different System Ids run on different cluster machines Ø Nodes on different machines may communication using p 2 p links only Node 0 System. Id 1 Node 1 System. Id 1 Node 2 System. Id 1 Node 3 System. Id 2 Point-to-point Link (simulation and real world) Konstantinos Katsaros Node 4 System. Id 2 14 Node 5 System. Id 2

Emulation • Support moving between simulation and testbeds or live systems • A real-time Emulation • Support moving between simulation and testbeds or live systems • A real-time scheduler, and support for two modes of emulation – Global. Value: : Bind (“Simulator. Implementation. Type”, String. Value (“ns 3: : Real. Time. Simulator. Impl”)); Konstantinos Katsaros 15

Acknowledgements Ø Special thanks to: ØMathieu Lacage ØTom Henderson ØGustavo Carneiro For borrowing parts Acknowledgements Ø Special thanks to: ØMathieu Lacage ØTom Henderson ØGustavo Carneiro For borrowing parts of their slides Konstantinos Katsaros 16