ns-3 training Tom Henderson ns-3 annual meeting 2019

Slides:



Advertisements
Similar presentations
Introduction to NS-3 Part - 2 Katsaros Konstantinos PhD Student PGSDP Workshop on NS-3 2 April 2012.
Advertisements

FIT FIT1002 Computer Programming Unit 19 Testing and Debugging.
Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff.
Copyright node This presentation is a subset of the one presented by:
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Purpose  This training course describes how to configure the the C/C++ compiler options.
University of Maryland parseThat: A Robust Arbitrary-Binary Tester for Dyninst Ray Chen.
Introduction to NS2 -Network Simulator- -Prepared by Changyong Jung.
The Pipeline Processing Framework LSST Applications Meeting IPAC Feb. 19, 2008 Raymond Plante National Center for Supercomputing Applications.
Ns-3 Training Computer and Communication Network Lab Department of Electrical Engineering National Sun Yat-Sen University 5/13/2013.
Programming Tools gcc make utility Open Source code Static and Shared Libraries gdb Memory debugging tools.
1 Conditions Logical Expressions Selection Control Structures Chapter 5.
Ns-3 tutorial Katto lab Tadashi Yamazaki 8 November 2012.
Editing & Compiling: UNIX vs. IDE and an Intro to Architecture.
Replay Compilation: Improving Debuggability of a Just-in Time Complier Presenter: Jun Tao.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 11 – gdb and Debugging.
Nachos Overview Lecturer: Hao-Hua Chu TA: Chun-Po Wang (Artoo) Date: 2008/09/18 Material Provided by Yuan-Hao Chang, Yung-Feng Lu.
STL CSSE 250 Susan Reeder. What is the STL? Standard Template Library Standard C++ Library is an extensible framework which contains components for Language.
Chapter – 8 Software Tools.
1 Building a program in C: Preprocessor, Compilation and Linkage.
Institute of Radio Physics and Electronics ILug-Cal Introduction to GDB Institute of Radio Physics and Electronics and Indian GNU/Linux Users Group Kolkata.
Gnu Debugger (gdb) Debuggers are used to: Find semantic errors Locate seg faults and bus errors Prepared by Dr. Spiegel.
File System Implementation
DEBUG.
Scan, Import, and Automatically file documents to Box Introduction
ns-3 Training 5/08/2017 Computer and Communication Network Lab
NETSTORM.
Class Invariants Class invariants are logical conditions to ensure the correct working of a class. Class invariants must hold true when an object is created,
Testing Tutorial 7.
Chapter 6 CS 3370 – C++ Functions.
Dept of Computer Science University of Maryland College Park
Key Ideas from day 1 slides
CSE 374 Programming Concepts & Tools
CS1101X Programming Methodology
Cross Platform Development using Software Matrix
INTRODUCING Adams/CHASSIS
PVS-Studio static analyzer: advanced features
Debugging with gdb gdb is the GNU debugger on our CS machines.
Ns-3 Training Session 2: Monday May 11 ns-3 Annual meeting May 2015.
OpenStorage API part II
Chapter 1-4 CSc 212 Data Structures, Sec AB CCNY, Spring 2012
C Basics.
gdb gdb is the GNU debugger on our CS machines.
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
Course Name: QTP Trainer: Laxmi Duration: 25 Hrs Session: Daily 1 Hr.
Session 4. 어플리케이션 및 헤더 만들기 변성호, 이규진
Many-core Software Development Platforms
A tutorial on the implementation of TCP in ns-3
Design and Programming
Using Visual Studio and VS Code for Embedded C/C++ Development
10.2 const (Constant) Objects and const Member Functions
C Preprocessor(CPP).
ns-3 Waf build system ns-3 Annual Meeting June 2017
Ns-3 Training Session 4: Monday 3:30pm ns-3 Annual Meeting May 2014.
Protocols 1 Key Revision Points.
Ns-3 Training ns-3 training, June 2017.
ECE 103 Engineering Programming Chapter 56 Runtime Errors
Homework Reading Programming Assignments Finish K&R Chapter 1
Ns-3 Tutorial Xin Li.
Ns-3 Training ns-3 training, June 2018.
Ns-3 Training: Packets ns-3 Annual meeting June 2016.
Outline System architecture Current work Experiments Next Steps
Ns-3 Training Debugging support ns-3 training, June 2016.
Makefiles, GDB, Valgrind
Ns-3 Training ns-3 Objects ns-3 training, June 2016.
Dynamic Binary Translators and Instrumenters
In Today’s Class.. General Kernel Responsibilities Kernel Organization
SPL – PS1 Introduction to C++.
Chapter 1-4 CSc 212 Data Structures, Sec FG CCNY, 2009
Introduction to Operating Systems
Presentation transcript:

ns-3 training Tom Henderson ns-3 annual meeting 2019 June 17-21, Florence, Italy

ns-3 Annual meeting June 2019 ns-3 Packet Packet is an advanced data structure with the following capabilities Supports fragmentation and reassembly Supports real or virtual application data Extensible Serializable (for emulation) Supports pretty-printing Efficient (copy-on-write semantics) ns-3 Annual meeting June 2019

ns-3 Annual meeting June 2019 ns-3 Packet structure Analogous to an mbuf/skbuff ns-3 Annual meeting June 2019

ns-3 Annual meeting June 2019 Copy-on-write Copy data bytes only as needed Figure source: Mathieu Lacage's Ph.D. thesis ns-3 Annual meeting June 2019

ns-3 Annual meeting June 2019 Headers and trailers Most operations on packet involve adding and removing an ns3::Header class ns3::Header must implement four methods: Serialize() Deserialize() GetSerializedSize() Print() ns-3 Annual meeting June 2019

Headers and trailers (cont.) Headers are serialized into the packet byte buffer with Packet::AddHeader() and removed with Packet::RemoveHeader() Headers can also be 'Peeked' without removal Ptr<Packet> pkt = Create<Packet> (); UdpHeader hdr; // Note: not heap allocated pkt->AddHeader (hdr); Ipv4Header iphdr; pkt->AddHeader (iphdr); ns-3 Annual meeting June 2019

ns-3 Annual meeting June 2019 Packet tags Packet tag objects allow packets to carry around simulator-specific metadata Such as a "unique ID" for packets or cross-layer info Tags may associate with byte ranges of data, or with the whole packet Distinction is important when packets are fragmented and reassembled Tags presently are not preserved across serialization boundaries (e.g. MPI) ns-3 Annual meeting June 2019

ns-3 Annual meeting June 2019 PacketTag vs. ByteTag Two tag types are available: PacketTag and ByteTag ByteTags run with bytes PacketTags run with packets When Packet is fragmented, both copies of Packet get copies of PacketTags When two Packets are merged, only the PacketTags of the first are preserved PacketTags may be removed individually; ByteTags may be removed all at once ns-3 Annual meeting June 2019

ns-3 Annual meeting June 2019 Tag example Here is a simple example illustrating the use of tags from the code in src/internet/model/udp-socket-impl.cc: Ptr<Packet> p; // pointer to a pre-existing packet SocketIpTtlTag tag tag.SetTtl (m_ipMulticastTtl); // Convey the TTL from UDP layer to IP layer p->AddPacketTag (tag); This tag is read at the IP layer, then stripped (src/internet/model/ipv4-l3-protocol.cc): uint8_t ttl = m_defaultTtl; SocketIpTtlTag tag; bool found = packet->RemovePacketTag (tag); if (found) { ttl = tag.GetTtl (); } ns-3 Annual meeting June 2019

ns-3 Annual meeting June 2019 Packet metadata Packets may optionally carry metadata record every operation on a packet's buffer implementation of Packet::Print for pretty-printing of the packet sanity check that when a Header is removed, the Header was actually present to begin with Not enabled by default, for performance reasons To enable, insert one or both statements: Packet::EnablePrinting (); Packet::EnableChecking (); ns-3 Annual meeting June 2019

ns-3 Annual meeting June 2019 Ptr<Packet> Packets are reference counted objects that support the smart pointer class Ptr Use a templated "Create" method instead of CreateObject for ns3::Objects Typical creation: Ptr<Packet> pkt = Create<Packet> (); In model code, Packet pointers may be const or non-const; often Packet::Copy() is used to obtain non-const from const Ptr<const Packet> cpkt = ...; Ptr<Packet> p = cpkt->Copy (); ns-3 Annual meeting June 2019

Queues in ns-3 Queues are objects for storing packets A templated Queue class exists to support a few use cases simple queues such as a DropTail WifiMacQueue a Linux-like QueueDisc class Enqueue Dequeue Common operations: GetNBytes (); GetNPackets (); etc. ns-3 training, June 2019

Linux-like TC architecture in ns-3 Figure source: Stefano Avallone (2017 training) ns-3 training, June 2019

Debugging support 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 ns-3 training, June 2019

Debugging support (cont.) 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 ns-3 training, June 2019

Running C++ programs through gdb The gdb debugger can be used directly on binaries in the build directory An easier way is to use a waf shortcut ./waf --command-template="gdb %s" --run <program- name> ns-3 training, June 2019

Running C++ programs through valgrind valgrind memcheck can be used directly on binaries in the build directory An easier way is to use a waf shortcut ./waf --command-template="valgrind %s" --run <program-name> Note: disable GTK at configure time when running valgrind (to suppress spurious reports) ./waf configure --disable-gtk --enable-tests ... ns-3 training, June 2019

Testing ns-3 models need tests verifiable by others (often overlooked) Onus is on the simulation project to validate and document results Onus is also on the researcher to verify results ns-3 strategies: regression tests Aim for event-based rather than trace-based unit tests for verification validation of models on testbeds where possible reuse of code ns-3 training, June 2019

Test framework ns-3-dev is checked nightly on multiple platforms Linux gcc-4.x, i386 and x86_64, OS X, FreeBSD clang, and Cygwin (occasionally) ./test.py will run regression tests Walk through test code, test terminology (suite, case), and examples of how tests are run ns-3 training, June 2019

Improving performance Debug vs optimized builds ./waf -d debug configure ./waf -d debug optimized Build ns-3 with static libraries ./waf --enable-static Use different compilers (icc) has been done in past, not regularly tested ns-3 training, June 2019