2017-07-10 17:25:33 +01:00
|
|
|
"""
|
2017-08-01 17:28:11 +01:00
|
|
|
Unit tests for testing CORE EMANE networks.
|
2017-07-10 17:25:33 +01:00
|
|
|
"""
|
2019-04-08 17:49:37 +01:00
|
|
|
import os
|
2017-07-27 22:59:40 +01:00
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
2018-04-26 00:33:58 +01:00
|
|
|
from conftest import ping
|
2017-07-10 17:25:33 +01:00
|
|
|
from core.emane.bypass import EmaneBypassModel
|
|
|
|
from core.emane.commeffect import EmaneCommEffectModel
|
|
|
|
from core.emane.ieee80211abg import EmaneIeee80211abgModel
|
|
|
|
from core.emane.rfpipe import EmaneRfPipeModel
|
2017-07-27 22:59:40 +01:00
|
|
|
from core.emane.tdma import EmaneTdmaModel
|
2018-05-01 18:40:25 +01:00
|
|
|
from core.emulator.emudata import NodeOptions
|
2017-07-10 17:25:33 +01:00
|
|
|
|
2017-07-27 22:59:40 +01:00
|
|
|
_EMANE_MODELS = [
|
2018-03-28 07:38:34 +01:00
|
|
|
EmaneIeee80211abgModel,
|
|
|
|
EmaneRfPipeModel,
|
|
|
|
EmaneBypassModel,
|
|
|
|
EmaneCommEffectModel,
|
|
|
|
EmaneTdmaModel,
|
2017-07-27 22:59:40 +01:00
|
|
|
]
|
2019-04-08 17:49:37 +01:00
|
|
|
_DIR = os.path.dirname(os.path.abspath(__file__))
|
2017-07-10 17:25:33 +01:00
|
|
|
|
|
|
|
|
2017-07-27 22:59:40 +01:00
|
|
|
class TestEmane:
|
2018-03-28 07:38:34 +01:00
|
|
|
@pytest.mark.parametrize("model", _EMANE_MODELS)
|
2018-04-26 00:33:58 +01:00
|
|
|
def test_models(self, session, model, ip_prefixes):
|
2017-07-10 17:25:33 +01:00
|
|
|
"""
|
2017-07-27 22:59:40 +01:00
|
|
|
Test emane models within a basic network.
|
2017-07-10 17:25:33 +01:00
|
|
|
|
2018-05-01 18:40:25 +01:00
|
|
|
:param core.emulator.coreemu.EmuSession session: session for test
|
2017-07-27 22:59:40 +01:00
|
|
|
:param model: emane model to test
|
2018-04-26 00:33:58 +01:00
|
|
|
:param ip_prefixes: generates ip addresses for nodes
|
2017-07-10 17:25:33 +01:00
|
|
|
"""
|
|
|
|
|
|
|
|
# create emane node for networking the core nodes
|
2018-04-26 00:33:58 +01:00
|
|
|
emane_network = session.create_emane_network(
|
|
|
|
model,
|
|
|
|
geo_reference=(47.57917, -122.13232, 2.00000)
|
|
|
|
)
|
|
|
|
emane_network.setposition(x=80, y=50)
|
2017-07-10 17:25:33 +01:00
|
|
|
|
2019-04-08 17:49:37 +01:00
|
|
|
# configure tdma
|
|
|
|
if model == EmaneTdmaModel:
|
|
|
|
session.emane.set_model_config(emane_network.objid, EmaneTdmaModel.name, {
|
|
|
|
"schedule": os.path.join(_DIR, "../examples/tdma/schedule.xml")
|
|
|
|
})
|
|
|
|
|
2017-07-10 17:25:33 +01:00
|
|
|
# create nodes
|
2018-04-26 00:33:58 +01:00
|
|
|
node_options = NodeOptions()
|
|
|
|
node_options.set_position(150, 150)
|
|
|
|
node_one = session.create_wireless_node(node_options=node_options)
|
|
|
|
node_options.set_position(300, 150)
|
|
|
|
node_two = session.create_wireless_node(node_options=node_options)
|
2017-07-10 17:25:33 +01:00
|
|
|
|
2018-04-26 00:33:58 +01:00
|
|
|
for i, node in enumerate([node_one, node_two]):
|
|
|
|
node.setposition(x=150 * (i + 1), y=150)
|
|
|
|
interface = ip_prefixes.create_interface(node)
|
|
|
|
session.add_link(node.objid, emane_network.objid, interface_one=interface)
|
2017-07-10 17:25:33 +01:00
|
|
|
|
|
|
|
# instantiate session
|
2018-04-26 00:33:58 +01:00
|
|
|
session.instantiate()
|
2017-07-10 17:25:33 +01:00
|
|
|
|
|
|
|
# ping n2 from n1 and assert success
|
2018-04-26 00:33:58 +01:00
|
|
|
status = ping(node_one, node_two, ip_prefixes, count=5)
|
2017-07-10 17:25:33 +01:00
|
|
|
assert not status
|