示例#1
0
 def test(self):
     inst = LinkBandwidth("owner", BWSnapshot(100, 100))
     for i, bw in enumerate([50, 0, -10, -20, 0, 0, -20]):
         inst.resvs[i] = BWSnapshot(bw, bw)
     updates = []
     for idx, bw in [(0, -10), (1, -10), (2, +10), (6, 10)]:
         updates.append((idx, BWSnapshot(bw, bw)))
     # Call
     inst.update(updates)
     # Tests
     for i, bw in enumerate([40, -10, 0, -20, 0, 0, -10]):
         tick = BWSnapshot(bw, bw)
         ntools.eq_(inst.resvs[i], tick)
示例#2
0
 def test(self):
     inst = SteadyReservation("owner", BWSnapshot(100, 100), "parent")
     inst.max_bw = BWSnapshot(100, 100)
     for i, bw in enumerate([50, 0, -10, -20, 0, 0, -20]):
         inst.child_resvs[i] = BWSnapshot(bw, bw)
     updates = []
     for idx, bw in [(0, -10), (1, -10), (2, +10), (6, 10)]:
         updates.append((idx, BWSnapshot(bw, bw)))
     # Call
     inst.update(updates)
     # Tests
     for i, bw in enumerate([40, -10, 0, -20, 0, 0, -10]):
         tick = BWSnapshot(bw, bw)
         ntools.eq_(inst.child_resvs[i], tick)
示例#3
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.bw_cls = BWSnapshot(1000 * 1024, 2000 * 1024).to_classes().ceil()
     self.block = None
     self.setup_ts = 0
     self.setup_tries = 3
     self.eph_id = SibraExtEphemeral.mk_path_id(self.addr.isd_as)
示例#4
0
 def _process_use(self, meta):
     """
     Process a packet using a SIBRA reservation.
     Update the appropriate usage counters, and determine the next hop.
     """
     bw_used = BWSnapshot(len(meta.spkt) * 8)
     if not meta.dir_fwd:
         bw_used.reverse()
     logging.debug("SIBRA use (Steady? %s)", self.steady)
     if not meta.state.use(self.path_ids[0],
                           self.active_blocks[self.block_idx].info.index,
                           bw_used, self.steady):
         return [(RouterFlag.ERROR, "SIBRA packet rejected")]
     next_ifid = self.get_next_ifid()
     if next_ifid:
         return [(RouterFlag.FORWARD, next_ifid)]
     return [(RouterFlag.DELIVER, )]
示例#5
0
 def __init__(self, bw, link_name):  # pragma: no cover
     self.curr_tick = current_tick()
     self.link = LinkBandwidth(link_name, BWSnapshot(bw * 1024, bw * 1024))
     self.steady = {}
     self.pend_steady = {}
     self.ephemeral = {}
     self.pend_ephemeral = {}
     self.pending = {}
     logging.info("Initialized SibraState: %s", self.link)
示例#6
0
 def _check(self, old_resvs, resvs, updates, super_init):
     inst = ReservationBaseTesting("path id", "owner", "parent")
     inst.parent = create_mock(["update"])
     inst.resvs = []
     for bw in old_resvs:
         inst.resvs.append(BWSnapshot(bw * 1024, bw * 1024))
     for idx, exp_tick, bw in resvs:
         inst.order.append(idx)
         resv = create_mock(["bwsnap", "exp_tick"])
         resv.bwsnap = BWSnapshot(bw * 1024, bw * 1024)
         resv.exp_tick = exp_tick
         inst.idxes[idx] = resv
     # Call
     inst._update(0)
     # Tests
     if not updates:
         ntools.eq_(inst.parent.update.called, False)
         return
     parent_updates = []
     for idx, bw in updates:
         parent_updates.append((idx, BWSnapshot(bw * 1024, bw * 1024)))
     inst.parent.update.assert_called_once_with(parent_updates)
示例#7
0
文件: main.py 项目: stschwar/scion
 def _steady_add(self, isd_as):
     seg = self._pick_seg(isd_as)
     if not seg:
         del self.dests[isd_as]
         return
     ifid = seg.last_hof().ingress_if
     link_state = self.link_states[ifid]
     link_type = self.link_types[ifid]
     # FIXME(kormat): un-hardcode these bandwidths
     bwsnap = BWSnapshot(500 * 1024, 500 * 1024)
     steady = SteadyPath(self.addr, self._port, self.sendq, self.signing_key,
                         link_type, link_state, seg, bwsnap)
     self.dests[isd_as][steady.id] = steady
     logging.debug("Setting up steady path %s -> %s over %s",
                   self.addr.isd_as, isd_as, seg.short_desc())
     steady.setup()
示例#8
0
 def teardown(self):  # pragma: no cover
     """Shut down the current reservation."""
     # FIXME(kormat): not implemented yet in sibra state.
     req_info = ResvInfoSteady.from_values(0, BWSnapshot(), 0)
     self.req_block = ResvBlockSteady.from_values(req_info, self.total_hops)
     self._set_size()