示例#1
0
    def process_update_info(self, datapath, sw, update_next, init_sw, end_sw):
        ofproto = datapath.ofproto
        parser = datapath.ofproto_parser

        # src+1, dst+1 -> IPs
        src_ip = ipAdd(init_sw + 1)
        dst_ip = ipAdd(end_sw + 1)

        self.logger.debug("process update %s of flow between %s, %s" %
                          (update_next, src_ip, dst_ip))

        if update_next.type == constants.ADD_NEXT or update_next.type == constants.UPDATE_NEXT:

            out_port = self.topo[datapath.id][update_next.next_sw + 1]

            match = parser.OFPMatch(eth_type=ether_types.ETH_TYPE_IP,
                                    ipv4_src=src_ip,
                                    ipv4_dst=dst_ip)
            actions = [parser.OFPActionOutput(out_port)]

            self.add_flow(datapath, 2, match, actions)
            msg = NotificationMessage(sw, global_vars.ctrl,
                                      constants.UPDATED_MSG,
                                      update_next.seg_path_id,
                                      self.current_update,
                                      time() * 1000)
            self.handler.scheduler.enque_msg_to_notification_queue(sw, msg)
            # notification_queue.append(msg)
            #
            # self.no_of_pending_msgs[(datapath.id, self.current_notification_time[datapath.id])] += 1

        elif update_next.type == constants.REMOVE_NEXT:
            match = parser.OFPMatch(eth_type=ether_types.ETH_TYPE_IP,
                                    ipv4_src=src_ip,
                                    ipv4_dst=dst_ip)

            self.remove_flow(datapath, 2, match)
            msg = NotificationMessage(sw, global_vars.ctrl,
                                      constants.REMOVED_MSG,
                                      update_next.seg_path_id,
                                      self.current_update,
                                      time() * 1000)
            # notification_queue.append(msg)
            # self.no_of_pending_msgs[(datapath.id, self.current_notification_time[datapath.id])] += 1
            self.handler.scheduler.enque_msg_to_notification_queue(sw, msg)

        elif update_next.type == constants.NO_UPDATE_NEXT:
            pass  # Do nothing

        else:
            raise Exception("what type?")
示例#2
0
 def split_msgs(self, agg_msg):
     msgs = []
     for key in agg_msg.seg_path_ids.keys():
         for seg_path_id in agg_msg.seg_path_ids[key]:
             msgs.append(NotificationMessage(agg_msg.src_id, agg_msg.dst_id,
                                             key, seg_path_id, agg_msg.update_id,
                                             agg_msg.sending_time, agg_msg.receiving_time))
     return msgs
示例#3
0
 def create_new_msg_to_sw_with_id(self,
                                  dst_id,
                                  msg_type,
                                  seg_path_id,
                                  split_vol,
                                  send_to_other_segment=False):
     if msg_type != constants.COHERENT_MSG:
         new_msg = NotificationMessage(self.id, dst_id, msg_type,
                                       seg_path_id, self.current_update,
                                       time() * 1000)
         if not send_to_other_segment:
             l_segment = self.segments_by_seg_path_id[seg_path_id]
             if l_segment.vol == 0:  # Spliting means that after executing, there are some volume left for l_segment
                 new_msg.split_vol = split_vol
     else:
         new_msg = NotificationMessage(self.id, dst_id, msg_type,
                                       seg_path_id, self.current_update,
                                       time() * 1000)
     return new_msg