Last active
February 1, 2019 16:56
-
-
Save yjlcoder/4845a184294429efbe44df10fd24b3fc to your computer and use it in GitHub Desktop.
A simple mininet topology
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from mininet.topo import Topo | |
| from mininet.link import TCLink | |
| from mininet.log import info | |
| from mininet.net import Mininet | |
| from mininet.cli import CLI | |
| from mininet.node import RemoteController | |
| def main(): | |
| net = Mininet(link=TCLink) | |
| controller = RemoteController("c1") | |
| info("*** Adding Switches ***\n") | |
| s1 = net.addSwitch("s1") | |
| s2 = net.addSwitch("s2") | |
| s3 = net.addSwitch("s3") | |
| s4 = net.addSwitch("s4") | |
| info("*** Adding Hosts ***\n") | |
| h1 = net.addHost("h1") | |
| h2 = net.addHost("h2") | |
| info("*** Adding Links ***\n") | |
| net.addLink(s1, h1) | |
| net.addLink(s4, h2) | |
| net.addLink(s1, s2, delay="10ms", bw=10) | |
| net.addLink(s1, s3, delay="20ms", bw=10) | |
| net.addLink(s4, s2) | |
| net.addLink(s4, s3) | |
| info("*** Starting network ***\n") | |
| net.build() | |
| s1.start([controller]) | |
| s2.start([controller]) | |
| s3.start([controller]) | |
| s4.start([controller]) | |
| info("*** Running CLI ***\n") | |
| CLI(net).run() | |
| info("*** Stopping network ***\n") | |
| net.stop() | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment