Download presentation
Presentation is loading. Please wait.
Published byJasmine Clementine Snow Modified over 9 years ago
1
OMNET++
2
Outline Introduction Overview The NED Language Simple Modules
3
What Is OMNeT++? Object-oriented modular discrete event network simulation framework modeling of wired and wireless communication networks protocol modeling modeling of queueing networks modeling of multiprocessors and other distributed hardware systems validating of hardware architectures evaluating performance aspects of complex software systems
4
What Is OMNeT++? Object-oriented modular discrete event network simulation framework Components (modules) are programmed in C++ Assembled into larger components and models using a high-level language (NED)
5
Modeling Concepts Connection Spanning hierarchy levels are not permitted Propagation delay, data rate and bit error rate, can be assigned Gates Input and output interfaces
6
Main features Hierarchical Modules Top level module is the system module Depth of module nesting is unlimited Model structure is described in OMNeT++'s NED language User implements the simple modules in C++, using the OMNeT++ simulation class library Module Types Both simple and compound modules are instances of module types
7
Main features Messages Modules communicate by exchanging messages Frames or packets in a computer network Jobs or customers in a queuing network Gates Input and output interfaces of modules messages are sent out through output gates and arrive through input gates Links (connection) Created within a single level of the module hierarchy
8
Main features Modeling of Packet Transmissions Data rate, propagation delay, bit error rate and packet error rate Parameters Can be assigned in either the NED files or the configuration file omnetpp.ini Used to customize simple module behavior, and to parameterize the model topology Topology Description Method User defines the structure of the model in NED language descriptions
9
The NED Language A communication network
10
Defines a network //Net6.ned network Network { submodules: node1: Node; node2: Node; node3: Node;... connections: node1.port++ {datarate=100Mbps;} node2.port++; node2.port++ {datarate=100Mbps;} node4.port++; node4.port++ {datarate=100Mbps;} node6.port++;... } //omnetpp.ini [General] network = Network new gate
11
Introducing a Channel network Network { types: channel C extends ned.DatarateChannel { datarate = 100Mbps; } submodules: node1: Node; node2: Node; node3: Node;... connections: node1.port++ C node2.port++; node2.port++ C node4.port++; node4.port++ C node6.port++;... }
12
The App, Routing, and Queue Simple Modules simple App { parameters: int destAddress;... @display("i=block/browser"); gates: input in; output out; } simple Routing {... } simple Queue {... } sending and receiving application packets App.ned, Routing.ned and Queue.ned
13
The Node Compound Module module Node { parameters: int address; @display("i=misc/node_vs,gold"); gates: inout port[]; submodules: app: App; routing: Routing; queue[sizeof(port)]: Queue; connections: routing.localOut --> app.in; routing.localIn <-- app.out; for i=0..sizeof(port)-1 { routing.out[i] --> queue[i].in; routing.in[i] <-- queue[i].out; queue[i].line port[i]; } size will be determined implicitly by the number of neighbours bidirectional connections
14
Simple Modules Simple modules are programmed in C++, using the OMNeT++ class library Discrete Event Simulation start of a packet transmission end of a packet transmission expiry of a retransmission timeout initialize -- this includes building the model and inserting initial events to FES(Future Event Set) while (FES not empty and simulation not yet complete) { retrieve first event from FES t:= timestamp of this event process event (processing may insert new events in FES or delete existing ones) } finish simulation (write statistical results, etc.)
15
Components, Simple Modules, Channels
16
Defining Simple Module Types // file: HelloModule.cc #include class HelloModule : public cSimpleModule { protected: virtual void initialize(); virtual void handleMessage(cMessage *msg); }; // register module class with `\opp` Define_Module(HelloModule); void HelloModule::initialize() { ev << "Hello World!\n"; } void HelloModule::handleMessage(cMessage *msg) { delete msg; // just discard everything we receive } called for every message that arrives at the module // file: HelloModule.ned simple HelloModule { gates: input in; }
17
handleMessage() send() family of functions to send messages to other modules scheduleAt() to schedule an event (the module “sends a message to itself”) cancelEvent() to delete an event scheduled with scheduleAt() Cannot use the receive() and wait() functions
18
Protocol Models class FooProtocol : public cSimpleModule { protected: // state variables //... virtual void processMsgFromHigherLayer(cMessage *packet); virtual void processMsgFromLowerLayer(FooPacket *packet); virtual void processTimer(cMessage *timer); virtual void initialize(); virtual void handleMessage(cMessage *msg); }; //... void FooProtocol::handleMessage(cMessage *msg) { if (msg->isSelfMessage()) processTimer(msg); else if (msg->arrivedOn("fromNetw")) processMsgFromLowerLayer(check_and_cast (msg)); else processMsgFromHigherLayer(msg); }
19
activity() receive() to receive messages (events) wait() to suspend execution for some time (model time) send() family of functions to send messages to other modules scheduleAt() to schedule an event (the module “sends a message to itself”) cancelEvent() to delete an event scheduled with scheduleAt() end() to finish execution of this module (same as exiting the activity() function)
20
activity() void Sink::activity() { while(true) { msg = receive(); delete msg; }
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.