Пример #1
0
 def _check_remote_ifid(self, pcb: PathSegment) -> Optional[ISD_AS]:
     Requires(Acc(pcb.State(), 1 / 20))
     Ensures(Acc(pcb.State(), 1 / 20))
     """
     Checkes whether any PCB markings have unset remote IFID values for
     up/downstream ASes. This can happen during normal startup depending
     on the timing of PCB propagation vs IFID keep-alives, but should
     not happen once the infrastructure is settled.
     Remote IFID is only allowed to be 0 if the corresponding ISD-AS is
     0-0.
     """
     asms = pcb.iter_asms()
     for asm in asms:
         Invariant(Forall(asms, lambda a: (Acc(a.State(), 1 / 4), [])))
         pcbms = asm.iter_pcbms()
         for pcbm in pcbms:
             Invariant(Forall(pcbms, lambda p: (Acc(p.State(), 1 / 4), [])))
             if (pcbm.inIA().to_int() and not Unfolding(
                     Acc(pcbm.State(), 1 / 8),
                     Unfolding(Acc(pcbm.p.State(), 1 / 16), pcbm.p.inIF))):
                 return pcbm.inIA()
             if (pcbm.outIA().to_int() and not Unfolding(
                     Acc(pcbm.State(), 1 / 8),
                     Unfolding(Acc(pcbm.p.State(), 1 / 16), pcbm.p.outIF))):
                 return pcbm.outIA()
     return None
Пример #2
0
 def _setup(self):
     asms = []
     for i in range(3):
         pcbm = create_mock_full({"hof()": "hof %d" % i})
         asms.append(create_mock_full({"pcbm()": pcbm}))
     inst = PathSegment(None)
     inst.iter_asms = create_mock_full(return_value=asms)
     return inst
Пример #3
0
 def test_3(self, _):
     asms = []
     for i in range(3):
         asms.append(
             create_mock_full({"sig_pack()": bytes("asm %i" % i, "ascii")}))
     inst = PathSegment(create_mock_full({"info": b"info"}))
     inst.is_sibra = create_mock_full()
     inst.iter_asms = create_mock_full(return_value=asms)
     inst.sibra_ext = create_mock_full({"sig_pack()": b"sibraext"})
     expected = b"".join(
         [b"info", b"asm 0", b"asm 1", b"asm 2", b"sibraext"])
     # Call
     ntools.eq_(inst.sig_pack(3), expected)
Пример #4
0
    def _check_unwanted_ases(
            self, pcb: PathSegment) -> Optional[ISD_AS]:  # pragma: no cover
        Requires(Acc(pcb.State(), 1 / 20))
        Requires(Acc(self.State(), 1 / 8))
        Ensures(Acc(pcb.State(), 1 / 20))
        Ensures(Acc(self.State(), 1 / 8))
        """
        Checks whether any of the ASes in the path belong to the black list.

        :param pcb: beacon to analyze.
        :type pcb: :class:`PathSegment`
        """
        asms = pcb.iter_asms()
        for asm in asms:
            Invariant(Forall(asms, lambda a: (Acc(a.State(), 1 / 4), [])))
            Invariant(Acc(self.State(), 1 / 9))
            Invariant(Acc(pcb.State(), 1 / 20))
            isd_as = asm.isd_as()
            Unfold(Acc(self.State(), 1 / 10))
            if isd_as in self.unwanted_ases:
                Fold(Acc(self.State(), 1 / 10))
                return isd_as
            Fold(Acc(self.State(), 1 / 10))