Exemplo n.º 1
0
    def run(self, ctrlinfo_raw_data):
        # The structure and and basic function just list here, other functions need to be added in future work.
        CtrlInfo_data_list = self.parse_CtrlInfo_Data(ctrlinfo_raw_data)

        if (CtrlInfo_data_list[0] == '0x0000'):  # FlowMod
            pass


        elif (CtrlInfo_data_list[0] == '0x0001'):  # FaceMod
            FaceMod_Operate_list = [CtrlInfo_data_list[2], CtrlInfo_data_list[1]]
            OSCommand.facemod(FaceMod_Operate_list)


        elif (CtrlInfo_data_list[0] == '0x0002'):  # TableMod
            pass

        elif (CtrlInfo_data_list[0] == '0x0003'):  # Role
            pass

        elif (CtrlInfo_data_list[0] == '0x0004'):  # Error
            pass

        elif (CtrlInfo_data_list[0] == '0x0005'):  # CS
            pass

        elif (CtrlInfo_data_list[0] == '0x0006'):  # PrefixMod
            pass

        elif (CtrlInfo_data_list[0] == '0x0007'):  # Fib RouteMod
            pass

        else:
            pass
Exemplo n.º 2
0
    def additem(Fulltable,parsedlist):  #add table item with the list including 5 elements
        # [EthernetPrefix(0), Face(1), Prefix(2), Priority(3),Counter(4),
        # Idle-Lifetime(5),Hard-lifetime(6),Action(7),Out-faces(8),Flag(9)]
        try:
            Fulltable = np.row_stack((Fulltable, parsedlist))  # insert one line at the end
            OSCommand.addrouttoRIB(parsedlist[2], parsedlist[8])
            print('################# Add New Route ################\n')
            print("New route '{0}' has been added to RIB \n".format(parsedlist[2]))
            print('################################################\n')

        except:
            return ("add faild")
        return (Fulltable)
Exemplo n.º 3
0
    def onInterest_Feature(self, mainPrefix, interest, transport,
                           registeredPrefixId):
        print("++++++++ Received <<<FeatureReq>>> interest ++++++++ \n")
        feature_face = OSCommand.getface()
        feature_FIB = OSCommand.getFIB()
        nodeid = bytes(self.nodeid, 'utf-8')

        feature_data = nodeid + b'----' + feature_face + b'----' + feature_FIB

        data = OFMSG().create_feature_res_data(interest, feature_data)

        transport.send(data.wireEncode().toBuffer())
        print("++++++++ Sent <<<FeatureRes>>> Data ++++++++ \n")
        self.isDone = True  #
Exemplo n.º 4
0
    def __init__(self):

        self.nodeid = OSCommand.getnodeid()
        self.controller_listener = Controller_Listener()
        self.controller_listener_ctrlinfo = Controller_Listener_CtrlInfo()
        self.controller_listener_hello = Controller_Listener_Hello()
        self.controller_setter = Controller_Setter()
Exemplo n.º 5
0
 def __init__(self):
     self.outstanding = dict(
     )  #a dictionary to keep track of outstanding Interests and retransmissions.
     self.isDone = False
     #self.face = Face("127.0.0.1")
     self.face = Face()
     self.nodeid = OSCommand.getnodeid()
Exemplo n.º 6
0
 def __init__(self):
     self.keyChain = KeyChain()
     self.isDone = False
     self.ofmsg = OFMSG()
     self.outstanding = dict(
     )  # a dictionary to keep track of outstanding Interests and retransmissions.
     self.face = Face()
     self.nodeid = OSCommand.getnodeid()
Exemplo n.º 7
0
    def run(self):

        nodeid = OSCommand.getnodeid()
        # nexthop_to_controller_faceid = OSCommand.getRIBnexthop_of_prefix('/ndn/ie/tcd/controller01/')
        nexthop_to_controller_faceid = OSCommand.getRIBnexthop_of_prefix(
            '/ndn/h6-site/h6')  # just for demo
        subprocess.check_output(["export HOME=/tmp/minindn/{0} && nfdc route add / {1} ". \
                                format(nodeid, nexthop_to_controller_faceid)], shell=True)

        try:
            self._sendNextInterest(self.prefix)

            while not self.isDone:
                self.face.processEvents()
                time.sleep(0.01)

        except RuntimeError as e:
            print("ERROR: %s" % e)
Exemplo n.º 8
0
 def __init__(self, prefix):
     self.prefix = Name(prefix)
     self.outstanding = dict(
     )  # a dictionary to keep track of outstanding Interests and retransmissions.
     self.isDone = False
     self.face = Face("127.0.0.1")
     # self.face = Face()
     self.keyChain = KeyChain()
     self.nodeid = OSCommand.getnodeid()
Exemplo n.º 9
0
    def onInterest_FaceMod(self, mainPrefix, interest, transport,
                           registeredPrefixId):
        print("--------Received <<<FaceMod>>> interest Msg")
        FaceMod_suffix_list = NdnFlowTable.parse_FaceMod_Interest(interest)
        # FaceMod_suffix_list pattern:[faceid, action]

        print(OSCommand.facemod(FaceMod_suffix_list)
              )  # modify the face and print the command output
        self.isDone = True  #
 def __init__(self):
     self.keyChain = KeyChain()
     self.isDone = False
     self.ofmsg = OFMSG()
     self.nodeid = OSCommand.getnodeid()
     self.face = Face()
     self.featurereq = FeatureReq()
     self.helloreq_name_list = []
     self.new_CtrlInfo_data = "---Initial CtrlInfo data---"  # used to get new ctrlinfo data and send to nodes.
     self.CtrlInfo_data = ""  # used to record used ctrlinfo data
Exemplo n.º 11
0
 def __init__(self):
     self.keyChain = KeyChain()
     self.isDone = False
     self.ofmsg = OFMSG()
     self.outstanding = dict()  # a dictionary to keep track of outstanding Interests and retransmissions.
     # self.face = Face("127.0.0.1")
     self.face = Face()
     self.nodeid = OSCommand.getnodeid()
     self.send_ctrlinfo_interest = True
     self.ctrlinfo_operation = CtrlInfo_Operation()
Exemplo n.º 12
0
    def _onData(self, interest, data):
        payload = data.getContent()
        name = data.getName()
        print("Received <<<<FlowMod data>>>>from Controller ")

        self.nodeid = OSCommand.getnodeid()

        # add this item to flow table.
        FlowModDataList = NdnFlowTable.parse_FlowMod_Data(payload)
        # print(FlowModDataList)
        NdnFlowTable.updatendnflowtable(FlowModDataList,self.nodeid)
        print(NdnFlowTable)


        del self.outstanding[name.toUri()]
        self.isDone = True
Exemplo n.º 13
0
 def __init__(self):
     self.nodeid = OSCommand.getnodeid()
     self.unknownprefixtable = set()
Exemplo n.º 14
0
 def __init__(self):
     self.keyChain = KeyChain()
     self.isDone = False
     self.nodeid = OSCommand.getnodeid()
     self.face = Face()
     self.featurereq = FeatureReq()