2021-05-04 21:29:22 +01:00
|
|
|
from core.api.grpc import client
|
2021-05-03 23:25:18 +01:00
|
|
|
from core.api.grpc.wrappers import NodeType, Position
|
2020-06-05 19:20:23 +01:00
|
|
|
|
2020-09-12 07:49:26 +01:00
|
|
|
# interface helper
|
2021-05-04 21:29:22 +01:00
|
|
|
iface_helper = client.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-04 21:29:22 +01:00
|
|
|
core = client.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
|
|
|
wlan = session.add_node(1, _type=NodeType.WIRELESS_LAN, position=position)
|
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=wlan, iface1=iface1)
|
|
|
|
iface1 = iface_helper.create_iface(node2.id, 0)
|
|
|
|
session.add_link(node1=node2, node2=wlan, iface1=iface1)
|
|
|
|
|
|
|
|
# set wlan config using a dict mapping currently
|
2020-09-12 07:49:26 +01:00
|
|
|
# support values as strings
|
2021-05-03 23:25:18 +01:00
|
|
|
wlan.set_wlan(
|
2020-09-12 07:49:26 +01:00
|
|
|
{
|
|
|
|
"range": "280",
|
|
|
|
"bandwidth": "55000000",
|
|
|
|
"delay": "6000",
|
|
|
|
"jitter": "5",
|
|
|
|
"error": "5",
|
2021-05-03 23:25:18 +01:00
|
|
|
}
|
2020-09-12 07:49:26 +01:00
|
|
|
)
|
|
|
|
|
2021-05-03 23:25:18 +01:00
|
|
|
# start session
|
|
|
|
core.start_session(session)
|