コード例 #1
0
 def set_packet(self, packet_bbuf):
     super().set_packet(packet_bbuf)
     self.all_tiles = TileList(self.rule, packet_bbuf)
     # XXX
     # check whether the size of the last tile is less than L2 word
     # AND the tile number is zero
     # because draft-17 doesn't specify how to handle it.
     a = self.all_tiles.get_all_tiles()
     if (a[-1]["t-num"] == 0 and
             a[-1]["tile"].count_added_bits() < self.rule["L2WordSize"]):
         raise ValueError(
             "The size of the last tile with the tile number 0 must be equal to or greater than L2 word size."
         )
     # make the bitmap
     #self.bit_list = make_bit_list(self.all_tiles.get_all_tiles(),
     #                              self.rule["FCNSize"],
     #                              schcmsg.get_fcn_all_1(self.rule))
     self.bit_list = make_bit_list(self.all_tiles.get_all_tiles(),
                                   self.rule["FCNSize"], self.rule["WSize"])
     print("bit_list:", self.bit_list)
     for tile in self.all_tiles.get_all_tiles():
         print("w: {}, t: {}, sent: {}".format(tile['w-num'], tile['t-num'],
                                               tile['sent']))
     self.all1_send = False
     self.num_of_windows = 0
     for pos in self.bit_list:
         print("bitmap: {}, length:{}".format(self.bit_list[pos],
                                              len(self.bit_list[pos])))
         if len(self.bit_list[pos]) is not 0:
             self.num_of_windows += 1
     print("number of windows = {}".format(self.num_of_windows))
コード例 #2
0
 def set_packet(self, packet_bbuf):
     super().set_packet(packet_bbuf)
     self.all_tiles = TileList(self.rule, packet_bbuf)
     #print('all tils : ')
     #print(self.all_tiles.get_all_tiles())
     # XXX
     # check whether the size of the last tile is less than L2 word
     # AND the tile number is zero
     # because draft-17 doesn't specify how to handle it.
     #print('set_packet RULE: ',self.rule)
     profile = self.rule["profile"]
     L2WordSize = profile["L2WordSize"]
     print('L2WordSize: ', L2WordSize)
     a = self.all_tiles.get_all_tiles()
     #print('all tiles: ', a)
     if (a[-1]["t-num"] == 0
             and a[-1]["tile"].count_added_bits() < L2WordSize):
         raise ValueError(
             "The size of the last tile with the tile number 0 must be equal to or greater than L2 word size."
         )
     # make the bitmap
     frag = self.rule["fragmentation"]
     Mode = frag["FRModeProfile"]
     FCNSize = Mode["FCNSize"]
     self.bit_list = make_bit_list(self.all_tiles.get_all_tiles(), FCNSize,
                                   schcmsg.get_fcn_all_1(self.rule))
コード例 #3
0
 def set_packet(self, packet_bbuf):
     super().set_packet(packet_bbuf)
     self.all_tiles = TileList(self.rule, packet_bbuf)
     # XXX
     # check whether the size of the last tile is less than L2 word
     # AND the tile number is zero
     # because draft-17 doesn't specify how to handle it.
     a = self.all_tiles.get_all_tiles()
     if (a[-1]["t-num"] == 0 and
             a[-1]["tile"].count_added_bits() < self.rule["L2WordSize"]):
         raise ValueError(
             "The size of the last tile with the tile number 0 must be equal to or greater than L2 word size."
         )
     # make the bitmap
     self.bit_list = make_bit_list(self.all_tiles.get_all_tiles(),
                                   self.rule["FCNSize"],
                                   schcmsg.get_fcn_all_1(self.rule))
     print("bit_list:", self.bit_list)
コード例 #4
0
ファイル: test_bitmap.py プロジェクト: sandoche2k/openschc
def test_fragment_bitmap_01():
    print("## bit list")
    tile_list = [
                { "w-num": 0, "t-num": 6, "nb_tiles": 3 },
                { "w-num": 0, "t-num": 3, "nb_tiles": 4 },
                { "w-num": 1, "t-num": 6, "nb_tiles": 3 },
                { "w-num": 1, "t-num": 3, "nb_tiles": 3 },
                { "w-num": 3, "t-num": 5, "nb_tiles": 2 },
                { "w-num": 3, "t-num": 7, "nb_tiles": 1 },
            ]
    bit_list = make_bit_list(tile_list, 3, 7)
    expected_list = {
        0: [1, 1, 1, 1, 1, 1, 1],
        1: [1, 1, 1, 1, 1, 1, 0],
        2: [0, 0, 0, 0, 0, 0, 0],
        3: [0, 1, 1, 0, 0, 0, 1],
        }

    for i in bit_list.items():
        print(i)
    assert bit_list == expected_list
コード例 #5
0
        for j in range(i[1].count_added_bits()):
            bm.append(i[1].get_bits(1, j))
        bitmap_str = lambda x: "".join("{}".format(_) for _ in x)
        print("\t{{ w:{} bm:{} }}".format(i[0], bitmap_str(bm)))
    assert str(bitmaps) == str(expected)

print("## bit list")
tile_list = [
            { "w-num": 0, "t-num": 6, "nb_tiles": 3 },
            { "w-num": 0, "t-num": 3, "nb_tiles": 4 },
            { "w-num": 1, "t-num": 6, "nb_tiles": 3 },
            { "w-num": 1, "t-num": 3, "nb_tiles": 3 },
            { "w-num": 3, "t-num": 5, "nb_tiles": 2 },
            { "w-num": 3, "t-num": 7, "nb_tiles": 1 },
        ]
bit_list = make_bit_list(tile_list, 3, 7)
expected_list = {
    0: [1, 1, 1, 1, 1, 1, 1],
    1: [1, 1, 1, 1, 1, 1, 0],
    2: [0, 0, 0, 0, 0, 0, 0],
    3: [0, 1, 1, 0, 0, 0, 1],
    }

for i in bit_list.items():
    print(i)
assert bit_list == expected_list

#
print("## find_missing_tiles:")
bitmaps = find_missing_tiles(tile_list, 3, 7)
expected = [