1 / 16

Introduction to NS-3 Part - 2

Introduction to NS-3 Part - 2. Katsaros Konstantinos PhD Student. PGSDP Workshop on NS-3 2 April 2012. Overview. FlowMonitor Smart Pointers Packet Tags Debugging Visualization Creating a new Module Advanced Simulation with NS-3 NSC (Network S imulator C radle)

prentice
Télécharger la présentation

Introduction to NS-3 Part - 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. Introduction to NS-3Part - 2 Katsaros Konstantinos PhD Student PGSDP Workshop on NS-3 2 April 2012

  2. Overview • FlowMonitor • 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) 2 Konstantinos Katsaros

  3. 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 3 Konstantinos Katsaros

  4. Flow Monitor Measurements • timeFirstTxPacket, timeLastTxPacketbegin and end times of the flow from the point of view of the receiver • timeFirstRxPacket, timeLastRxPacketbegin and end times of the flow from the point of view of the receiver • delaySum, jitterSumsum of delay and jitter values • txBytes, txPacketsnumber of transmitted bytes and packets • rxBytes, rxPacketsnumber of received bytes and packets • lostPacketsnumber of definitely lost packets • timesForwardedthe number of times a packet has been reportedly forwarded, summed for all packets in the flow • delayHistogram, jitterHistogram, packetSizeHistogramHistogram versions for the delay, jitter, and packet sizes, respectively • packetsDropped, bytesDroppeddiscriminates the losses by a reason code • DROP NO ROUTE no IPv4 route found for a packet • DROP TTL EXPIRE a packet was dropped due to an IPv4 TTL field decremented and reaching zero • DROP BAD CHECKSUM a packet had a bad IPv4 header checksum and had to be dropped 4 Konstantinos Katsaros

  5. Flow Monitor Example Create a FlowMonitorHelper object FlowMonirtorHelperflowmon; Create a pointer to FlowMonirot class and install probes to all nodes Ptr<FlowMonitor> monitor = flowmon.InstallAll(); Configure histogram parameters Monitor->SetAttribute (”DelayBinWidth”, DoubleValue(0.001)); Monitor->SetAttribute (”JitterBinWidth”,DoubleValue (0.001)); Run simulation Simulator::Run (); Write results into an XML file monitor->SerializeToXmlFile (”results.xml”,True,True); 5 Konstantinos Katsaros

  6. Smart Pointer • NS3 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<MyClass> p = CreateObject<MyClass> (); p->method (); 6 Konstantinos Katsaros

  7. 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<Packet> p; MyTag tag; p->AddTag (tag); p->PeekTag (tag); • New tag types are defined similarly to header types • Tags can be used to: • Attach context information to a packet • Example: NetDevice attaches destination MAC address when queueing, retrieves it when dequeuing for transmission • Convey additional information across layers 7 Konstantinos Katsaros

  8. 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->GetSize () << ” bytes”); • NS_LOG macros evaluate to nothing in optimized builds • When debugging is done, logging does not get in the way of execution performance 8 Konstantinos Katsaros

  9. 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_LOG_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 ("OlsrAgent"); • Displaying log messages. Two ways: • Programatically: • LogComponentEnable("OlsrAgent", LOG_LEVEL_ALL); • From the environment: • NS_LOG="OlsrAgent" ./my-program 9 Konstantinos Katsaros

  10. 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 10 Konstantinos Katsaros

  11. NetAnim 3.0 Features • Animate wired-links and wireless-links 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/NetAnim 11 Konstantinos Katsaros

  12. Adding New Module • In order to create a new module in the NS3, 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 ns3 wscript, it is done automatically. Usage: ./create-module.py [options] modulename Then clean the project, configure and re-build it %./wafdistclean %./waf configure %./waf 12 Konstantinos Katsaros

  13. 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 13 Konstantinos Katsaros

  14. 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 p2p links only Node 0 SystemId 1 Node 3 SystemId 2 Point-to-point Link (simulation and real world) Node 2 SystemId 1 Node 1 SystemId 1 Node 4 SystemId 2 Node 5 SystemId 2 14 Konstantinos Katsaros

  15. Emulation • Support moving between simulation and testbeds or live systems • A real-time scheduler, and support for two modes of emulation • GlobalValue::Bind (“SimulatorImplementationType”, StringValue(“ns3::RealTimeSimulatorImpl”)); 15 Konstantinos Katsaros

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

More Related