Last active
April 29, 2018 16:20
-
-
Save WoodProgrammer/a333dc25fafdd3765944c4bf13943470 to your computer and use it in GitHub Desktop.
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.node import CPULimitedHost | |
| from mininet.topo import Topo | |
| from mininet.net import Mininet | |
| from mininet.log import setLogLevel, info | |
| from mininet.node import RemoteController | |
| from mininet.cli import CLI | |
| #4 switches and 4 hosts. They are connected in a star shape. | |
| class SimplePktSwitch(Topo): | |
| """Simple topology example.""" | |
| def __init__(self, **opts): | |
| """Create custom topo.""" | |
| super(SimplePktSwitch, self).__init__(**opts) | |
| # Hostlar Ekleniyor. | |
| h1 = self.addHost('h1') | |
| h2 = self.addHost('h2') | |
| h3 = self.addHost('h3') | |
| h4 = self.addHost('h4') | |
| # Switchler Ekleniyor. | |
| s1 = self.addSwitch('s1', dpid="0000000000000001") | |
| s2 = self.addSwitch('s2', dpid="0000000000000002") | |
| s3 = self.addSwitch('s3', dpid="0000000000000003") | |
| s4 = self.addSwitch('s4', dpid="0000000000000004") | |
| # Add links | |
| self.addLink(h1, s1) | |
| self.addLink(h2, s2) | |
| self.addLink(h3, s3) | |
| self.addLink(h4, s4) | |
| self.addLink(s1, s2) | |
| self.addLink(s1, s3) | |
| self.addLink(s1, s4) | |
| def run(): | |
| c = RemoteController('c', '0.0.0.0', 6633) | |
| net = Mininet(topo=SimplePktSwitch(), host=CPULimitedHost, controller=None) | |
| net.addController(c) | |
| net.start() | |
| CLI(net) | |
| net.stop() | |
| if __name__ == '__main__': | |
| setLogLevel('info') | |
| run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment