简体   繁体   English

如何在mininet中运行Python代码

[英]How to run Python Code in mininet

I write a simple topology with Python in mininet, but I dont know how to execute my code,I searched in internet and find several methods. 我在mininet中用Python写了一个简单的拓扑,但是我不知道如何执行我的代码,我在互联网上搜索并找到了几种方法。 which one is correct? 哪一个是正确的? And what is the difference between them? 它们之间有什么区别?

  1. Method 1: 方法1:

     sudo mn --custom ~/mininet/custom/filename.py --topo mytopo 
  2. Method 2: 方法2:

     sudo phython filename.py 
  3. Method 3: 方法3:

     chmod u+x filename.py sudo ./filename.py 
  • Method 1 is the classical method to deploy a custom topology in Mininet. 方法1是在Mininet中部署自定义拓扑的经典方法。 You can specify in the same command the controller, like this : 您可以在同一命令中指定控制器,如下所示:

     sudo mn --custom ~/mininet/custom/filename.py --topo mytopo --controller=remote,ip=[CONTROLLER_IP],port=6633 

    or if you don't, Mininet will use the default. 否则,Mininet将使用默认值。

  • Method 2 executes the [FILENAME] file. 方法2执行[FILENAME]文件。 Note that here you have to specify the controller which you will use inside the python script . 请注意, 您必须在此处指定在python脚本中使用的控制器 This is the difference with Method 1. 这与方法1有所不同。

  • Method 3 makes the [FILENAME] file executable with the first command, and then executes it. 方法3使用第一个命令使[FILENAME]文件可执行,然后执行它。 It is the same as Method 2. 它与方法2相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM