I have a class called WIFISegment as below in ns3.py :
class WIFISegment( object ):
"""Equivalent of radio WiFi channel.
Only Ap and WDS devices support SendFrom()."""
def __init__( self ):
# Helpers instantiation.
self.channelhelper = ns.wifi.YansWifiChannelHelper.Default()
self.phyhelper = ns.wifi.YansWifiPhyHelper.Default()
self.wifihelper = ns.wifi.WifiHelper.Default()
self.machelper = ns.wifi.NqosWifiMacHelper.Default()
# Setting channel to phyhelper.
self.channel = self.channelhelper.Create()
self.phyhelper.SetChannel( self.channel )
def add( self, node, port=None, intfName=None, mode=None ):
"""Connect Mininet node to the segment.
Will create WifiNetDevice with Mac type specified in
the MacHelper (default: AdhocWifiMac).
node: Mininet node
port: node port number (optional)
intfName: node tap interface name (optional)
mode: TapBridge mode (UseLocal or UseBridge) (optional)"""
# Check if this Mininet node has assigned an underlying ns-3 node.
if hasattr( node, 'nsNode' ) and node.nsNode is not None:
# If it is assigned, go ahead.
pass
else:
# If not, create new ns-3 node and assign it to this Mininet node.
node.nsNode = ns.network.Node()
allNodes.append( node )
# Install new device to the ns-3 node, using provided helpers.
device = self.wifihelper.Install( self.phyhelper, self.machelper, node.nsNode ).Get( 0 )
mobilityhelper = ns.mobility.MobilityHelper()
# Install mobility object to the ns-3 node.
mobilityhelper.Install( node.nsNode )
# If port number is not specified...
if port is None:
# ...obtain it automatically.
port = node.newPort()
# If interface name is not specified...
if intfName is None:
# ...obtain it automatically.
intfName = Link.intfName( node, port ) # classmethod
# In the specified Mininet node, create TBIntf bridged with the 'device'.
tb = TBIntf( intfName, node, port, node.nsNode, device, mode )
return tb
This class has a method called def add( self, node, port=None, intfName=None, mode=None ) and in this method we define mobilityhelper.
I was wondering if I can use mobilityhelper in another program. For example, I wrote another program and in my program I import WIFISegment, then define wifi = WIFISegment() and I can use its method "add" as follow wifi.add(h1) (h1 is host here).
My question is How I can use mobilityhelper of add() method in my other program. Because I need to set a new mobility each time.
Thanks Farzaneh