Home
Introduction to Network Simulation Using OMNeT++ Contents 1
Contents
1. fi N 5 We now create the Makefile which will help us to compile and link our program to create the executable tictoc opp_makemake This command should have now created a Makefile in the working directory tictoc 6 Add dependencies to the Makefile make depend ignore the generated errors 7 Let s now compile and link our very first simulation by issuing the make com mand make If there are compilation errors you need to rectify those and repeat the make until you get an error free compilation and linking 8 Once you complete the above steps you launch the simulation by issuing this command tictoc and hopefully you should now get the OMNeT simulation window similar to the one shown in Figure 1 9 Press the run button to start the simulation What you should see is that tic and toc are exchanging messages with each other This is the result of the send and receive calls in the C code The main window behind displays text messages generated via the ev lt lt lines from these modules Observe that the messages Hello World I m tic tictoc tex v1 2 4 Introduction to Network Simulation Using OMNeT Shell No 4 Konsole Fi Live msgs 2 Ev simsec n a Setting up Tkeny Tk based Loading bitmaps from b bluebox cloud cloud_s cog ink bwsink_s bwxcon_s bwxe Loading plugins no tcl file in home ahme no so file in
2. 11 tic TXc 12 display p 42 188 b 40 24 13 toc Txc 14 display p 218 188 b 40 24 15 connections 16 tic out gt toc in 17 tic in lt toc out 18 endmodule 19 20 network tictoc Tictoc 21 endnetwork 22 In this file we define a network called tictoc which consists of a compound mod ule Tictoc The compound module in turn consists of submodules tic and toc tic and toc are instances of the same simple module type called Txc Txc has one input gate named in and one output gate named out We connect tic s output gate to toc s input gate and vice versa 3 We now need to implement the functionality of the simple module Txc This is achieved by writing two C files txc h and txc cc Id txc h v 1 3 2003 12 01 02 26 29 ahmet Exp include omnetpp h Derive the Txc class cSimpleModule class Txc public cSimpleModule This is a macro it expands to constructor definition etc 16384 is the size for the coroutine stack in bytes OC OND TF WN Re It would be a good idea to adopt C like naming conventions type names with uppercase variables with lowercase and begin the submodule names with lowercase i e tic and toc tictoc tex v1 2 2 Introduction to Network Simulation Using OMNeT 10 Module_Class_Members Txc cSimpleModule 16384 11 12 This redefined virtual function holds the algorithm 13 virtual void activity 14 1 Id txc cc v 1
3. home ahmet omg ba calibrated 7730 D new A sosin E shen Cay Figure 1 tictoc simulation and Hello World I m toc are only printed once at the beginning of the sim ulation The main window toolbar displays the simulated time This is virtual time it has nothing to do with the actual or wall clock time that the program takes to execute Actually how many seconds you can simulate in one real world second depends highly on the speed of your hardware and even more on the nature and complexity of the simulation model itself Exercise 2 will emphasize this issue Note that the toolbar also contains a simsec sec gauge which displays you this value 10 In real life communication systems the links carrying the packets do not transmit a packet from one end to the other instantaneously Instead the packets experi ence propagation delays Let s now improve our model by introducing a more realistic link which will delay the messages 0 5 sec in both directions a Edit the tictoc ned to insert the following lines after line 7 channel TicTocLink delay 0 5 sec endchannel b Then modify the lines 16 and 17 of tictoc ned as follows tictoc tex v1 2 5 Introduction to Network Simulation Using OMNeT 11 tic out gt TicTocLink gt toc in tic in lt TicTocLink lt toc out We now have a link connecting modules tic and toc involving a 0 5 seconds prop agation delay
4. 4 2003 12 01 02 26 29 ahmet Exp 2 3 include lt stdio h gt 4 include lt string h gt 5 include omnetpp h 6 include txc h 7 8 register player module types 9 Define_Module Txc 10 11 void Txc activity 12 4 13 ev lt lt Hello World I m lt lt name lt lt n 14 15 Am I Tic or Toc 16 if strcmp tic name 0 17 18 Tic sends initial message and then waits for Toc s response 19 Toc starts waiting for Tic s message straightaway 20 cMessage msg new cMessage name 21 ev lt lt name lt lt sending ist msg lt lt msg gt name lt lt n 22 send msg out 23 24 25 Infinite loop to process events 26 for 27 28 cMessage msgin receive 29 ev lt lt name lt lt got msg lt lt msgin gt name lt lt n 30 delete msgin 31 wait 1 0 32 cMessage msg new cMessage name 33 ev lt lt name lt lt sending msg lt lt msg gt name lt lt n 34 send msg out 35 36 tictoc tex v1 2 Introduction to Network Simulation Using OMNeT 4 Then we need to write the file omnetpp ini which will tell the simulation tool what to do Id tictoc omnetpp ini v 1 2 2003 12 01 02 07 02 ahmet Exp ahmet General ini warnings no network tictoc Cmdenv module messages yes verbose simulation no OC OAND TF WN RH m m e Tkenv default run 1
5. Introduction to Network Simulation Using OMNeT Introduction to Network Simulation Using OMNeT Ahmet Sekercioglu Contents 1 Introduction 1 1 1 Prerequisites s a a Tata eat Ha ae las Ee Aas ie SS 1 2 Discrete Event Simulation with OMNeT 1 3 Exercises 6 1 Introduction This short tutorial to OMNeT guides you through an example of modeling and sim ulation showing you along the way some of the commonly used OMNeT features 1 1 Prerequisites I assume you have downloaded OMNeT from its Web site OMN96 and successfully installed I recommend that to be sure that the installation is error free run at least a couple of the examples bundled with the distribution Also I assume that you are going to use the linux version of OMNeT for the experiments of this tutorial 2 Discrete Event Simulation with OMNeT Here are the steps you take to implement your first simulation 1 Create a working directory called tictoc and cd to this directory 2 Describe your example network by creating a topology file A topology file is a text file that identifies the network s nodes and the links between them Let s call this file tictoc ned Many thanks to Andr s Varga for suggestions tictoc tex v1 2 1 Introduction to Network Simulation Using OMNeT 1 Id tictoc ned v 1 2 2003 12 01 02 07 02 ahmet Exp 2 3 simple Txc 4 gates 5 in in 6 out out 7 endsimple 8 9 module Tictoc 10 submodules
6. Repeat the make command and then run the tictoc to see the effects of the prop agation delay In OMNeT communication link models can have quite sophisti cated properties Explore the user manual Var to see what they are Exercises Line 31 of txc cc contains the wait 1 0 OMNeT kernel call Find out what does this call do by referring to the OMNeT user manual Var Now let a tictoc simulation running Change the line 31 wait 1 0 of the txc cc to wait 100 0 Then do a make and run the new tictoc in another window Should we expect that the message exchange between tic and toc slowed If no why Delete the communication link connecting tic and toc Then insert a third mod ule called tac between the modules tic and toc This new module will be re sponsible for relaying messages bouncing between tic and toc by having direct connections to both of them tic tac toc i e there will not be a direct com munication between tic and toc have written the message handling mechanism of txc cc by using the activity call Rewrite the txc cc this time by using the handleMessage mechanism of OMNeT To do this you need to study the examples presented in the Section 5 3 2 of the OMNeT user manual Var References OMN96 OMNeT object oriented discrete event simulation system URL reference http www omnetpp org 1996 Var A Varga OMNeT Object oriented Discrete Event S
7. imulation System User Manual URL reference http www omnetpp org external doc html usman php tictoc tex v1 2 6
Download Pdf Manuals
Related Search
Related Contents
RESUMEN DE CARACTERÍSTICAS DEL Une rupture générationnelle TRENDnet TEW-453APB User's Manual 取扱説明書 OC−12 シリーズ cámara digital hp photosmart 715 guía del usuario MANUALE TECNICO MANUALE D`USO A. KORG PA80 OPERATING SYSTEM RELEASE 2.0 Microdata User Guide Adult Education and Training Survey User`s Manual Copyright © All rights reserved.
Failed to retrieve file