예제 #1
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)
예제 #2
0
파일: global.py 프로젝트: JasonatBuaa/Ez
 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)
예제 #3
0
 def tag2_add_flows(self,f):
     self.logger.info(" in tag 2")
     aggre_dict = {}
     f.up_step = consts.TAG_NEW_TAG
     to_add = self.tag_flows_temp[f.flow_id]['to_add']
     if(len(to_add) == 0):
         self.tag3_push_new(f)
         return
     aggre_dict = tools.flowkey_to_ctrlkey(aggre_dict,self.dp_to_local,f.flow_id,to_add,[])
     self.make_and_send_info(aggre_dict,False)
예제 #4
0
 def tag4_del_old(self,f):
     self.logger.info(" in tag 4")
     f.up_step = consts.TAG_DEL_OLD
     aggre_dict = {}
     # to_del = self.tag_flows_temp[f.flow_id]['to_del']
     to_del = self.tag_flows_temp[f.flow_id]['raw_to_del']
     if(len(to_del) == 0):
         self.tag5_mod_new(f)
         return
     aggre_dict = tools.flowkey_to_ctrlkey(aggre_dict,self.dp_to_local,f.flow_id,[],to_del)
     self.make_and_send_info(aggre_dict,True)
예제 #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 tag5_mod_new(self,f):
     aggre_dict = {}
     f.up_step = consts.TAG_MOD_NEW
     self.logger.info("in tag 5")
     self.logger.info(self.flows_new)
     # to_add = self.flows_new[f.flow_id]['to_add']
     to_add = self.tag_flows_temp[f.flow_id]['raw_to_add']
     if(len(to_add) == 0):
         self.tag6_push_del(f)
         return
     aggre_dict = tools.flowkey_to_ctrlkey(aggre_dict,self.dp_to_local,f.flow_id,to_add,[])
     self.make_and_send_info(aggre_dict,False)
예제 #7
0
파일: global.py 프로젝트: JasonatBuaa/Ez
 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)
예제 #8
0
파일: global.py 프로젝트: JasonatBuaa/Ez
 def buf_del(self, flows={}):
     aggre_dict = {}
     # for f_id,f in self.flows_new.items():
     for f_id, f in flows.items():
         f.up_type = consts.BUF
         f.up_step = consts.BUF_DEL
         to_buf = self.find_buf_dp(f)
         self.logger.info("to buf is")
         self.logger.info(to_buf)
         l, dp, n = to_buf
         f.ctrl_buf = self.dp_to_local[dp]
         aggre_dict = tools.flowkey_to_ctrlkey(aggre_dict, self.dp_to_local,
                                               f_id, [], [to_buf])
     self.logger.info(aggre_dict)
     self.make_and_send_info(aggre_dict)
예제 #9
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())
예제 #10
0
    def buf_del(self,flows={}):
        aggre_dict = {}
        # for f_id,f in self.flows_new.items():
        for f_id,f in flows.items():
            f.up_type = consts.BUF
            f.up_step = consts.BUF_DEL
            to_buf = self.find_buf_dp(f)
            l,dp,n = to_buf
            f.ctrl_buf = self.dp_to_local[dp]
            self.logger.info("flow_id"+str(f.flow_id))
            self.logger.info("ctrl_buf" + str(f.ctrl_buf))
            aggre_dict = tools.flowkey_to_ctrlkey(aggre_dict,self.dp_to_local,f_id,[],[to_buf])
            self.logger.info("her is buf del")
            self.logger.info(self.flows_to_schedule)
            self.started_update_to_flows_new(f)

        self.logger.info(aggre_dict)
        self.make_and_send_info(aggre_dict,False)
예제 #11
0
 def tag7_pop_del(self,f):
     self.logger.info(" in tag 7")
     f.up_step = consts.TAG_POP_DEL
     aggre_dict = {}
     # to_del = self.flows_new[f.flow_id]['to_add']
     # self.logger.info("!!!!!!!!!!!!!!!!!!in tag 7")
     self.logger.info("tag_flows_temp")
     self.logger.info(self.tag_flows_temp)
     to_del = self.tag_flows_temp[f.flow_id]['raw_to_add']
     if(len(to_del) == 0):
         self.logger.info("update over by tag")
         # self.finished_update_to_flows(f)
         # self.tag_flows_temp = {}
         return
     aggre_dict = tools.flowkey_to_ctrlkey(aggre_dict,self.dp_to_local,f.flow_id,[],to_del)
     self.logger.info("let's see tag step 7's bug haha")
     self.logger.info(aggre_dict)
     
     self.make_and_send_info(aggre_dict,True)
예제 #12
0
파일: global.py 프로젝트: JasonatBuaa/Ez
    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")
예제 #13
0
파일: global.py 프로젝트: JasonatBuaa/Ez
    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?")