Skip to content

Commit

Permalink
changed task3a
Browse files Browse the repository at this point in the history
  • Loading branch information
SandeepTadepalli1 committed Dec 5, 2017
1 parent 28edf29 commit 739769a
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 3 deletions.
77 changes: 77 additions & 0 deletions scripts/task3a_topo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.node import Node
from mininet.log import setLogLevel, info
from mininet.cli import CLI
from mininet.net import Mininet
from mininet.node import Controller, RemoteController, OVSController
from mininet.node import CPULimitedHost, Host, Node
from mininet.node import OVSKernelSwitch, UserSwitch
from mininet.node import IVSSwitch
from mininet.cli import CLI
from mininet.log import setLogLevel, info
from mininet.node import Node
from mininet.link import TCLink, Intf
from subprocess import call



class LinuxRouter( Node ):
"A Node with IP forwarding enabled."

def config( self, **params ):
super( LinuxRouter, self).config( **params )
# Enable forwarding on the router
self.cmd( 'sysctl net.ipv4.ip_forward=1' )

def terminate( self ):
self.cmd( 'sysctl net.ipv4.ip_forward=0' )
super( LinuxRouter, self ).terminate()


class NetworkTopo( Topo ):

def build( self, **_opts ):
router = self.addNode( 'r0', cls=LinuxRouter, ip='10.0.0.1/24' )
s1 = self.addSwitch('s1', cls=OVSKernelSwitch)
s2 = self.addSwitch('s2', cls=OVSKernelSwitch)
s3 = self.addSwitch('s3', cls=OVSKernelSwitch)

info( '*** Add hosts\n')
stu1 = self.addHost('stu1', cls=Host, ip='10.0.0.2', defaultRoute ='via 10.0.0.1')
stu2 = self.addHost('stu2', cls=Host, ip='10.0.0.3', defaultRoute ='via 10.0.0.1')
fac1 = self.addHost('fac1', cls=Host, ip='10.0.0.101', defaultRoute ='via 10.0.0.1')
fac2 = self.addHost('fac2', cls=Host, ip='10.0.0.102', defaultRoute='via 10.0.0.1')

ext1 = self.addHost('ext1', cls=Host, ip='12.12.12.12', defaultRoute='via 12.12.12.1')
ext2 = self.addHost('ext2', cls=Host, ip='11.11.11.11', defaultRoute='via 11.11.11.1')

info( '*** Add links\n')
self.addLink(s3, router,intfName2='r0-eth1',params2={'ip':'10.0.0.1/24'})
self.addLink(ext1, router,intfName2='r0-eth2',params2={'ip':'12.12.12.1/24'})
self.addLink(ext2, router,intfName2='r0-eth3',params2={'ip':'11.11.11.1/24'})
self.addLink(stu1, s1)
self.addLink(stu2, s1)
self.addLink(fac1, s2)
self.addLink(fac2, s2)
self.addLink(s2,s3)
self.addLink(s1,s3)



def run():
"Test linux router"
topo = NetworkTopo()
net = Mininet( topo=topo ) # controller is used by s1-s3
net.start()
#info( '*** Routing Table on Router:\n' )
#info( net[ 'r0' ].cmd( 'route' ) )
# net['ext1'].cmd('python -m SimpleHTTPServer 80')
# net['ext2'].cmd('python -m SimpleHTTPServer 80')

CLI( net )
net.stop()

if __name__ == '__main__':
setLogLevel( 'info' )
run()
File renamed without changes.
4 changes: 2 additions & 2 deletions tasks/task3/bandlimit.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ And there is a external internet where two Servers are running
The objective is to rate limit the bandwidth allocated to students and faculty does not have any such limits

#### Run script:
Use [topo.py](https://github.com/shreyakupadhyay/SDN-Project/blob/master/scripts/task3_topo.py)
Use [topo.py](https://github.com/shreyakupadhyay/SDN-Project/blob/master/scripts/task3a_topo.py)
```
$ sudo mn --custom mesh.py --topo task3_topo.py --controller=remote,ip=127.0.0.1
$ python task3a_topo.py
```
This setsup the mininet environment and the topology of the simple campus network

Expand Down
2 changes: 1 addition & 1 deletion tasks/task3/firewall.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ To run the firewall first we need to setup the campus network on the mininet.

Use [topo.py](https://github.com/shreyakupadhyay/SDN-Project/blob/master/scripts/task3_topo.py)
```sh
$ sudo mn --custom mesh.py --topo task3_topo.py --controller=remote,ip=127.0.0.1
$ sudo mn --custom mesh.py --topo task3b_topo.py --controller=remote,ip=127.0.0.1
```
Here we are using a remote Open Day light controller instead of a normal POX controller which is default by the mininet.

Expand Down

0 comments on commit 739769a

Please sign in to comment.