Пример #1
0
 def find_packet_tag_dp(self, f):
     to_add, to_del = tools.diff_old_new(f.old, f.new)
     to_add_bak, to_del_bak = tools.diff_old_new(f.new, [])
     dp_tup = to_del[0] if to_del else to_del_bak[0]
     to_add, to_del = tools.diff_old_new(list(reversed(f.old)),
                                         list(reversed(f.new)))
     to_add_bak, to_del_bak = tools.diff_old_new(list(reversed(f.new)), [])
     dp_tup_reverse = to_del[0] if to_del else to_del_bak[0]
     return dp_tup, dp_tup_reverse
Пример #2
0
 def find_buf_dp(self,f):
     to_add, to_del = tools.diff_old_new(f.old,f.new)
     self.logger.info(to_del)
     to_add_bak,to_del_bak = tools.diff_old_new(f.new,[])
     self.logger.info("where to buf")
     
     where_to_buf =  to_del[0] if to_del else to_del_bak[0]  
     self.logger.info(where_to_buf)  
     return where_to_buf
Пример #3
0
    def tag0(self,flows={}):
        aggre_dict = {}
        for f_id, f in flows.items():
            f.up_type = consts.TAG
            f.up_step = 0
            to_add,to_del = tools.diff_old_new(f.old,f.new)
            raw_to_add,raw_to_del = self.deepcp_to_deal(to_add),self.deepcp_to_deal(to_del)
            aggre_dict = tools.flowkey_to_ctrlkey(aggre_dict,self.dp_to_local,f_id,to_add,to_del)
            left,right = None,None #the points who pop packets' vid
            
            try:
                right = to_add[-1]
                to_add.pop(-1)
            except:
                self.logger.info("right wrong")

            try:
                left = to_add[0]
                to_add.pop(0)
            except:
                self.logger.info("left wrong")
            
            self.tag_flows_temp.update({f_id:{'to_add':to_add,'to_del':to_del,
                                        'left':left,'right':right,
                                        'raw_to_add':raw_to_add,'raw_to_del':raw_to_del}})

        self.logger.info(" tag0")
        self.logger.info(self.tag_flows_temp)
        self.make_and_send_info(aggre_dict,False)
        for f_id, f in flows.items():
            self.started_update_to_flows_new(f)
Пример #4
0
 def raw_update(self, flows={}):
     aggre_dict = {}
     for f_id, f in flows.items():
         f.up_type = consts.RAW
         f.up_step = consts.RAW_INSTALL
         to_add, to_del = tools.diff_old_new(f.old, f.new)
         aggre_dict = tools.flowkey_to_ctrlkey(aggre_dict, self.dp_to_local,
                                               f_id, to_add, to_del)
         self.make_and_send_info(aggre_dict)
Пример #5
0
 def raw_update(self,flows={}):
     aggre_dict = {}
     for f_id,f in flows.items():
         f.up_type = consts.RAW
         f.up_step = consts.RAW_INSTALL
         to_add, to_del = tools.diff_old_new(f.old,f.new)
         self.logger.info("let's see raw update bug")
         self.logger.info(to_add)
         self.logger.info(to_del)
         aggre_dict = tools.flowkey_to_ctrlkey(aggre_dict,self.dp_to_local,f_id,to_add,to_del)
         self.make_and_send_info(aggre_dict,False)
         self.started_update_to_flows_new(f)
Пример #6
0
 def tag_add(self, flows={}):
     aggre_dict = {}
     # for f_id,f in self.flows_new.items():
     for f_id, f in flows.items():
         f.up_type = consts.TAG
         f.up_step = consts.TAG_ADD
         f.version_tag = self.find_version_tag(f)
         to_add, to_del = tools.diff_old_new(f.old, f.new)
         aggre_dict = tools.flowkey_to_ctrlkey(aggre_dict, self.dp_to_local,
                                               f_id, to_add, [])
     self.logger.info(aggre_dict)
     self.make_and_send_info(aggre_dict)
Пример #7
0
    def buf_fb_process(self,f_id):
        aggre_dict = {}
        f = self.flows_new[f_id]
        f.ctrl_ok += 1
        self.logger.info("-------in buf fb process")
        self.logger.info(f.up_step)
        self.logger.info("ctrl_ok" + str(f.ctrl_ok))
        self.logger.info("ctrl_wait" + str(f.ctrl_wait))
        if(len(f.ctrl_wait) == f.ctrl_ok):
            f.ctrl_wait = []
            f.ctrl_ok = 0
            if(f.up_step == consts.BUF_DEL):
                self.logger.info("buf del over")
                f.up_step = consts.BUF_ADD
                to_add, to_del = tools.diff_old_new(f.old,f.new)
                aggre_dict = tools.flowkey_to_ctrlkey(aggre_dict,self.dp_to_local,f_id,to_add,to_del)
                # self.logger.info(aggre_dict)
                self.make_and_send_info(aggre_dict,False)
                
            elif(f.up_step == consts.BUF_ADD):
                self.logger.info("buf add over")
                f.up_step = consts.BUF_RLS
                #firstly we send cmd to the ctrls who bufed,but why?? why some buffed from other dps?
                # info = InfoMessage(f.ctrl_buf)
                # um = UpdateMessageByFlow(f_id,f.up_type,f.up_step)
                # info.ums.append(um)
                # self.send_to_local(f.ctrl_buf,info)
                # f.ctrl_wait.append(f.ctrl_buf)
                #now we let all ctrls to sendback,but why????
                for ctrl in self.locals:
                    info = InfoMessage(ctrl)
                    um = UpdateMessageByFlow(f_id,f.up_type,f.up_step)
                    info.ums.append(um)
                    self.send_to_local(ctrl,info)
                    f.ctrl_wait.append(ctrl)

            elif(f.up_step == consts.BUF_RLS):
                f.up_step = None
                f.up_type = None
                f.ctrl_buf = None
                self.logger.info(f.flow_id)
                self.logger.info("updated over by buf")
                self.finished_update_to_flows(f)
                self.logger.info("------------------------buf over time--------------")
                self.logger.info(nowTime())
Пример #8
0
    def buf_fb_process(self, f_id):
        aggre_dict = {}
        f = self.flows_new[f_id]
        f.ctrl_ok += 1
        self.logger.info(f.up_step)
        if (len(f.ctrl_wait) == f.ctrl_ok):
            f.ctrl_wait = []
            f.ctrl_ok = 0
            if (f.up_step == consts.BUF_DEL):
                self.logger.info("buf del over")
                f.up_step = consts.BUF_ADD
                to_add, to_del = tools.diff_old_new(f.old, f.new)
                aggre_dict = tools.flowkey_to_ctrlkey(aggre_dict,
                                                      self.dp_to_local, f_id,
                                                      to_add, to_del)
                self.logger.info(aggre_dict)
                self.make_and_send_info(aggre_dict)

            elif (f.up_step == consts.BUF_ADD):
                self.logger.info("buf add over")
                f.up_step = consts.BUF_RLS
                info = InfoMessage(f.ctrl_buf)
                um = UpdateMessageByFlow(f_id, f.up_type, f.up_step)
                info.ums.append(um)
                self.send_to_local(f.ctrl_buf, info)
                f.ctrl_wait.append(f.ctrl_buf)

            elif (f.up_step == consts.BUF_RLS):
                f.up_step = None
                f.up_type = None
                f.ctrl_buf = None
                self.logger.info(f.flow_id)
                self.logger.info("updated over by buf")
                self.finished_update_to_flows(f)
                self.logger.info(nowTime())
        else:
            print("something wrong")
Пример #9
0
 def find_buf_dp(self, f):
     to_add, to_del = tools.diff_old_new(f.old, f.new)
     self.logger.info(to_del)
     to_add_bak, to_del_bak = tools.diff_old_new(f.new, [])
     return to_del[0] if to_del else to_del_bak[0]
Пример #10
0
    def tag_fb_process(self, f_id):
        self.logger.info("in tag fb")
        f = self.flows_new[f_id]
        f.ctrl_ok += 1
        self.logger.info(f.up_step)
        if (len(f.ctrl_wait) == f.ctrl_ok):
            f.ctrl_wait = []
            f.ctrl_ok = 0
            if (f.up_step == consts.TAG_ADD):
                self.logger.info("tag add finished")
                f.up_step = consts.TAG_TAG
                dp_tup, dp_tup_reverse = self.find_packet_tag_dp(f)
                # l,dpid,n =dp_tup
                # l,dpid_reverse,n = dp_tup_reverse
                # self.send_pkg_tag_cmd(f,dpid,False)
                # self.send_pkg_tag_cmd(f,dpid_reverse,True)
                self.send_pkg_tag_cmd(f, dp_tup, False)
                self.send_pkg_tag_cmd(f, dp_tup_reverse, True)
                self.logger.info(f.ctrl_wait)

            elif (f.up_step == consts.TAG_TAG):
                self.logger.info("tag tag finished")
                f.up_step = consts.TAG_DEL
                to_add, to_del = tools.diff_old_new(f.old, f.new)
                if (len(to_del) > 0):
                    aggre_dict = tools.flowkey_to_ctrlkey(
                        aggre_dict, self.dp_to_local, f_id, [], to_del)
                    self.make_and_send_info(aggre_dict)
                else:
                    info = InfoMessage(f.ctrl_tag)
                    um = UpdateMessageByFlow(f_id, f.up_type, f.up_step)
                    info.ums.append(um)
                    self.send_to_local(f.ctrl_tag, info)
                    f.ctrl_wait.append(f.ctrl_tag)
                self.logger.info("tag_del sent")
            elif (f.up_step == consts.TAG_DEL):
                self.logger.info("tag del finished")
                self.logger.info(nowTime())
                f.up_step = consts.TAG_MOD
                # l,dpid,n = self.find_packet_tag_dp(f)
                # f.ctrl_tag = self.dp_to_local[dpid]
                info = InfoMessage(f.ctrl_tag)
                um = UpdateMessageByFlow(f_id, f.up_type, f.up_step)
                info.ums.append(um)
                self.send_to_local(f.ctrl_tag, info)

                info = InfoMessage(f.ctrl_tag_reverse)
                um = UpdateMessageByFlow(f_id, f.up_type, f.up_step)
                um.if_reverse = True
                info.ums.append(um)
                self.send_to_local(f.ctrl_tag_reverse, info)

                f.ctrl_wait.append(f.ctrl_tag)
                f.ctrl_wait.append(f.ctrl_tag_reverse)

    #from here should be rewrited
            elif (f.up_step == consts.TAG_MOD):
                self.logger.info("tag notag finished")
                f.up_step = consts.TAG_UNTAG
                # l,dpid,n = self.find_packet_tag_dp(f)
                # f.ctrl_tag = self.dp_to_local[dpid]
                info = InfoMessage(f.ctrl_tag)
                um = UpdateMessageByFlow(f_id, f.up_type, f.up_step)
                info.ums.append(um)
                self.send_to_local(f.ctrl_tag, info)
                f.ctrl_wait.append(f.ctrl_buf)

            elif (f.up_step == consts.TAG_UNTAG):
                f.up_step = None
                f.up_type = None
                f.ctrl_tag = None
                self.logger.info(f.flow_id)
                self.logger.info("updated over by tag")
                finished_update_to_flows(f)
            else:
                self.logger.info("what type?")