Commit 3896b38d authored by Pedro Oliveira's avatar Pedro Oliveira

fix Assert state machine: verification of preferred assert

parent 1a64d22c
import os
import sys
import time
import netifaces
......@@ -193,10 +194,8 @@ def list_instances():
"""
List instance information
"""
t = PrettyTable(['Instance PID', 'Multicast VRF', 'Unicast VRF'])
import os
t.add_row([os.getpid(), pim_globals.MULTICAST_TABLE_ID, pim_globals.UNICAST_TABLE_ID])
return str(t)
t = "{}|{}|{}"
return t.format(os.getpid(), pim_globals.MULTICAST_TABLE_ID, pim_globals.UNICAST_TABLE_ID)
def stop():
......
......@@ -13,7 +13,7 @@ from pimdm import Main
from pimdm.tree import pim_globals
from pimdm.daemon.Daemon import Daemon
VERSION = "1.1.1.3"
VERSION = "1.1.1.4"
def client_socket(data_to_send, print_output=True):
......@@ -177,7 +177,7 @@ def main():
continue
t_new = client_socket(args, print_output=False)
t.add_row(t_new.replace(" ", "").split("\n")[3].split("|")[1:4])
t.add_row(t_new.split("|"))
print(t)
return
......
......@@ -116,6 +116,11 @@ class AssertStateABC(metaclass=ABCMeta):
interface.set_assert_timer(pim_globals.ASSERT_TIME)
interface.send_assert()
@staticmethod
@abstractmethod
def is_preferred_assert(interface: "TreeInterfaceDownstream", received_metric):
raise NotImplementedError()
# Override
def __str__(self) -> str:
return "AssertSM:" + self.__class__.__name__
......@@ -127,6 +132,10 @@ class NoInfoState(AssertStateABC):
This router has no (S,G) Assert state on interface I.
'''
@staticmethod
def is_preferred_assert(interface: "TreeInterfaceDownstream", received_metric):
return received_metric.is_better_than(interface._assert_winner_metric)
@staticmethod
def receivedDataFromDownstreamIf(interface: "TreeInterfaceDownstream"):
"""
......@@ -212,6 +221,10 @@ class WinnerState(AssertStateABC):
interface I.
'''
@staticmethod
def is_preferred_assert(interface: "TreeInterfaceDownstream", received_metric):
return received_metric.is_better_than(interface.my_assert_metric())
@staticmethod
def receivedDataFromDownstreamIf(interface: "TreeInterfaceDownstream"):
"""
......@@ -294,6 +307,11 @@ class LoserState(AssertStateABC):
forward packets from S destined for G onto interface I.
'''
@staticmethod
def is_preferred_assert(interface: "TreeInterfaceDownstream", received_metric):
return received_metric.is_better_than(interface._assert_winner_metric) or \
received_metric.equal_metric(interface._assert_winner_metric)
@staticmethod
def receivedDataFromDownstreamIf(interface: "TreeInterfaceDownstream"):
"""
......
......@@ -112,8 +112,7 @@ class TreeInterface(metaclass=ABCMeta):
elif self.my_assert_metric().is_better_than(received_metric) and self.could_assert():
# received inferior assert from non assert winner and could_assert
self._assert_state.receivedInferiorMetricFromNonWinner_couldAssertIsTrue(self)
elif received_metric.is_better_than(self._assert_winner_metric) or \
received_metric.equal_metric(self._assert_winner_metric):
elif self._assert_state.is_preferred_assert(self, received_metric):
#received preferred assert
equal_metric = received_metric.equal_metric(self._assert_winner_metric)
self._assert_state.receivedPreferedMetric(self, received_metric, equal_metric)
......
......@@ -13,7 +13,7 @@ setup(
long_description=open("README.md", "r").read(),
long_description_content_type="text/markdown",
keywords="PIM-DM Multicast Routing Protocol PIM Dense-Mode Router RFC3973 IPv4 IPv6",
version="1.1.1.3",
version="1.1.1.4",
url="http://github.com/pedrofran12/pim_dm",
author="Pedro Oliveira",
author_email="pedro.francisco.oliveira@tecnico.ulisboa.pt",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment