Ejemplo n.º 1
0
    def _handle_barrier(self, ev):
        to_switches = {}
        # if self.receiving_update_time is not None:
        #     current_time = time() * 1000
        #     self.logger.info("receiving barrier at %s" % str(current_time - self.receiving_update_time))
        # sent_this_time = list(self.notification_queue)
        while len(self.notification_queue) > 0:
            msg = self.notification_queue.popleft()
            if not to_switches.has_key(msg.dst_id):
                to_switches[msg.dst_id] = [AggregatedMessage(msg.src_id, msg.dst_id, msg.msg_type, [],
                                                            msg.update_id)]
            l_len = len(to_switches[msg.dst_id])
            len_msg = 0
            for l_msg in to_switches[msg.dst_id][l_len - 1].seg_path_ids.values():
                len_msg += len(l_msg)
            if len_msg > 30:
                to_switches[msg.dst_id].append(AggregatedMessage(msg.src_id, msg.dst_id, msg.msg_type, [],
                                                        msg.update_id))

            if not to_switches[msg.dst_id][l_len-1].seg_path_ids.has_key(msg.msg_type):
                to_switches[msg.dst_id][l_len-1].seg_path_ids[msg.msg_type] = [msg.seg_path_id]
            else:
                to_switches[msg.dst_id][l_len-1].seg_path_ids[msg.msg_type].append(msg.seg_path_id)
            # if not to_switches.has_key((msg.dst_id, msg.msg_type)):
            #     to_switches[(msg.dst_id, msg.msg_type)] = [msg]
            # else:
            #     to_switches[(msg.dst_id, msg.msg_type)].append(msg)

        # agg_msgs = {}
        for l_msg in to_switches.values():
            for msg in l_msg:
                # agg_msg = self.aggregate_msgs(to_switches[(dst, msg_type)])
                # self.logger.debug("message: %s" % str(agg_msg))
                self.send_msg(self.datapath, msg)
Ejemplo n.º 2
0
 def aggregate_msgs(self, msgs):
     f_msg = msgs[0]
     agg_msg = AggregatedMessage(f_msg.src_id, f_msg.dst_id, f_msg.msg_type,
                                 [], f_msg.update_id)
     for msg in msgs:
         agg_msg.seg_path_ids.append(msg.seg_path_id)
     return agg_msg
Ejemplo n.º 3
0
import sys
import six
sys.path.append('./simulator')
from domain.message import AggregatedMessage

from ryu.lib.packet import packet
# from ryu.lib.packet import ipv4
from ryu.lib.packet import ethernet, ipv4, udp
from ryu.lib.packet import ether_types
from ryu.ofproto import ether
from ryu.lib.packet.in_proto import IPPROTO_UDP
import struct
# #src=4,dst=3,Good_TO_MOVE:[]
rcved = b"\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x05\x08\x00E\x00\x01|\x00\x00\x00\x00\xff\x11\xbah\x00\x00\x00\x05\x00\x00\x00\x04\x19\xdc\x19\xdc\x01h\xc9]\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00(idomain.message\nAggregatedMessage\np1\n(dp2\nS'src_id'\np3\nI4\nsS'receiving_time'\np4\nNsS'dst_id'\np5\nI3\nsS'seg_path_ids'\np6\n(dp7\nI0\n(lp8\n(I33\nI0\ntp9\na(I100\nI0\ntp10\na(I37\nI0\ntp11\na(I39\nI0\ntp12\na(I73\nI0\ntp13\na(I57\nI0\ntp14\na(I75\nI0\ntp15\na(I53\nI0\ntp16\na(I55\nI0\ntp17\na(I25\nI0\ntp18\na(I71\nI0\ntp19\nassS'update_id'\np20\nI0\nsS'sending_time'\np21\nF1611211334769.9412\nsb."
# rc = b"(idomain.message\nAggregatedMessage\np1\n(dp2\nS'src_id'\np3\nI4\nsS'receiving_time'\np4\nNsS'dst_id'\np5\nI3\nsS'seg_path_ids'\np6\n(dp7\nI0\n(lp8\n(I33\nI0\ntp9\na(I100\nI0\ntp10\na(I37\nI0\ntp11\na(I39\nI0\ntp12\na(I73\nI0\ntp13\na(I57\nI0\ntp14\na(I75\nI0\ntp15\na(I53\nI0\ntp16\na(I55\nI0\ntp17\na(I25\nI0\ntp18\na(I71\nI0\ntp19\nassS'update_id'\np20\nI0\nsS'sending_time'\np21\nF1611211334769.9412\nsb."
t = AggregatedMessage('3','2',0,[(150, 0), (152, 0)],10000)
# # a = t.decode('ascii')
# t.receiving_time = 19191919191991
td =pickle.dumps(t)


# test = AggregatedMessage(3,4,'GOOD_TO_MOVE','[(33, 0), (100, 0), (37, 0), (39, 0), (73, 0), (57, 0), (75, 0), (53, 0), (55, 0), (25, 0), (71, 0)]',0)
# # # tdcpk = pk.dumps(t)
# # print(td)
# # # #print(binascii.hexlify(td))
# # print(pickle.loads(rc))
# # # # print(tdcpk)
# # print(str(pickle.loads(td)))
# # strpprcvd = rcved.strip(b'\x00')
# # spl = rcved.split('(')
# # spl[0] = ''