0% found this document useful (0 votes)
41 views24 pages

Lab 2

This document discusses building network topologies using Omnet++. It covers gate vectors, dynamic connections, random sampling from distributions, and self-messaging. Students are asked to create a star network topology in Omnet++ with one hub node and N configurable outer nodes, where any node can send to any other through the hub by sampling from an exponential distribution for packet intervals. The submission requires submitting the project files in a zip along with a short video demonstrating the working project.

Uploaded by

Nada A. Amin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views24 pages

Lab 2

This document discusses building network topologies using Omnet++. It covers gate vectors, dynamic connections, random sampling from distributions, and self-messaging. Students are asked to create a star network topology in Omnet++ with one hub node and N configurable outer nodes, where any node can send to any other through the hub by sampling from an exponential distribution for packet intervals. The submission requires submitting the project files in a zip along with a short video demonstrating the working project.

Uploaded by

Nada A. Amin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 24

Cairo University Computer Networks-1

Faculty of Engineering CMP405-A /CMPN405


Computer Department Fall 2021

Network topologies with


omnet++
1
2 Today’s goal
 Build a LAN of an arbitrary N nodes.
 Any 2 nodes can send messages to each other (directly or indirectly).
 Experiment with different network topologies

Star Mesh Ring


3 We’ll learn about

1. Gate vectors
2. Dynamic connections
3. Sampling from random distributions
4. Self messaging
4
Gate vectors
Building gates of different sizes
5
Gate vectors

• Can create single gates and gate


vectors.
• Gate vectors follow the square
brackets syntax “[]”
Gate vector
• The size of a gate vector can be
Gate
specified or be left empty
• If left empty, size is inferred from
the connections, or is determined
when instantiated as a submodule
• You can find out the size of a gate by
calling gateSize(<gate_name>)
6 If size is left empty

Size is inferred Size is specified when


instantiated

Node1 has gate size 2, nodes 2 & 3 have a


size of 1
7
Gate vectors cont.

• Gate vectors can


accommodate and expand to
grow their pre-determined
size
• This code runs properly
without any errors.
• All nodes have a gate size of 2
8
Gate vectors cont.

We can also specify the size by


subclassing.
10 Gate vectors cont.

 Omnetpp by default doesn’t allow for a gate to be unconnected.


 An error will be produced when attempting to run with a gate that is unconnected.
 We can work around this by using the @loose property
11
Dynamic connections
12 Dealing with dynamic networks

 We can use for loops and if conditions inside connections to deal with arbitrarily
large modules and add some logic to our topology.
13 Dynamic networks cont.

N=4 (default) N=8


14 Nested loops
15
Simulating traffic
16 Simulating traffic

 We want to simulate traffic in our network.


 We can model a packet’s arrival at the sender node with a Poisson process, similar
to how we model queues.
 Then sampling from an Exponential distribution with a parameter lambda, we can
get the time interval for the next packet arrival.
 Upon arrival, we can then sample from a Uniform distribution a value to
determine which node our packet will be sent to.
17 Random sampling
 Omnetpp offers utility functions to sample from many different distributions.
 The two we’ll use the most are uniform and exponential as follows:
 uniform(double a, double b)

 exponential(double mean)
 Remember the exponential distribution’s mean = 1/lambda
 Lambda could be a parameter that has different value for every node
18 Self messaging
 Need to schedule the packet arrival event.
 Remember that messages are omnetpp’s representation of events.
 We need to send ourselves a message in the future, to trigger the sending at the
appropriate time.
 The scheduleAt(t, msg) function allows us to send ourselves a message that will be
received at simulation time t
 The simTime() functions returns the current simulation time.
 We can combine this with our samples interval to send ourselves a message as
follows:
19 Self messaging cont.

 Then inside the handleMessage(cMessage *msg) function, we can check if this is a


self message or not using the isSelfMessage() function
20 Sending the packet

 Finally, we can use the send(msg, gatename,


gateindex) function to send our message on the
proper gate to our destination node.
 Example:
 Send(msg, “outs”, 1);
21 Putting it all together

 Live overview of the Mesh project.


22 Extra illustration

Node Output gate Connected to


Node 0 0 -> Node 1
1 -> Node 2
2 -> Node 3
Node 1 0 -> Node 0
1 -> Node 2
2 -> Node 3
Node 2 0 -> Node 0
1 -> Node 1
2 -> Node 3
23 Useful functions

 gateSize(“outs”) //inside c, returns the size of the “out” gate array


 getIndex() // inside c, returns the current node index
 getParentModule()->par(“n”) //inside node.c, returns a pointer to the parent
module Mesh, and then we can use this pointer to access any parameter in the
parent module.
 Mesh.n // inside .ini where Mesh is the network module.
 Mesh.nodes[..] .lambda //inside.ini where the [..] means all the array
elements.
24 Requirement
 Similar to the Mesh network shown in the lab, create a Star network
topology consisting of 1 HUB and N nodes.
 N should be configurable in the .ini file.
 Each node is connected only to the hub.
 The hub is connected to all nodes.
 Any node is able to send to any other node through the hub.
 Sample from an exponential distribution to get the inter-packet wait times
using parameter Lambda which is also configurable in the .ini file.
25 Submission
 Work in pairs
 Submit one .zip project folder
 In the private comments write your names and Id’s.
 Submit one short video [ 3 to 5] minutes showing your working project
and showing each file of your project describing what changes you made.

You might also like