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
45c2e504
You need to sign in or sign up before continuing.
Commit
45c2e504
authored
Nov 29, 2021
by
Anurag Kumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
e7da4fed
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
+43
-0
Controller_program/Ryu_controller_sdn/hop_db.py
Controller_program/Ryu_controller_sdn/hop_db.py
+43
-0
No files found.
Controller_program/Ryu_controller_sdn/hop_db.py
0 → 100644
View file @
45c2e504
# encoding: utf-8
from
ryu.base
import
app_manager
from
netaddr
import
IPNetwork
,
IPAddress
"""
Record routing information: destination network ---> next hop address
"""
class
HopDB
(
app_manager
.
RyuApp
):
def
__init__
(
self
):
super
(
HopDB
,
self
)
.
__init__
()
self
.
hops
=
{}
# prefix -> hop
self
.
installed_prefix
=
[]
def
add_hop
(
self
,
prefix
,
next_hop
):
self
.
hops
.
setdefault
(
prefix
,
next_hop
)
def
remove_hop
(
self
,
prefix
):
del
self
.
hops
[
prefix
]
def
get_nexthop
(
self
,
prefix
):
return
self
.
hops
.
get
(
prefix
)
def
get_nexthop_by_ip
(
self
,
ip
):
ip_addr
=
IPAddress
(
ip
)
for
prefix
in
self
.
hops
.
keys
():
cidr
=
IPNetwork
(
prefix
)
if
ip_addr
in
cidr
:
return
[
cidr
,
self
.
hops
.
get
(
prefix
)]
return
None
def
is_prefix_installed
(
self
,
prefix
):
return
(
prefix
in
self
.
installed_prefix
)
def
get_uninstalled_prefix_list
(
self
):
result
=
[
prefix
for
prefix
in
self
.
hops
.
keys
()
if
(
prefix
not
in
self
.
installed_prefix
)]
return
result
def
install_prefix
(
self
,
prefix
):
self
.
installed_prefix
.
append
(
prefix
)
def
get_all_prefixes
(
self
):
return
self
.
hops
.
keys
()
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