Skip to content

Commit

Permalink
added initial protobuf for lsp's representation.
Browse files Browse the repository at this point in the history
added new class TEController. so application will looks like:
pce_controller - everything related to communication between pcc and pce will be here (socket's handling etc)
pcep - pcep handling (msg parsing etc)
te_controller - full controllers logic (todo;)(path computation, lsp storing etc) or/and proxy to external controller
  • Loading branch information
tehnerd committed Oct 26, 2013
1 parent b284b47 commit 9f161ef
Show file tree
Hide file tree
Showing 5 changed files with 391 additions and 7 deletions.
35 changes: 35 additions & 0 deletions mpls_lsp.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package mplspce;

message LSP {
optional string pcc_ip = 1;

message LSPObject {
optional uint32 plsp_id = 1;
optional bool delegated = 2;
optional bool administrative = 3;
optional uint32 operational = 4;
}

message LSPAttributeObject {
optional uint32 setup_prio = 1;
optional uint32 hold_prio = 2;
optional bool local_protection = 3;
}

message EROSubObject {
optional bool loose =1;
optional string node_ip =2;
optional uint32 node_mask =3;
}

message RROSubObject {
optional string node_ip =1;
optional uint32 node_mask =2;
}

optional LSPObject lsp_obj = 2;
optional LSPAttributeObject lspa_obj = 3;
repeated EROSubObject ero =4;
repeated RROSubObject rro =5;
optional uint32 bandwidth =6;
}
288 changes: 288 additions & 0 deletions mpls_lsp_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions pce_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import gevent
import socket
import pcep
import te_controller
import time
from gevent import monkey
monkey.patch_socket()
Expand All @@ -16,7 +17,7 @@ def send_ka(pcep_context, sock):
sock.send(pcep_context.generate_ka_msg())
gevent.sleep(pcep_context._ka_timer)

def pcc_handler(clsock,sid):
def pcc_handler(clsock,sid,controller):
pcep_context = pcep.PCEP(open_sid = sid)
print(clsock[1])
msg=clsock[0].recv(1000)
Expand All @@ -25,18 +26,20 @@ def pcc_handler(clsock,sid):
ka_greenlet = gevent.spawn(send_ka,pcep_context,clsock[0])
while True:
msg=clsock[0].recv(1000)
pcep_context.parse_rcved_msg(msg)
parsed_msg = pcep_context.parse_rcved_msg(msg)
controller.handle_pce_message(clsock[1],parsed_msg)
#time.sleep(100)
clsock[0].close()

def main():
CURRENT_SID = 0
controller = te_controller.TEController()
servsock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
servsock.bind((SERVADDR,SERVPORT))
servsock.listen(MAXCLIENTS)
while True:
client = servsock.accept()
gevent.spawn(pcc_handler,client,CURRENT_SID)
gevent.spawn(pcc_handler,client,CURRENT_SID,controller)
CURRENT_SID += 1

if __name__ == '__main__':
Expand Down
8 changes: 4 additions & 4 deletions pcep.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def parse_rcved_msg(self, msg):
self.parse_open_msg(common_hdr, msg)
elif common_hdr[1] == 2:
print('ka msg recved')
self.parse_ka_msg(common_hdr, msg)
return self.parse_ka_msg(common_hdr, msg)
elif common_hdr[1] == 3:
print('pcreq msg recved')
elif common_hdr[1] == 4:
Expand All @@ -141,11 +141,11 @@ def parse_rcved_msg(self, msg):
elif common_hdr[1] == 7:
print('close msg recved')
elif common_hdr[1] == 10:
self.parse_state_report_msg(common_hdr,msg)
print('pcc state report msg recved')
return self.parse_state_report_msg(common_hdr,msg)
elif common_hdr[1] == 11:
print('pcc update msg recved')

return ('NotImplemented',None)

"""
The format of the OPEN object body is as follows:
Expand Down Expand Up @@ -577,6 +577,6 @@ def generate_ka_msg(self):
return common_hdr

def parse_ka_msg(self,common_hdr,msg):
pass
return ('ka_msg',)


Loading

0 comments on commit 9f161ef

Please sign in to comment.