问题
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