Closed hugo921 closed 5 years ago
anyone can discuss this issue with me ? i want to do it but i dont know how long time it will spend me.
You cannot currently do this from the GUI, it may be something to consider in the future when time permits.
Otherwise this should be able to be achieved using a script to drive creation of your session, potentially even ran as a script from the GUI, which would allow you to visualize and see it. You could spin off logic into a thread that would modify things over time or potentially even take your own custom commands. All depending on what you want.
Here is an example of a script that could be run from the GUI that adds a link after the scenario has been started and can be ran from the GUI using "File --> Execute XML or Python script...". You need to switch to the created session after using "Session --> Change sessions...".
If you start the core-daemon from command line "sudo core-daemon" you will see the ping output in your terminal when executing the script from the GUI. You can also just run the script itself and see the same output without the GUI.
from core.emulator.coreemu import CoreEmu
from core.emulator.emudata import IpPrefixes
from core.enumerations import NodeTypes, EventTypes
def main():
# ip generator for example
prefixes = IpPrefixes(ip4_prefix="10.83.0.0/16")
# create emulator instance for creating sessions and utility methods
coreemu = globals().get("coreemu", CoreEmu())
session = coreemu.create_session()
# must be in configuration state for nodes to start, when using "node_add" below
session.set_state(EventTypes.CONFIGURATION_STATE)
# create switch network node
switch = session.add_node(_type=NodeTypes.SWITCH)
switch.setposition(50, 50)
# node one with link to switch
node_one = session.add_node()
node_one.setposition(50, 200)
interface = prefixes.create_interface(node_one)
session.add_link(node_one.objid, switch.objid, interface_one=interface)
# node two with lik to switch
node_two = session.add_node()
node_two.setposition(200, 200)
# instantiate session
session.instantiate()
# attempt to ping node one from node two with no link
node_one_address = prefixes.ip4_address(node_one)
print "node %s pinging %s" % (node_two.name, node_one_address)
node_two.client.icmd(["ping", "-c", "3", node_one_address])
# add link from node two to switch
interface = prefixes.create_interface(node_two)
session.add_link(node_two.objid, switch.objid, interface_one=interface)
# attempt to ping node one from node two with link
node_one_address = prefixes.ip4_address(node_one)
print "node %s pinging %s" % (node_two.name, node_one_address)
node_two.client.icmd(["ping", "-c", "3", node_one_address])
if __name__ in {"__main__", "__builtin__"}:
main()
@hugo921 You could use a WLAN, this would allow you to use mobility or manually break/connect links within the network.
Also potentially can achieve desired effect through gRPC API on develop and master soon.
this function is very useful,but the core cannot support it.we can use this function test dynamic topology,it will be amazing!! anyone has some good idea to achieve it ?