Lab 04 - Intro to Network Simulator - Portal

38 downloads 842 Views 75KB Size Report
For the benefit of this laboratory exercises we are going to use OMNET++ simulator. ... OMNET following the installation guide given in the e-learning website. 4.
LAB 4 INTRODUCTION TO NETWORK SIMULATOR

SCHOOL OF COMPUTER AND COMMUNICATION ENGINEERING UNIVERSITY MALAYSIA PERLIS 1|Page

1.

INTRODUCTION:

Discrete-event simulation complements analytical (mathematical) tools and experimental methods for performance analysis and estimation of communication networks. A well- designed simulation model can provide an extremely important insight into the structural weaknesses of a computer network or a communication protocol. Because of their versatility, in addition to modeling communication networks, discrete-event simulation methods are indeed widely used in a wide number of areas such as computer system performance analysis, manufacturing processes, database systems etc. and there is a large number of discrete-event simulation tools available. In this unit, we will be using OMNeT++ [OMN06] for building our simulation models and doing our experiments. OMNeT++ is a very well designed, modular, widely-used system; source code is available and free for teaching and research purposes For the benefit of this laboratory exercises we are going to use OMNET++ simulator. OMNeT++ is basically a collection of software tools and libraries which you can use to build your own simulation models. The simulation framework provides the following:    

  

A simulation kernel, A compiler for the NED topology description language, A graphical network editor for NED _les, A two types of user interfaces for simulation execution: o A graphical user interface, or o A command-line user interface Tools for plotting data, Utilities (random number seed generation tool, make_le creation tool, etc.) Tools for documentation

The actual models are written by the model designer, or borrowed from someone who has already written these. There are significant numbers of models available through the OMNeT++ Web site. 2.

OBJECTIVES:

This laboratory aims at developing the student understanding of OMNET++ simulation framework and familiarizes the student with OMNET++ modeling and simulation process. Upon completion of this lab, the student will be able to: 2.1 To develop the student understanding of simulation environment file architecture. 2.2 To create a simple OMNET++ project. 2.3 To design simple two nodes network.

2|Page

3.

OMNET++ INSTALLATION:

OMNET++ is open software developed under Linux operating system. The source file and installation guides for different releases of OMNET++ are available through OMNET website http://www.omnetpp.org, for this course laboratory module students are encouraged to install OMNET following the installation guide given in the e-learning website. 4.

OMNET++ PROJECT FILES:

OMNET++ project is composed of three types of files which are: 4.1 Source Files Source files are c++ files, which are to describe the protocol algorithms. Source file are build based-on Object Oriented Programming. Each source file defines a class that describes the functionality of a specific node, protocol, layer, message, or any other entity in the system. 4.2 Ned Files Network description file is an interface for a source file” simple module“, or multi-source files “compound module”. This file defines all parameters to be modified by each run. Also the parameters defined in the .ned file are accessible by .ini file. .ned file could be edited either code base or GUI base. In graphical mode, one can create compound modules, channels, and other component types. Submodules can be created using the palette of available module types. Visual and non-visual properties can be modified in the Properties View, or by dialogs invoked from the context menu. The editor offers many features such as unlimited undo/redo, object cloning, constrained move and resize, alignment of objects, and zooming. Submodules can be pinned (having a fixed position), or unpinned (auto-layout). Graphical features that can be edited are background image, background grid, default icons (via display string inheritance), icon sizing and coloring, transmission range, and many others. 4.3 Ini Files These types of file are intended for run parameters setup. .ned file’s parameters are also accessible from the .ini files. OMNET++ provide especial editor for this type of files. The Ini File Editor lets the user configure simulation models for execution. It features both form-based and source editing. The Ini File editor considers all supported configuration options and offers them in several forms, organized by topics. Descriptions and default values are displayed in tooltips, which can be made persistent for easier reading. The structure of the ini file (sections and their inheritance tree) is also visualized and editable via drag&drop and dialogs. Validation and content assist (Ctrl+Space) are also provided where needed. The editor supports unlimited undo/redo and automatic conversion from OMNeT⁠+⁠+ 3.x ini files. The text editor lets the user work with the ini file directly, which is more efficient for advanced users than forms. Unlimited undo/redo, syntax coloring, and completion of configuration keys, values, and module parameter patterns (on Ctrl+Space) are provided. As the user types, the file is continually analyzed and errors/warnings are displayed in real time. 3|Page

The editor considers all NED declarations (simple modules, compound modules, channels, etc.) and can fully exploit this information to provide diagnostics and assistance to the user. Looking at the network= configuration key, it knows the top-level compound module NED type, and internally builds a static picture of the network by recursively enumerating the top-level module's submodules, sub-submodules, sub-sub-submodules, etc., and continually relates this information to the ini file contents. Thus, the editor always knows which ini file keys match which module parameters, which are the ini file keys that are unused (will not match anything), and which module parameters are still open (i.e. have no value assigned yet). It displays this information in tooltips, as warnings, and in various views. 5.

OMNET++ PROJECT:

5.1 Project Description: Assume that in a network with two nodes connected with a direct link. When a node receives a message it will immediately resend it back to its neighbor node. Design this network in OMNET simulator. Answer: 5.1.1

Step 1:

Create an empty OMNET++ project. Before we can go any more steps we may need to describe our node functionality in details, and design the source file. As follow: Assume that: (1) The two nodes are sta1, and sta2. (2) The first message will be created by sta1. When sta1, or sta2 receives a message it will directly retransmitted to the other node through the link. This pseudo code describes the generation of the first message. Pseudo code: In the initial stage: If(sta1) Then create a message msg; Send msg to sta2 End if End initial stage.

4|Page

Now for both sta1,and 2, when a node receives a message then it will send it back to the other node, here is the pseudo code for this operation: when message recieved: send it back end 5.1.2

Step 2:

To design the adhered algorithm we need to write it the source file. As we mentioned before source file are responsible of describing the protocols algorithms. Create a source file, with a class that describes the previous operations. The class should contain two functions which are: void Node::initialize() { //check if sta1 if (strcmp("sta1", getName()) == 0) { //create and a message cMessage *msg = new cMessage("msg"); //send it to the another node send(msg, "out"); } }

And void Node::handleMessage(cMessage *msg) { //when message received //send it back send(msg,”out”); }

5.1.3

Step 3:

The network descriptions file .ned. In complex project we may need to design a .ned file for each source file, and separate .ned file for the network description. However in this project we can combine both in one .ned file. Create a new .ned file with one item “simple module”, and make sure the ned type name is same as the class name “from the source file”.

5|Page

In this step we link this .ned file to the previous created source file. In the text editor of the .ned file, create one input gate, and one output gate for the simple module “in, and out”. Make sure the name of the gate variable is same as the name in the send method on the source file. Now create a network: In the same.ned file add a network with two submodules, which are the two nodes sta1, and sta2. Now create the connections: In the network add a connection from the input gates of each node to the output gate of the other node. 5.1.4

Step 4:

Create the .ini file, in the .ini file we need to define the network. Create an empty .ini file. Make sure you select the network as in the .ned file. 5.1.5

Step 5:

Before we can run the project we need to compile the project. After compilation make sure to fix all errors. Now the project is ready to run. To run the project, create a new OMNET++ run configuration; select the project and the .ini file.

6.

TASKS:

6.1 Task 1: Install OMNET++ in your workstation. 6.2 Task 2: Answer the following questions: 1) What does the command ev