Ejemplo n.º 1
0
 def __init__(self, rule, packet_bbuf):
     self.rule = rule
     #print('TileList()  Rule: ', rule)
     frag = rule["fragmentation"]
     ModProfil = frag["FRModeProfile"]
     tileSize = ModProfil["tileSize"]
     #print('tile size = ', tileSize)
     self.t_size = tileSize
     self.max_fcn = schcmsg.get_max_fcn(rule)
     self.all_tiles = []
     w_num = 0
     t_num = self.max_fcn
     # make tiles
     # XXX for now, the packet bitbuffer is going to be divided
     # into the tiles, which are a set of bit buffers too.
     # logically, it doesn't need when tileSize is well utilized.
     bbuf = packet_bbuf.copy()
     nb_full_size_tiles, last_tile_size = (bbuf.count_added_bits() //
                                           self.t_size,
                                           bbuf.count_added_bits() %
                                           self.t_size)
     assert last_tile_size >= 0
     tiles = [
         bbuf.get_bits_as_buffer(self.t_size)
         for _ in range(nb_full_size_tiles)
     ]
     if last_tile_size > 0:
         tiles.append(bbuf.get_bits_as_buffer(last_tile_size))
     # make a all_tiles
     for t in tiles:
         #print('w_num:', w_num,'  t_num:', t_num )
         tile_obj = {
             "w-num": w_num,
             "t-num": t_num,
             "tile": t,
             "sent": False,
         }
         self.all_tiles.append(tile_obj)
         if t_num == 0:
             t_num = self.max_fcn
             w_num += 1
         else:
             t_num -= 1
     if schcmsg.get_win_all_1(rule) < w_num:
         # win_all_1() is assumed to be equal to the max window number.
         raise ValueError("ERROR: the packet size > WSize. {} > {}".format(
             w_num, schcmsg.get_win_all_1(rule)))
     self.max_w_num = w_num
Ejemplo n.º 2
0
 def __init__(self, rule, packet_bbuf):
     self.rule = rule
     """Changement à corriger 
     self.t_size = ["tileSize"]
     """
     self.t_size = rule[T_FRAG][T_FRAG_PROF][T_FRAG_TILE]
     self.max_fcn = schcmsg.get_max_fcn(rule)
     self.all_tiles = []
     w_num = 0
     t_num = self.max_fcn
     # make tiles
     # XXX for now, the packet bitbuffer is going to be divided
     # into the tiles, which are a set of bit buffers too.
     # logically, it doesn't need when tileSize is well utilized.
     bbuf = packet_bbuf.copy()
     nb_full_size_tiles, last_tile_size = (bbuf.count_added_bits() //
                                           self.t_size,
                                           bbuf.count_added_bits() %
                                           self.t_size)
     assert last_tile_size >= 0
     tiles = [
         bbuf.get_bits_as_buffer(self.t_size)
         for _ in range(nb_full_size_tiles)
     ]
     if last_tile_size > 0:
         tiles.append(bbuf.get_bits_as_buffer(last_tile_size))
     # make a all_tiles
     for t in tiles:
         tile_obj = {
             "w-num": w_num,
             "t-num": t_num,
             "tile": t,
             "sent": False,
         }
         self.all_tiles.append(tile_obj)
         if t_num == 0:
             t_num = self.max_fcn
             w_num += 1
         else:
             t_num -= 1
     if schcmsg.get_win_all_1(rule) < w_num:
         # win_all_1() is assumed to be equal to the max window number.
         raise ValueError("ERROR: the packet size > WSize. {} > {}".format(
             w_num, schcmsg.get_win_all_1(rule)))
     self.max_w_num = w_num