hpimdm/tree/tree_if_non_root.py
def calculate_assert_winner(self, creating_interface=False):
        """
        Calculate the router responsible for forwarding data packets to a link...
        Based on this calculation, the Assert state is set
        If tree in Active state and this interface offers a better Assert state compared to all neighbors
            then this interface transitions to AssertWinner state
        If tree in Active state and the BestUpstream neighbor offers a better Assert state (RPC and IP)
            then this interface must transition to AssertLoser state
        If tree in Unsure state and there are no Upstream neighbors connected to this interface
            then this interface transitions to AssertWinner state
        If tree in Unsure state and there are Upstream neighbors connected to this interface
            then this interface transitions to AssertLoser state
        If tree in Inactive state then interface must be in AssertWinner state
        """
        print("CALCULATE ASSERT WINNER")
        if self.is_tree_active():
            if self._best_upstream_router is None:
                self.assert_logger.debug('BEST UPSTREAM NEIGHBOR IS NONE AND TREE IS ACTIVE')
                self.set_assert_state(AssertState.Winner, creating_interface)
            elif self._my_assert_rpc.is_better_than(self._best_upstream_router):
                self.assert_logger.debug('TREE IS ACTIVE AND WON ASSERT')
                self.assert_logger.debug("BEST UPSTREAM NEIGHBOR METRIC_PREFERENCE: " +
                                         str(self._best_upstream_router.metric_preference) + '; METRIC: ' +
                                         str(self._best_upstream_router.route_metric) + '; IP: ' +
                                         self._best_upstream_router.get_ip())
                self.assert_logger.debug("MY METRIC_PREFERENCE: " + str(self._my_assert_rpc.metric_preference) +
                                         '; METRIC: ' + str(self._my_assert_rpc.route_metric) + '; IP: ' +
                                         self._my_assert_rpc.get_ip())
                self.set_assert_state(AssertState.Winner, creating_interface)
            else:
                self.assert_logger.debug('TREE IS ACTIVE AND LOST ASSERT')
                self.assert_logger.debug("BEST UPSTREAM NEIGHBOR METRIC_PREFERENCE: " +
                                         str(self._best_upstream_router.metric_preference) + '; METRIC: ' +
                                         str(self._best_upstream_router.route_metric) + '; IP: ' +
                                         self._best_upstream_router.get_ip())
                self.assert_logger.debug("MY METRIC_PREFERENCE: " + str(self._my_assert_rpc.metric_preference) +
                                         '; METRIC: ' + str(self._my_assert_rpc.route_metric) + '; IP: ' +
                                         self._my_assert_rpc.get_ip())
                self.set_assert_state(AssertState.Loser, creating_interface)
        elif self.is_tree_unsure():
            if self._best_upstream_router is None:
                self.assert_logger.debug('TREE IS UNSURE AND NO UPSTREAM NEIGHBOR')
                self.set_assert_state(AssertState.Winner)
            else:
                self.assert_logger.debug('TREE IS UNSURE AND UPSTREAM NEIGHBOR CONNECTED TO THIS INTERFACE')
                self.set_assert_state(AssertState.Loser, creating_interface)
        else:
            self.assert_logger.debug('TREE IS INACTIVE AND UPSTREAM NEIGHBOR CONNECTED TO THIS INTERFACE')
            self.set_assert_state(AssertState.Winner, creating_interface)

        Calculate the router responsible for forwarding data packets to a link...
        Based on this calculation, the Assert state is set
        If tree in Active state and this interface offers a better Assert state compared to all neighbors
            then this interface transitions to AssertWinner state
        If tree in Active state and the BestUpstream neighbor offers a better Assert state (RPC and IP)
            then this interface must transition to AssertLoser state
        If tree in Unsure state and there are no Upstream neighbors connected to this interface
            then this interface transitions to AssertWinner state
        If tree in Unsure state and there are Upstream neighbors connected to this interface
            then this interface transitions to AssertLoser state
        If tree in Inactive state then interface must be in AssertWinner state
        
Calculate the router responsible for forwarding data packets to a link
Based on this calculation, the Assert state is set
If tree in Active state and this interface offers a better Assert state compared to all neighbors
then this interface transitions to AssertWinner state
If tree in Active state and the BestUpstream neighbor offers a better Assert state (RPC and IP)
then this interface must transition to AssertLoser state
If tree in Unsure state and there are no Upstream neighbors connected to this interface
then this interface transitions to AssertWinner state
If tree in Unsure state and there are Upstream neighbors connected to this interface
then this interface transitions to AssertLoser state
If tree in Inactive state then interface must be in AssertWinner state
Calculate the router responsible for forwarding data packets to a link Based on this calculation the Assert state is set If tree in Active state and this interface offers a better Assert state compared to all neighbors then this interface transitions to AssertWinner state If tree in Active state and the BestUpstream neighbor offers a better Assert state ( RPC and IP ) then this interface must transition to AssertLoser state If tree in Unsure state and there are no Upstream neighbors connected to this interface then this interface transitions to AssertWinner state If tree in Unsure state and there are Upstream neighbors connected to this interface then this interface transitions to AssertLoser state If tree in Inactive state then interface must be in AssertWinner state
def calculate_assert_winner(self, creating_interface=False):
        print("CALCULATE ASSERT WINNER")
        if self.is_tree_active():
            if self._best_upstream_router is None:
                self.assert_logger.debug('BEST UPSTREAM NEIGHBOR IS NONE AND TREE IS ACTIVE')
                self.set_assert_state(AssertState.Winner, creating_interface)
            elif self._my_assert_rpc.is_better_than(self._best_upstream_router):
                self.assert_logger.debug('TREE IS ACTIVE AND WON ASSERT')
                self.assert_logger.debug("BEST UPSTREAM NEIGHBOR METRIC_PREFERENCE: " +
                                         str(self._best_upstream_router.metric_preference) + '; METRIC: ' +
                                         str(self._best_upstream_router.route_metric) + '; IP: ' +
                                         self._best_upstream_router.get_ip())
                self.assert_logger.debug("MY METRIC_PREFERENCE: " + str(self._my_assert_rpc.metric_preference) +
                                         '; METRIC: ' + str(self._my_assert_rpc.route_metric) + '; IP: ' +
                                         self._my_assert_rpc.get_ip())
                self.set_assert_state(AssertState.Winner, creating_interface)
            else:
                self.assert_logger.debug('TREE IS ACTIVE AND LOST ASSERT')
                self.assert_logger.debug("BEST UPSTREAM NEIGHBOR METRIC_PREFERENCE: " +
                                         str(self._best_upstream_router.metric_preference) + '; METRIC: ' +
                                         str(self._best_upstream_router.route_metric) + '; IP: ' +
                                         self._best_upstream_router.get_ip())
                self.assert_logger.debug("MY METRIC_PREFERENCE: " + str(self._my_assert_rpc.metric_preference) +
                                         '; METRIC: ' + str(self._my_assert_rpc.route_metric) + '; IP: ' +
                                         self._my_assert_rpc.get_ip())
                self.set_assert_state(AssertState.Loser, creating_interface)
        elif self.is_tree_unsure():
            if self._best_upstream_router is None:
                self.assert_logger.debug('TREE IS UNSURE AND NO UPSTREAM NEIGHBOR')
                self.set_assert_state(AssertState.Winner)
            else:
                self.assert_logger.debug('TREE IS UNSURE AND UPSTREAM NEIGHBOR CONNECTED TO THIS INTERFACE')
                self.set_assert_state(AssertState.Loser, creating_interface)
        else:
            self.assert_logger.debug('TREE IS INACTIVE AND UPSTREAM NEIGHBOR CONNECTED TO THIS INTERFACE')
            self.set_assert_state(AssertState.Winner, creating_interface)
def calculate_assert_winner ( self , creating_interface = False ) : print ( "CALCULATE ASSERT WINNER" ) if self . is_tree_active ( ) : if self . _best_upstream_router is None : self . assert_logger . debug ( 'BEST UPSTREAM NEIGHBOR IS NONE AND TREE IS ACTIVE' ) self . set_assert_state ( AssertState . Winner , creating_interface ) elif self . _my_assert_rpc . is_better_than ( self . _best_upstream_router ) : self . assert_logger . debug ( 'TREE IS ACTIVE AND WON ASSERT' ) self . assert_logger . debug ( "BEST UPSTREAM NEIGHBOR METRIC_PREFERENCE: " + str ( self . _best_upstream_router . metric_preference ) + '; METRIC: ' + str ( self . _best_upstream_router . route_metric ) + '; IP: ' + self . _best_upstream_router . get_ip ( ) ) self . assert_logger . debug ( "MY METRIC_PREFERENCE: " + str ( self . _my_assert_rpc . metric_preference ) + '; METRIC: ' + str ( self . _my_assert_rpc . route_metric ) + '; IP: ' + self . _my_assert_rpc . get_ip ( ) ) self . set_assert_state ( AssertState . Winner , creating_interface ) else : self . assert_logger . debug ( 'TREE IS ACTIVE AND LOST ASSERT' ) self . assert_logger . debug ( "BEST UPSTREAM NEIGHBOR METRIC_PREFERENCE: " + str ( self . _best_upstream_router . metric_preference ) + '; METRIC: ' + str ( self . _best_upstream_router . route_metric ) + '; IP: ' + self . _best_upstream_router . get_ip ( ) ) self . assert_logger . debug ( "MY METRIC_PREFERENCE: " + str ( self . _my_assert_rpc . metric_preference ) + '; METRIC: ' + str ( self . _my_assert_rpc . route_metric ) + '; IP: ' + self . _my_assert_rpc . get_ip ( ) ) self . set_assert_state ( AssertState . Loser , creating_interface ) elif self . is_tree_unsure ( ) : if self . _best_upstream_router is None : self . assert_logger . debug ( 'TREE IS UNSURE AND NO UPSTREAM NEIGHBOR' ) self . set_assert_state ( AssertState . Winner ) else : self . assert_logger . debug ( 'TREE IS UNSURE AND UPSTREAM NEIGHBOR CONNECTED TO THIS INTERFACE' ) self . set_assert_state ( AssertState . Loser , creating_interface ) else : self . assert_logger . debug ( 'TREE IS INACTIVE AND UPSTREAM NEIGHBOR CONNECTED TO THIS INTERFACE' ) self . set_assert_state ( AssertState . Winner , creating_interface )
Calculate the router responsible for forwarding data packets to a link...
Based on this calculation, the Assert state is set
If tree in Active state and this interface offers a better Assert state compared to all neighbors
then this interface transitions to AssertWinner state
If tree in Active state and the BestUpstream neighbor offers a better Assert state (RPC and IP)
then this interface must transition to AssertLoser state
If tree in Unsure state and there are no Upstream neighbors connected to this interface
then this interface transitions to AssertWinner state
If tree in Unsure state and there are Upstream neighbors connected to this interface
then this interface transitions to AssertLoser state
If tree in Inactive state then interface must be in AssertWinner state
Calculate the router responsible for forwarding data packets to a link ... Based on this calculation the Assert state is set If tree in Active state and this interface offers a better Assert state compared to all neighbors then this interface transitions to AssertWinner state If tree in Active state and the BestUpstream neighbor offers a better Assert state ( RPC and IP ) then this interface must transition to AssertLoser state If tree in Unsure state and there are no Upstream neighbors connected to this interface then this interface transitions to AssertWinner state If tree in Unsure state and there are Upstream neighbors connected to this interface then this interface transitions to AssertLoser state If tree in Inactive state then interface must be in AssertWinner state
"""
        Calculate the router responsible for forwarding data packets to a link...
        Based on this calculation, the Assert state is set
        If tree in Active state and this interface offers a better Assert state compared to all neighbors
            then this interface transitions to AssertWinner state
        If tree in Active state and the BestUpstream neighbor offers a better Assert state (RPC and IP)
            then this interface must transition to AssertLoser state
        If tree in Unsure state and there are no Upstream neighbors connected to this interface
            then this interface transitions to AssertWinner state
        If tree in Unsure state and there are Upstream neighbors connected to this interface
            then this interface transitions to AssertLoser state
        If tree in Inactive state then interface must be in AssertWinner state
        """
self
creating_interface