2020-09-12 07:49:26 +01:00
|
|
|
# required imports
|
2021-05-03 23:25:18 +01:00
|
|
|
from core.api.grpc import clientw
|
|
|
|
from core.api.grpc.wrappers import NodeType, Position
|
2020-06-05 19:20:23 +01:00
|
|
|
from core.emane.ieee80211abg import EmaneIeee80211abgModel
|
|
|
|
|
2020-09-12 07:49:26 +01:00
|
|
|
# interface helper
|
2021-05-03 23:25:18 +01:00
|
|
|
iface_helper = clientw.InterfaceHelper(ip4_prefix="10.0.0.0/24", ip6_prefix="2001::/64")
|
2020-09-12 07:49:26 +01:00
|
|
|
|
|
|
|
# create grpc client and connect
|
2021-05-03 23:25:18 +01:00
|
|
|
core = clientw.CoreGrpcClient()
|
2020-09-12 07:49:26 +01:00
|
|
|
core.connect()
|
|
|
|
|
2021-05-03 23:25:18 +01:00
|
|
|
# add session
|
|
|
|
session = core.add_session()
|
2020-09-12 07:49:26 +01:00
|
|
|
|
2021-05-03 23:25:18 +01:00
|
|
|
# create nodes
|
2020-09-12 07:49:26 +01:00
|
|
|
position = Position(x=200, y=200)
|
2021-05-03 23:25:18 +01:00
|
|
|
emane = session.add_node(
|
|
|
|
1, _type=NodeType.EMANE, position=position, emane=EmaneIeee80211abgModel.name
|
|
|
|
)
|
2020-09-12 07:49:26 +01:00
|
|
|
position = Position(x=100, y=100)
|
2021-05-03 23:25:18 +01:00
|
|
|
node1 = session.add_node(2, model="mdr", position=position)
|
2020-09-12 07:49:26 +01:00
|
|
|
position = Position(x=300, y=100)
|
2021-05-03 23:25:18 +01:00
|
|
|
node2 = session.add_node(3, model="mdr", position=position)
|
2020-09-12 07:49:26 +01:00
|
|
|
|
2021-05-03 23:25:18 +01:00
|
|
|
# create links
|
|
|
|
iface1 = iface_helper.create_iface(node1.id, 0)
|
|
|
|
session.add_link(node1=node1, node2=emane, iface1=iface1)
|
|
|
|
iface1 = iface_helper.create_iface(node2.id, 0)
|
|
|
|
session.add_link(node1=node2, node2=emane, iface1=iface1)
|
2020-09-12 07:49:26 +01:00
|
|
|
|
2021-05-03 23:25:18 +01:00
|
|
|
# setup emane configurations using a dict mapping currently support values as strings
|
|
|
|
session.set_emane({"eventservicettl": "2"})
|
|
|
|
emane.set_emane_model(EmaneIeee80211abgModel.name, {"unicastrate": "3"})
|
2021-02-17 18:09:33 +00:00
|
|
|
|
2021-05-03 23:25:18 +01:00
|
|
|
# start session
|
|
|
|
core.start_session(session)
|