How to run script from mininet shell?

纵饮孤独 提交于 2020-01-25 09:27:07

问题


I've got an assignment in SDN course to create a Load Balancer using mininet and pox controller. I have the topology file, which I've created using Python and mininet, and the controller file, which I've created using Python and POX. The topology is as follow: Hosts h1-h4 are the client hosts, Hosts h5-h8 are the servers. I have one switch that acts as the load balancer. The clients send a requests to the switch, which forwards the request to a randomly selected server. The server is then sends the request back to the switch, and the switch is then direct it back to the client.

I've managed to complete this task, but now i have to show that the load balancer is acting as expected (meaning, it balance the requests among all servers). The way i need to show it, is by generate at least 10,000 requests from the clients to the switch.

My question is: how do i make a script like that and run it from the mininet shell? I thought about making a script that runs a loop (10K iterations) and pick a random client which ping the switch. The problem is i don't know how to do it.


回答1:


You can use mininet API to do it. Once your topology is created. You can include a loop in the same mininet file, which randomly selects a client and ping switch. Let us say the selected client node is h1.

    h1.cmd(<your command which is to be run at h1 to ping switch>)

command passed as argument will be run at h1's terminal. cmdPrint function does the same except it also prints output. For an exclusive list of mininet API funcions for a node, please refer mininet api reference



来源:https://stackoverflow.com/questions/50087319/how-to-run-script-from-mininet-shell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!