network protocol design and evaluation
play

Network Protocol Design and Evaluation 07 - Simulation, Part II - PowerPoint PPT Presentation

Network Protocol Design and Evaluation 07 - Simulation, Part II Stefan Rhrup University of Freiburg Computer Networks and Telematics Summer 2009 Overview In the first part of this chapter: Discrete-event simulation In this


  1. Network Protocol Design and Evaluation 07 - Simulation, Part II Stefan Rührup University of Freiburg Computer Networks and Telematics Summer 2009

  2. Overview ‣ In the first part of this chapter: • Discrete-event simulation ‣ In this part: • Network simulation • The network simulator OMNeT++ • Simulation models for wireless networks Network Protocol Design and Evaluation Computer Networks and Telematics 2 Stefan Rührup, Summer 2009 University of Freiburg

  3. OMNeT++ ‣ The simulation environment OMNeT++ • Discrete event simulator • Component-based • Provides the basic tools to write simulations - simulation kernel (event processing) - utility classes (RNG, statistics collection) • Public-source (free for academic use) ‣ OMNeT++ is a general purpose tool and not specifically designed for network simulations. Components for network simulations are provided by frameworks . Network Protocol Design and Evaluation Computer Networks and Telematics 3 Stefan Rührup, Summer 2009 University of Freiburg

  4. The User Interface OMNeT version 3 Network Protocol Design and Evaluation Computer Networks and Telematics 4 Stefan Rührup, Summer 2009 University of Freiburg

  5. Basic Principles (1) ‣ A simulation model consists of modules (Modules are communicating FSMs) ‣ Modules communicate by passing messages over connections (links) connection Module A Module B gate Network nested modules: compound module S1 S2 simple modules Network Protocol Design and Evaluation Computer Networks and Telematics 5 Stefan Rührup, Summer 2009 University of Freiburg

  6. Basic Principles (2) ‣ Modules implement application-specific behaviour ‣ Modules are C++ objects ‣ Connections are defined using the NED (network topology description) language ‣ Modules communicate by exchanging messages. The reception of a message is an event msg Module A Module B simulation kernel Network Protocol Design and Evaluation Computer Networks and Telematics 6 Stefan Rührup, Summer 2009 University of Freiburg

  7. Why do we need gates? ‣ Gates are well-defined interfaces ‣ Functionality inside the module is independent of the connections → Modules can be treated as black boxes → Modules are exchangable (e.g. layer of a protocol stack) ‣ Modules send messages to outgoing gates ‣ ...and also directly to other modules (can be useful when simulating a wireless medium where connections are created dynamically) Network Protocol Design and Evaluation Computer Networks and Telematics 7 Stefan Rührup, Summer 2009 University of Freiburg

  8. How to Write a Simulation (1) The general procedure: ‣ Implementation • Define module behaviour (event generation, event processing) • Define message format ‣ Simulation setup: • Define parameters • Define metrics to be observed during simulation Network Protocol Design and Evaluation Computer Networks and Telematics 8 Stefan Rührup, Summer 2009 University of Freiburg

  9. How to Write a Simulation (2) .ned .msg Define modules and network 1. topology (.ned) nedtool opp_msgc Define messages (.msg) 2. .cc *_n.cc *_m.cc Implement the behaviour of 3. simple modules (.cc) C++ libraries Compile the project 4. Linker .ini Define the parameters for 5. the simulation (omnetpp.ini) executable Network Protocol Design and Evaluation Computer Networks and Telematics 9 Stefan Rührup, Summer 2009 University of Freiburg

  10. Step 1. Defining Modules ‣ Modules are defined using the NED language (OMNeT specific) ‣ GNED - a graphical editor for NED files ‣ Understanding the NED language is not that difficult... Network Protocol Design and Evaluation Computer Networks and Telematics 10 Stefan Rührup, Summer 2009 University of Freiburg

  11. Step 1. Defining Modules (2) Example: Node module Node address parameters: address : numeric; gates: in: in[]; app out: out[]; in out submodules: app: App; routing: Routing; localIn localOut gatesizes: in[sizeof(in)], routing out[sizeof(out)]; connections: in 0 out 0 in n out n ... routing.localOut --> app.in; routing.localIn <-- app.out; in 0 out 0 in n out n for i=0..sizeof(in)-1 do ... routing.out[i] --> out[i]; routing.in[i] <-- in[i]; endfor; endmodule (see ../samples/routing) Network Protocol Design and Evaluation Computer Networks and Telematics 11 Stefan Rührup, Summer 2009 University of Freiburg

  12. Step 1. Defining a Network Compound module containing the nodes: import "node"; module Net60 submodules: rte: Node[57]; parameters: address = index; connections nocheck: rte[0].out++ --> rte[1].in++; rte[0].in++ <-- rte[1].out++; ... ... rte[0].out++ --> rte[1].in++; rte[0].in++ <-- rte[1].out++; endmodule Network definition: network net60 : Net60 endnetwork Network Protocol Design and Evaluation Computer Networks and Telematics 12 Stefan Rührup, Summer 2009 University of Freiburg

  13. Step 2. Defining a Network (2) ‣ nedtool creates C++ classes (if not loaded dynamically) node.ned node_n.cc nedtool module Node [...] parameters: ModuleInterface(Node) address : numeric; // parameters: gates: Parameter(address, ParType_Numeric) in: in[]; // gates: out: out[]; Gate(in[], GateDir_Input) submodules: Gate(out[], GateDir_Output) app: App; EndInterface routing: Routing; gatesizes: Register_ModuleInterface(Node); in[sizeof(in)], class Node : public cCompoundModule out[sizeof(out)]; { connections: public: routing.localOut --> app.in; Node() : cCompoundModule() {} routing.localIn <-- app.out; protected: for i=0..sizeof(in)-1 do virtual void doBuildInside(); routing.out[i] --> out[i]; }; routing.in[i] <-- in[i]; endfor; Define_Module(Node); endmodule [...] Network Protocol Design and Evaluation Computer Networks and Telematics 13 Stefan Rührup, Summer 2009 University of Freiburg

  14. Step 2. Defining Messages ‣ Messages are C++ classes and either of class cMessage or derived from this class ‣ Messages are handled in a module by the method handleMessage(cMessage *msg) ‣ Messages are sent to other modules by the method send(cMessage *msg, const char *outGateName) ‣ Timers are also realized by messages (self-messages) ‣ Messages can be defined in a MSG file. Example: message Packet { fields: int srcAddr; int destAddr; int hopCount; } Network Protocol Design and Evaluation Computer Networks and Telematics 14 Stefan Rührup, Summer 2009 University of Freiburg

  15. Step 2. Defining Messages (2) ‣ Define the fields in a .mgs file and let opp_msgc do the rest: packet.msg packet_m.h class Packet : public cMessage message Packet { { protected: fields: int srcAddr_var; int srcAddr; int destAddr_var; msgc int destAddr; int hopCount_var; int hopCount; public: } Packet(const char *name=NULL, int kind=0); Packet(const Packet& other); virtual ~Packet(); Packet& operator=(const Packet& other); virtual cPolymorphic *dup() const { return new Packet(*this);} virtual void netPack(cCommBuffer *b); virtual void netUnpack(cCommBuffer *b); virtual int getSrcAddr() const; virtual void setSrcAddr(int srcAddr_var); getter and setter methods virtual int getDestAddr() const; are automatically generated virtual void setDestAddr(int destAddr_var); virtual int getHopCount() const; virtual void setHopCount(int hopCount_var); }; Network Protocol Design and Evaluation Computer Networks and Telematics 15 Stefan Rührup, Summer 2009 University of Freiburg

  16. Step 3. Module Implementation ‣ Derive a class from cSimpleModule #include <omnetpp.h> #include "packet_m.h” ← include msg definitions class Routing : public cSimpleModule { [...] } Define_Module(Routing); ← register the module class ‣ Redefine the methods (virtual methods of cModule) initialize() e.g., to define state variables • • handleMessage(cMessage *msg) finish() e.g., for statistics collection • Network Protocol Design and Evaluation Computer Networks and Telematics 16 Stefan Rührup, Summer 2009 University of Freiburg

  17. Step 3. Event Handling ‣ Events are generated by sending messages from one module to other modules oder to itself ‣ Event handling is performed by handleMessage(cMessage *msg) ‣ Message processing depends on the state of a module, but also changes the state ‣ State variables are members of the module class ‣ Message sending (event generation) methods: - send(cMessage* msg, int gateid) - scheduleAt(simtime_t t, cMessage* msg) - cancelEvent(cMessage* msg) Network Protocol Design and Evaluation Computer Networks and Telematics 17 Stefan Rührup, Summer 2009 University of Freiburg

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend