removed session.create_emane_network, removed unused node types

This commit is contained in:
bharnden 2019-10-22 21:27:31 -07:00
parent 14d759667c
commit 945f3cce5b
7 changed files with 40 additions and 58 deletions

View file

@ -73,18 +73,15 @@ class NodeTypes(Enum):
DEFAULT = 0
PHYSICAL = 1
TBD = 3
SWITCH = 4
HUB = 5
WIRELESS_LAN = 6
RJ45 = 7
TUNNEL = 8
KTUNNEL = 9
EMANE = 10
TAP_BRIDGE = 11
PEER_TO_PEER = 12
CONTROL_NET = 13
EMANE_NET = 14
DOCKER = 15
LXC = 16

View file

@ -55,15 +55,12 @@ from core.xml.corexml import CoreXmlReader, CoreXmlWriter
NODES = {
NodeTypes.DEFAULT: CoreNode,
NodeTypes.PHYSICAL: PhysicalNode,
NodeTypes.TBD: None,
NodeTypes.SWITCH: SwitchNode,
NodeTypes.HUB: HubNode,
NodeTypes.WIRELESS_LAN: WlanNode,
NodeTypes.RJ45: Rj45Node,
NodeTypes.TUNNEL: TunnelNode,
NodeTypes.KTUNNEL: None,
NodeTypes.EMANE: EmaneNet,
NodeTypes.EMANE_NET: None,
NodeTypes.TAP_BRIDGE: GreTapBridge,
NodeTypes.PEER_TO_PEER: PtpNet,
NodeTypes.CONTROL_NET: CtrlNet,
@ -906,28 +903,18 @@ class Session(object):
"""
self.mobility.handleevent(event_data)
def create_emane_network(
self, model, geo_reference, geo_scale=None, options=NodeOptions(), config=None
):
def set_location(self, lat, lon, alt, scale):
"""
Convenience method for creating an emane network.
Set session geospatial location.
:param model: emane model to use for emane network
:param geo_reference: geo reference point to use for emane node locations
:param geo_scale: geo scale to use for emane node locations, defaults to 1.0
:param core.emulator.emudata.NodeOptions options: options for emane node being created
:param dict config: emane model configuration
:return: create emane network
:param float lat: latitude
:param float lon: longitude
:param float alt: altitude
:param float scale: reference scale
:return: nothing
"""
# required to be set for emane to function properly
self.location.setrefgeo(*geo_reference)
if geo_scale:
self.location.refscale = geo_scale
# create and return network
emane_network = self.add_node(_type=NodeTypes.EMANE, options=options)
self.emane.set_model(emane_network, model, config)
return emane_network
self.location.setrefgeo(lat, lon, alt)
self.location.refscale = scale
def shutdown(self):
"""

View file

@ -5,7 +5,7 @@ import parser
from core.emane.ieee80211abg import EmaneIeee80211abgModel
from core.emulator.coreemu import CoreEmu
from core.emulator.emudata import IpPrefixes, NodeOptions
from core.emulator.enumerations import EventTypes
from core.emulator.enumerations import EventTypes, NodeTypes
def example(args):
@ -20,10 +20,11 @@ def example(args):
session.set_state(EventTypes.CONFIGURATION_STATE)
# create emane network node
emane_network = session.create_emane_network(
model=EmaneIeee80211abgModel, geo_reference=(47.57917, -122.13232, 2.00000)
)
emane_network.setposition(x=80, y=50)
session.set_location(47.57917, -122.13232, 2.00000, 1.0)
options = NodeOptions()
options.set_position(80, 50)
emane_network = session.add_node(_type=NodeTypes.EMANE, options=options)
session.emane.set_model(emane_network, EmaneIeee80211abgModel)
# create nodes
options = NodeOptions(model="mdr")

View file

@ -695,18 +695,15 @@ message NodeType {
enum Enum {
DEFAULT = 0;
PHYSICAL = 1;
TBD = 3;
SWITCH = 4;
HUB = 5;
WIRELESS_LAN = 6;
RJ45 = 7;
TUNNEL = 8;
KTUNNEL = 9;
EMANE = 10;
TAP_BRIDGE = 11;
PEER_TO_PEER = 12;
CONTROL_NET = 13;
EMANE_NET = 14;
DOCKER = 15;
LXC = 16;
}

View file

@ -12,6 +12,7 @@ from core.emane.ieee80211abg import EmaneIeee80211abgModel
from core.emane.rfpipe import EmaneRfPipeModel
from core.emane.tdma import EmaneTdmaModel
from core.emulator.emudata import NodeOptions
from core.emulator.enumerations import NodeTypes
from core.errors import CoreCommandError, CoreError
_EMANE_MODELS = [
@ -46,10 +47,11 @@ class TestEmane:
"""
# create emane node for networking the core nodes
emane_network = session.create_emane_network(
model, geo_reference=(47.57917, -122.13232, 2.00000)
)
emane_network.setposition(x=80, y=50)
session.set_location(47.57917, -122.13232, 2.00000, 1.0)
options = NodeOptions()
options.set_position(80, 50)
emane_network = session.add_node(_type=NodeTypes.EMANE, options=options)
session.emane.set_model(emane_network, model)
# configure tdma
if model == EmaneTdmaModel:
@ -87,12 +89,11 @@ class TestEmane:
:param ip_prefixes: generates ip addresses for nodes
"""
# create emane node for networking the core nodes
emane_network = session.create_emane_network(
EmaneIeee80211abgModel,
geo_reference=(47.57917, -122.13232, 2.00000),
config={"test": "1"},
)
emane_network.setposition(x=80, y=50)
session.set_location(47.57917, -122.13232, 2.00000, 1.0)
options = NodeOptions()
options.set_position(80, 50)
emane_network = session.add_node(_type=NodeTypes.EMANE, options=options)
session.emane.set_model(emane_network, EmaneIeee80211abgModel, {"test": "1"})
# create nodes
options = NodeOptions(model="mdr")

View file

@ -524,9 +524,9 @@ class TestGrpc:
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
emane_network = session.create_emane_network(
model=EmaneIeee80211abgModel, geo_reference=(47.57917, -122.13232, 2.00000)
)
session.set_location(47.57917, -122.13232, 2.00000, 1.0)
emane_network = session.add_node(_type=NodeTypes.EMANE)
session.emane.set_model(emane_network, EmaneIeee80211abgModel)
config_key = "platform_id_start"
config_value = "2"
session.emane.set_model_config(
@ -548,9 +548,9 @@ class TestGrpc:
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
emane_network = session.create_emane_network(
model=EmaneIeee80211abgModel, geo_reference=(47.57917, -122.13232, 2.00000)
)
session.set_location(47.57917, -122.13232, 2.00000, 1.0)
emane_network = session.add_node(_type=NodeTypes.EMANE)
session.emane.set_model(emane_network, EmaneIeee80211abgModel)
config_key = "bandwidth"
config_value = "900000"
@ -574,9 +574,9 @@ class TestGrpc:
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
emane_network = session.create_emane_network(
model=EmaneIeee80211abgModel, geo_reference=(47.57917, -122.13232, 2.00000)
)
session.set_location(47.57917, -122.13232, 2.00000, 1.0)
emane_network = session.add_node(_type=NodeTypes.EMANE)
session.emane.set_model(emane_network, EmaneIeee80211abgModel)
# then
with client.context_connect():

View file

@ -108,13 +108,12 @@ Examples for configuring custom emane model settings.
# create session and emane network
coreemu = CoreEmu()
session = coreemu.create_session()
emane_network = session.create_emane_network(
model=EmaneIeee80211abgModel,
geo_reference=(47.57917, -122.13232, 2.00000)
)
emane_network.setposition(x=80, y=50)
session.set_location(47.57917, -122.13232, 2.00000, 1.0)
options = NodeOptions()
options.set_position(80, 50)
emane_network = session.add_node(_type=NodeTypes.EMANE, options=options)
# set custom emane model config
config = {}
session.emane.set_model_config(emane_network.id, EmaneIeee80211abgModel.name, config)
session.emane.set_model(emane_network, EmaneIeee80211abgModel, config)
```