Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
Reinforcement_learning_based_bgp_system
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Anurag Kumar
Reinforcement_learning_based_bgp_system
Commits
a7a3ba7a
Commit
a7a3ba7a
authored
Nov 29, 2021
by
Anurag Kumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
c54bc766
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
144 additions
and
0 deletions
+144
-0
Controller_program/topology/quagga-test1.py
Controller_program/topology/quagga-test1.py
+144
-0
No files found.
Controller_program/topology/quagga-test1.py
0 → 100644
View file @
a7a3ba7a
#!/usr/bin/python
from
mininet.topo
import
Topo
from
mininet.net
import
Mininet
from
mininet.cli
import
CLI
from
mininet.log
import
setLogLevel
,
info
,
debug
from
mininet.node
import
Host
,
RemoteController
,
OVSSwitch
QUAGGA_DIR
=
'/usr/lib/quagga'
# Must exist and be owned by quagga user (quagga:quagga by default on Ubuntu)
QUAGGA_RUN_DIR
=
'/var/run/quagga'
CONFIG_DIR
=
'configs'
class
SdnIpHost
(
Host
):
def
__init__
(
self
,
name
,
ip
,
route
,
*
args
,
**
kwargs
):
Host
.
__init__
(
self
,
name
,
ip
=
ip
,
*
args
,
**
kwargs
)
self
.
route
=
route
def
config
(
self
,
**
kwargs
):
Host
.
config
(
self
,
**
kwargs
)
debug
(
"configuring route
%
s"
%
self
.
route
)
self
.
cmd
(
'ip route add default via
%
s'
%
self
.
route
)
class
Router
(
Host
):
def
__init__
(
self
,
name
,
quaggaConfFile
,
zebraConfFile
,
intfDict
,
*
args
,
**
kwargs
):
Host
.
__init__
(
self
,
name
,
*
args
,
**
kwargs
)
self
.
quaggaConfFile
=
quaggaConfFile
self
.
zebraConfFile
=
zebraConfFile
self
.
intfDict
=
intfDict
def
config
(
self
,
**
kwargs
):
Host
.
config
(
self
,
**
kwargs
)
self
.
cmd
(
'sysctl net.ipv4.ip_forward=1'
)
for
intf
,
attrs
in
self
.
intfDict
.
items
():
self
.
cmd
(
'ip addr flush dev
%
s'
%
intf
)
if
'mac'
in
attrs
:
self
.
cmd
(
'ip link set
%
s down'
%
intf
)
self
.
cmd
(
'ip link set
%
s address
%
s'
%
(
intf
,
attrs
[
'mac'
]))
self
.
cmd
(
'ip link set
%
s up '
%
intf
)
for
addr
in
attrs
[
'ipAddrs'
]:
self
.
cmd
(
'ip addr add
%
s dev
%
s'
%
(
addr
,
intf
))
self
.
cmd
(
'zebra -d -f
%
s -z
%
s/zebra
%
s.api -i
%
s/zebra
%
s.pid'
%
(
self
.
zebraConfFile
,
QUAGGA_RUN_DIR
,
self
.
name
,
QUAGGA_RUN_DIR
,
self
.
name
))
self
.
cmd
(
'bgpd -d -f
%
s -z
%
s/zebra
%
s.api -i
%
s/bgpd
%
s.pid'
%
(
self
.
quaggaConfFile
,
QUAGGA_RUN_DIR
,
self
.
name
,
QUAGGA_RUN_DIR
,
self
.
name
))
def
terminate
(
self
):
self
.
cmd
(
"ps ax | egrep 'bgpd
%
s.pid|zebra
%
s.pid' | awk '{print $1}' | xargs kill"
%
(
self
.
name
,
self
.
name
))
Host
.
terminate
(
self
)
class
SdnIpTopo
(
Topo
):
"SDN-IP tutorial topology"
def
build
(
self
):
s1
=
self
.
addSwitch
(
's1'
,
cls
=
OVSSwitch
,
dpid
=
'00000000000000a1'
,
protocols
=
'OpenFlow13'
)
s2
=
self
.
addSwitch
(
's2'
,
cls
=
OVSSwitch
,
dpid
=
'00000000000000a2'
,
protocols
=
'OpenFlow13'
)
s3
=
self
.
addSwitch
(
's3'
,
cls
=
OVSSwitch
,
dpid
=
'00000000000000a3'
,
protocols
=
'OpenFlow13'
)
s4
=
self
.
addSwitch
(
's4'
,
cls
=
OVSSwitch
,
dpid
=
'00000000000000a4'
,
protocols
=
'OpenFlow13'
)
s5
=
self
.
addSwitch
(
's5'
,
cls
=
OVSSwitch
,
dpid
=
'00000000000000a5'
,
protocols
=
'OpenFlow13'
)
s6
=
self
.
addSwitch
(
's6'
,
cls
=
OVSSwitch
,
dpid
=
'00000000000000a6'
,
protocols
=
'OpenFlow13'
)
zebraConf
=
'
%
s/zebra.conf'
%
CONFIG_DIR
# Switches we want to attach our routers to, in the correct order
attachmentSwitches
=
[
s1
,
s2
,
s5
,
s6
]
for
i
in
range
(
1
,
4
+
1
):
name
=
'r
%
s'
%
i
eth0
=
{
'mac'
:
'00:00:00:00:0
%
s:01'
%
i
,
'ipAddrs'
:
[
'10.0.
%
s.1/24'
%
i
]
}
eth1
=
{
'ipAddrs'
:
[
'192.168.
%
s.254/24'
%
i
]
}
intfs
=
{
'
%
s-eth0'
%
name
:
eth0
,
'
%
s-eth1'
%
name
:
eth1
}
quaggaConf
=
'
%
s/quagga
%
s.conf'
%
(
CONFIG_DIR
,
i
)
router
=
self
.
addHost
(
name
,
cls
=
Router
,
quaggaConfFile
=
quaggaConf
,
zebraConfFile
=
zebraConf
,
intfDict
=
intfs
)
host
=
self
.
addHost
(
'h
%
s'
%
i
,
cls
=
SdnIpHost
,
ip
=
'192.168.
%
s.1/24'
%
i
,
route
=
'192.168.
%
s.254'
%
i
)
self
.
addLink
(
router
,
attachmentSwitches
[
i
-
1
])
self
.
addLink
(
router
,
host
)
# Set up the internal BGP speaker
bgpEth0
=
{
'mac'
:
'00:00:00:00:00:01'
,
'ipAddrs'
:
[
'10.0.1.101/24'
,
'10.0.2.101/24'
,
'10.0.3.101/24'
,
'10.0.4.101/24'
,]
}
bgpEth1
=
{
'ipAddrs'
:
[
'10.10.10.1/24'
]
}
bgpIntfs
=
{
'bgp-eth0'
:
bgpEth0
,
'bgp-eth1'
:
bgpEth1
}
bgp
=
self
.
addHost
(
"bgp"
,
cls
=
Router
,
quaggaConfFile
=
'
%
s/quagga-sdn.conf'
%
CONFIG_DIR
,
zebraConfFile
=
zebraConf
,
intfDict
=
bgpIntfs
)
self
.
addLink
(
bgp
,
s3
)
# Connect BGP speaker to the root namespace so it can peer with ONOS
root
=
self
.
addHost
(
'root'
,
inNamespace
=
False
,
ip
=
'10.10.10.2/24'
)
self
.
addLink
(
root
,
bgp
)
# Wire up the switches in the topology
self
.
addLink
(
s1
,
s2
,
bw
=
10
)
self
.
addLink
(
s1
,
s3
,
bw
=
20
)
self
.
addLink
(
s2
,
s4
,
bw
=
30
)
self
.
addLink
(
s3
,
s4
,
bw
=
10
)
self
.
addLink
(
s3
,
s5
,
bw
=
20
)
self
.
addLink
(
s4
,
s6
,
bw
=
30
)
self
.
addLink
(
s5
,
s6
,
bw
=
40
)
sdnh1
=
self
.
addHost
(
'sdnh1'
,
ip
=
'192.168.0.1'
)
sdnh2
=
self
.
addHost
(
'sdnh2'
,
ip
=
'192.168.0.2'
)
self
.
addLink
(
sdnh1
,
s3
)
self
.
addLink
(
sdnh2
,
s4
)
topos
=
{
'sdnip'
:
SdnIpTopo
}
if
__name__
==
'__main__'
:
setLogLevel
(
'debug'
)
topo
=
SdnIpTopo
()
net
=
Mininet
(
topo
=
topo
,
controller
=
RemoteController
)
net
.
start
()
CLI
(
net
)
net
.
stop
()
info
(
"done
\n
"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment