Introduction to Omnet++ By: Mahsa Soheil Shamaee.

Slides:



Advertisements
Similar presentations
Network II.5 simulator ..
Advertisements

How to use TinyOS Jason Hill Rob Szewczyk Alec Woo David Culler An event based execution environment for Networked Sensors.
Lectures on File Management
Introduction 1.  A Simulator  Modular (Component-based)  Open-architecture  For Discrete Event Networks.
Chapter 7 Introduction to Procedures. So far, all programs written in such way that all subtasks are integrated in one single large program. There is.
Introduction to OMNeT++
Introduction to Flowcharting
Introduction to Flowcharting
Answers of Exercise 7 1. Explain what are the connection-oriented communication and the connectionless communication. Give some examples for each of the.
MANETs Routing Dr. Raad S. Al-Qassas Department of Computer Science PSUT
Mobile and Wireless Computing Institute for Computer Science, University of Freiburg Western Australian Interactive Virtual Environments Centre (IVEC)
1 Complexity of Network Synchronization Raeda Naamnieh.
IS 1181 IS 118 Introduction to Development Tools VB Chapter 06.
EEC-484/584 Computer Networks Lecture 10 Wenbing Zhao (Part of the slides are based on Drs. Kurose & Ross ’ s slides for their Computer.
Performance Analysis and Monitoring Facilities in CPN Tools Tutorial CPN’05 October 25, 2005 Lisa Wells.
V0.01 © 2009 Research In Motion Limited Introduction to Java Application Development for the BlackBerry Smartphone Trainer name Date.
SUNY Morrisville-Norwich Campus-Week 12 CITA 130 Advanced Computer Applications II Spring 2005 Prof. Tom Smith.
WSN Simulation Template for OMNeT++
Introduction. 2 What Is SmartFlow? SmartFlow is the first application to test QoS and analyze the performance and behavior of the new breed of policy-based.
CS 1400 Chap 6 Functions. Library routines are functions! root = sqrt (a); power = pow (b, c); function name argument arguments.
C++ fundamentals.
DEMONSTRATION FOR SIGMA DATA ACQUISITION MODULES Tempatron Ltd Data Measurements Division Darwin Close Reading RG2 0TB UK T : +44 (0) F :
OMNET++. Outline Introduction Overview The NED Language Simple Modules.
TCP/IP Protocol Suite 1 Chapter 9 Upon completion you will be able to: Internet Control Message Protocol Be familiar with the ICMP message format Know.
TCP/IP Protocol Suite 1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 9 Internet Control Message.
Lesson 5 – Looking at the Output MATSim Tutorial, 2011, Shanghai 1.
Working with cursors in Python GISDE Python Workshop Qiao Li.
Modular Programming Chapter Value and Reference Parameters t Function declaration: void computesumave(float num1, float num2, float& sum, float&
Designing a Discrete Event Simulation Tool Peter L. Jackson School of Operations Research and Industrial Engineering March 15, 2003 Cornell University.
Modular Programming Chapter Value and Reference Parameters computeSumAve (x, y, sum, mean) ACTUALFORMAL xnum1(input) ynum2(input) sumsum(output)
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. C How To Program - 4th edition Deitels Class 05 University.
1 CMPT 471 Networking II IGMP (IPv4) and MLD (IPv6) © Janice Regan,
Application of Data Programming Blocks. Objectives  Understand the use of data programming blocks and their applications  Understand the basic logic.
1 Internet Control Message Protocol (ICMP) Used to send error and control messages. It is a necessary part of the TCP/IP suite. It is above the IP module.
Pointers OVERVIEW.
Operating Systems Lecture November 2015© Copyright Virtual University of Pakistan 2 Agenda for Today Review of previous lecture Hardware (I/O, memory,
Fall 2004EE 3563 Digital Systems Design EE 3563 VHDL – Basic Language Elements  Identifiers: –basic identifier: composed of a sequence of one or more.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
1 Getting Started Exercise Part 1. 2 Profiles related to the exercise When starting use archive profile: GettingStarted_Start.zip The fully completed.
Cosc175/module.ppt1 Introduction to Modularity Function/procedures void/value-returning Arguments/parameters Formal arguments/actual arguments Pass by.
—————————— CACI Products Company - ——————————————————— COMNET III —————————————— 1-1 Day 1 - COMNET Program Operation, Network Topology.
Functions Structured Programming. Topics to be covered Introduction to Functions Defining a function Calling a function Arguments, local variables and.
RIP Routing Protocol. 2 Routing Recall: There are two parts to routing IP packets: 1. How to pass a packet from an input interface to the output interface.
Spring Routing: Part I Section 4.2 Outline Algorithms Scalability.
Aggregator  Performs aggregate calculations  Components of the Aggregator Transformation Aggregate expression Group by port Sorted Input option Aggregate.
CS 6401 Intra-domain Routing Outline Introduction to Routing Distance Vector Algorithm.
1 An SDL Tutorial Two primary elements: –Structure –Identifies the various components of the system, and the communication paths among them. –Components:
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Loop Design What goes into coding a loop. Considerations for Loop Design ● There are basically two kinds of loops: ● Those that form some accumulated.
Introduction to Omnet++ By: Mahsa Soheil Shamaee.
SECTION 6 DESIGN STUDY. What’s in this section: –Design Variables –Design Studies Overview –Specifying an Objective –Execution Display Settings –Output.
Control Flow Testing Handouts
21-2 ICMP(Internet control message protocol)
Chapter 3: Using Methods, Classes, and Objects
Outline of the Chapter Basic Idea Outline of Control Flow Testing
Topics Introduction to File Input and Output
Internet Control Message Protocol Version 4 (ICMPv4)
Programming Logic and Design Fourth Edition, Comprehensive
Intradomain Routing Outline Introduction to Routing
Modelling and Simulation
Introduction to OMNeT++
Internet Control Message Protocol
Operating Systems Lecture 3.
Spreadsheets, Modelling & Databases
Topics Introduction to File Input and Output
TCP/IP Protocol Suite 1 Chapter 9 Upon completion you will be able to: Internet Control Message Protocol Be familiar with the ICMP message format Know.
Modeling and simulation [NETW707] Tutorial5 – Introduction to Omnet++
Presentation transcript:

Introduction to Omnet++ By: Mahsa Soheil Shamaee

TicToc Tutorial for OMNeT++ Step 15: Adding statistics collection The OMNeT++ simulation kernel can record a detailed log about your message exchanges automatically by setting the [Config Tictoc15] network = Tictoc15 record-eventlog = true The previous simulation model does something interesting enough so that we can collect some statistics For example, you may be interested in the average hop count a message has to travel before reaching its destination We'll record in the hop count of every message upon arrival into an output vector (a sequence of (time,value) pairs, sort of a time series) We also calculate mean, standard deviation, minimum, maximum values per node, and write them into a file at the end of the simulation Then we'll use tools from the OMNeT++ IDE to analyse the output files For that, we add an output vector object (which will record the data into Tictoc15-0.vec) and a histogram object (which also calculates mean, etc) to the class

TicToc Tutorial for OMNeT++ message TicTocMsg15 { int source; int destination; int hopCount = 0;} simple Txc15{ gates: inout gate[];} network Tictoc15 { types: channel Channel extends ned.DelayChannel { delay = 100ms; } submodules: tic[6]: Txc15; connections: tic[0].gate++ Channel tic[1].gate++; tic[1].gate++ Channel tic[2].gate++; tic[1].gate++ Channel tic[4].gate++; tic[3].gate++ Channel tic[4].gate++; tic[4].gate++ Channel tic[5].gate++;} class Txc15 : public cSimpleModule { private: long numSent; long numReceived; cLongHistogram hopCountStats; cOutVector hopCountVector; protected: virtual TicTocMsg15 *generateMessage(); virtual void forwardMessage(TicTocMsg15 *msg); virtual void initialize(); virtual void handleMessage(cMessage *msg); // The finish() function is called by OMNeT++ at the end of the simulation: virtual void finish(); };

TicToc Tutorial for OMNeT++ Define_Module(Txc15); void Txc15::initialize() { // Initialize variables numSent = 0; numReceived = 0; WATCH(numSent); WATCH(numReceived); hopCountStats.setName("hopCountStats"); hopCountStats.setRangeAutoUpper(0, 10, 1.5); hopCountVector.setName("HopCount"); // Module 0 sends the first message if (getIndex()==0) { // Boot the process scheduling the initial message as a self-message. TicTocMsg15 *msg = generateMessage(); scheduleAt(0.0, msg); } void Txc15::handleMessage(cMessage *msg) { TicTocMsg15 *ttmsg = check_and_cast (msg); if (ttmsg->getDestination()==getIndex()) { // Message arrived int hopcount = ttmsg->getHopCount(); EV << "Message " << ttmsg << " arrived after " << hopcount << " hops.\n"; bubble("ARRIVED, starting new one!"); // update statistics. numReceived++; hopCountVector.record(hopcount); hopCountStats.collect(hopcount); delete ttmsg;. }

TicToc Tutorial for OMNeT++ void Txc15::finish() { // This function is called by OMNeT++ at the end of the simulation. EV << "Sent: " << numSent << endl; EV << "Received: " << numReceived << endl; EV << "Hop count, min: " << hopCountStats.getMin() << endl; EV << "Hop count, max: " << hopCountStats.getMax() << endl; EV << "Hop count, mean: " << hopCountStats.getMean() << endl; EV << "Hop count, stddev: " << hopCountStats.getStddev() << endl; recordScalar("#sent", numSent); recordScalar("#received", numReceived); hopCountStats.recordAs("hop count"); } hopCountVector.record() call writes the data into Tictoc15-0.vec With a large simulation model or long execution time, the Tictoc15-0.vec file may grow very large To handle this situation, you can specifically disable/enable vector in omnetpp.ini, and you can also specify a simulation time interval in which you're interested (data recorded outside this interval will be discarded) When you begin a new simulation, the existing Tictoc15- 0.vec/sca file gets deleted Scalar data (collected by the histogram object in this simulation) have to be recorded manually, in the finish() function finish() gets invoked on successful completion of the simulation, i.e. not when it's stopped with an error The recordScalar() calls in the code below write into the Tictoc15-0.sca file The files are stored in the results/ subdirectory.

TicToc Tutorial for OMNeT++. Step 16: Statistic collection without modifying your model In the previous step we have added statistic collection to our model While we can compute and save any value we wish, usually it is not known at the time of writing the model, what data the enduser will need OMNeT provides an additional mechanism to record values and events Any model can emit 'signals' that can carry a value or an object The model writer just have to decide what signals to emit, what data to attach to them and when to emit them The enduser can attach 'listeners' to these signals that can process or record these data items This way the model code does not have to contain any code that is specific to the statistics collection and the enduser can freely add additional statistics without even looking into the C++ code We will re-write the statistic collection introduced in the last step to use signals First of all, we can safely remove all statistic related variables from our module. There is no need for the cOutVector and cLongHistogram classes eithercOutVectorcLongHistogram We will need only a single signal that carries the hopCount of the message at the time of message arrival at the destination First we need to define our signal. The arrivalSignal is just an identifier that can be used later to easily refer to our signal

TicToc Tutorial for OMNeT++. class Txc16 : public cSimpleModule { private: simsignal_t arrivalSignal; protected: virtual TicTocMsg16 *generateMessage(); virtual void forwardMessage(TicTocMsg16 *msg); virtual void initialize(); virtual void handleMessage(cMessage *msg); }; Define_Module(Txc16); void Txc16::initialize() { arrivalSignal = registerSignal("arrival"); // Module 0 sends the first message if (getIndex()==0) { // Boot the process scheduling the initial message as a self-message. TicTocMsg16 *msg = generateMessage(); scheduleAt(0.0, msg); } We must register all signals before using them The best place to do this is the initialize() method of the module void Txc16::handleMessage(cMessage *msg) { TicTocMsg16 *ttmsg = check_and_cast (msg); if (ttmsg->getDestination()==getIndex()) { // Message arrived int hopcount = ttmsg->getHopCount(); // send a signal emit(arrivalSignal, hopcount); EV << "Message " << ttmsg << " arrived after " << hopcount << " hops.\n"; bubble("ARRIVED, starting new one!"); delete ttmsg; Now we can emit our signal, when the message has arrived to the destination node As we do not have to save or store anything manually, the finish() method can be deleted. We no longer need it

TicToc Tutorial for OMNeT++. simple Txc16 count"; source="arrival"; record=vector,stats; gates: inout gate[]; } network Tictoc16 { types: channel Channel extends ned.DelayChannel { delay = 100ms; } submodules: tic[6]: Txc16; connections: tic[0].gate++ Channel tic[1].gate++; tic[1].gate++ Channel tic[2].gate++; tic[1].gate++ Channel tic[4].gate++; tic[3].gate++ Channel tic[4].gate++; tic[4].gate++ Channel tic[5].gate++; } Define the emitted signal also in the NED file Declaring signals in the NED file allows you to have all information about your module in one place You will see the parameters it takes, its input and output gates, and also the signals and statistics it provides