INET: Random static node positions while keeping a connected network?

68 views
Skip to first unread message

Ester Lopez

unread,
Jun 29, 2015, 7:13:13 AM6/29/15
to omn...@googlegroups.com
Dear all,

Im trying to simulate a mesh network, but when using the StationaryMobility model, sometimes the resulting network is not connected (there are islands of nodes). Is there any static "mobility" model in INET that places wireless nodes randomly, but still making sure that in the end we have a connected network?

Thanks,
Ester

Rudolf Hornig

unread,
Jul 1, 2015, 5:12:40 AM7/1/15
to omn...@googlegroups.com, ester.lo...@gmail.com
Nothing I'm aware of. The mobility model does not know anything about the nodes (i.e. it has no idea whether a node is wireless or not, what is the transmission range etc.) It would be almost impossible to know the full connectivity without taking into account all the model parameters, obstacles, fading etc. You should play with the number of nodes, playground area etc. to get a fully connected graph)

Ester Lopez

unread,
Jul 2, 2015, 2:52:41 AM7/2/15
to omn...@googlegroups.com
Sure, I didnt consider that... 

In the end I wrote a short python script to generate the omnetpp.ini with my nodes positions, where I can adjust the max and minim distance between nodes. In case anyone in the future has the same issue:

import random
import math
import sys
from jinja2 import Template
import textwrap

def choose_random(positions):
    return random.choice(positions)

def get_min_distance(positions, x, y):
    distances = [ math.sqrt((x - pos[0])**2 + (y - pos[1])**2) for pos in positions ]
    return min(distances)

def get_random_position(positions, radius):
    (x_0, y_0) = choose_random(positions)
    d = random.uniform(radius/2, radius)
    angle = random.uniform(0, 2*math.pi)
    return (x_0 + d*math.cos(angle), y_0 + d * math.sin(angle))

def getNpositions(N, radius):
    positions = [(0,0)]
    for i in range(N-1):
        (x, y) = get_random_position(positions, radius)
        while get_min_distance(positions, x, y) < radius/10:
            (x, y) = get_random_position(positions, radius)
        positions += [ (x,y) ]
    return positions


def generate():
    template = Template( textwrap.dedent("""
        [General]
        network = kdet
        experiment-label = {{ expLabel }}
        sim-time-limit = 65s
        **.numNodes = {{ nHosts }}
        **.numProxies = {{ nProxies }}
        **.mobility.numHosts = 100
        **.resultsFile = "results/TA{{ expLabel }}.csv"
        num-rngs = 3
        **.mobility.rng-0 = 1
        **.wlan[*].mac.rng-0 = 2
        #debug-on-errors = true

        tkenv-plugin-path = ../../../etc/plugins

        **.channelNumber = 0

        # channel physical parameters
        *.channelControl.carrierFrequency = 2.4GHz
        *.channelControl.pMax = 2.0mW
        *.channelControl.sat = -110dBm
        *.channelControl.alpha = 2
        *.channelControl.numChannels = 1

        # mobility
        {% for i in range(nHosts) %}
        **.hosts[{{ i }}].mobility.constraintAreaMinX = {{ positions[i][0] }}m
        **.hosts[{{ i }}].mobility.constraintAreaMaxX = {{ positions[i][0] }}m
        **.hosts[{{ i }}].mobility.constraintAreaMinY = {{ positions[i][1] }}m
        **.hosts[{{ i }}].mobility.constraintAreaMaxY = {{ positions[i][1] }}m
        {% endfor %}
        {% for i in range(nProxies) %}
        **.proxies[{{ i }}].mobility.constraintAreaMinX = {{ positions[i+nHosts][0] }}m
        **.proxies[{{ i }}].mobility.constraintAreaMaxX = {{ positions[i+nHosts][0] }}m
        **.proxies[{{ i }}].mobility.constraintAreaMinY = {{ positions[i+nHosts][1] }}m
        **.proxies[{{ i }}].mobility.constraintAreaMaxY = {{ positions[i+nHosts][1] }}m
        {% endfor %}
        **.mobility.constraintAreaMinZ = 0m
        **.mobility.constraintAreaMaxZ = 0m
        **.mobilityType = "StationaryMobility"

        # nic settings
        **.wlan[*].bitrate = 2Mbps
        **.wlan[*].mgmt.frameCapacity = 10
        **.wlan[*].mac.address = "auto"
        **.wlan[*].mac.maxQueueSize = 14
        **.wlan[*].mac.rtsThresholdBytes = 3000B
        **.wlan[*].mac.retryLimit = 7
        **.wlan[*].mac.cwMinData = 7
        **.wlan[*].mac.cwMinMulticast = 31
        **.wlan[*].radio.transmitterPower = 2mW
        **.wlan[*].radio.thermalNoise = -110dBm
        **.wlan[*].radio.sensitivity = -85dBm
        **.wlan[*].radio.pathLossAlpha = 2
        **.wlan[*].radio.snirThreshold = 4dB

        #### Malicious behavior
        {% for i in faulty %}
        **.hosts[{{ i }}].*.dropProbability = {{ dropFaulty }}
        **.hosts[{{ i }}].trafGen.numPackets = 0
        **.hosts[{{ i }}].faulty= true
        {% endfor %}
        **.dropProbability = 0.0
        **.k = {{ k }}

        #### Traffic Generator
        **.hosts[*].trafGenType = "IPvXTrafGen"
        **.proxies[*].trafGenType = "IPvXTrafSink"

        **.hosts[*].trafGen.startTime = uniform(60s,100s)
        **.hosts[*].trafGen.sendInterval = 100ms
        **.hosts[*].trafGen.numPackets = 100
        **.hosts[*].trafGen.protocol = 258
        **.hosts[*].trafGen.packetLength = 800B
        **.hosts[*].trafGen.destAddresses = "proxies[*]"
        **.proxies[*].trafGen.protocol = 258

        ### Vector recording
        **.ta.*.vector-recording = true
        **.flooding.*.vector-recording = true
        **.vector-recording = false
        # Routing
        **.routingProtocol = "OLSR"
        **.Tc_redundancy = 2    
        **.waitTime = 20s  
    """))
    nHosts = 20
    nProxies = 3
    positions = getNpositions(nHosts+nProxies, 200)
    random.shuffle(positions)
    faulty = random.sample(range(nHosts), int(nHosts*float(sys.argv[4])))
    context = {
        'expLabel': sys.argv[1],
        'nHosts': nHosts,
        'nProxies': nProxies,
        'positions': positions,
        'dropFaulty': float(sys.argv[2]),
        'k': int(sys.argv[3]),
        'faulty': faulty,
    }
    print template.render(context)


generate()




--
You received this message because you are subscribed to the Google Groups "OMNeT++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omnetpp+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/omnetpp.
For more options, visit https://groups.google.com/d/optout.

Rudolf Hornig

unread,
Jul 3, 2015, 4:57:32 AM7/3/15
to omn...@googlegroups.com, ester.lo...@gmail.com
Yeah, obviously this could be implemented also in the mobility model (i.e. adding some constraints to the static mobility that specifies the max/min separatation between the nodes). This seems to be a valid use case that is not covered by the current mobility models.

Now that INET 3.0 is out we have plans to review/refactor the mobility models too for INET 3.1. Would you mind posting this issue as a requirement on the INET issue tracker as a feature request?


It will be useful when we start planning the new mobility architecture.
Rudolf
To unsubscribe from this group and stop receiving emails from it, send an email to omnetpp+unsubscribe@googlegroups.com.

Ester Lopez

unread,
Jul 6, 2015, 11:33:37 AM7/6/15
to omn...@googlegroups.com
Sure! :) Done. I didn't know how to add the "feature" label... so I didn't do it.

I mentioned the constrains I used on my script, but if I any other that seems useful comes to mind, Ill add it as a comment there.

Best regards,
Ester

Rudolf
To unsubscribe from this group and stop receiving emails from it, send an email to omnetpp+u...@googlegroups.com.

Visit this group at http://groups.google.com/group/omnetpp.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "OMNeT++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omnetpp+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages