Commit deed2e8a authored by Pedro Oliveira's avatar Pedro Oliveira

log events more verbose

parent 8fec9cb1
...@@ -8,11 +8,11 @@ import ipaddress ...@@ -8,11 +8,11 @@ import ipaddress
from RWLock.RWLock import RWLockWrite from RWLock.RWLock import RWLockWrite
import Main import Main
import UnicastRouting
from InterfacePIM import InterfacePim from InterfacePIM import InterfacePim
from InterfaceIGMP import InterfaceIGMP from InterfaceIGMP import InterfaceIGMP
from tree.KernelEntry import KernelEntry from tree.KernelEntry import KernelEntry
class Kernel: class Kernel:
# MRT # MRT
MRT_BASE = 200 MRT_BASE = 200
...@@ -237,6 +237,20 @@ class Kernel: ...@@ -237,6 +237,20 @@ class Kernel:
struct_mfcctl = struct.pack("4s 4s H " + "B"*Kernel.MAXVIFS + " IIIi", source_ip, group_ip, kernel_entry.inbound_interface_index, *outbound_interfaces_and_other_parameters) struct_mfcctl = struct.pack("4s 4s H " + "B"*Kernel.MAXVIFS + " IIIi", source_ip, group_ip, kernel_entry.inbound_interface_index, *outbound_interfaces_and_other_parameters)
self.socket.setsockopt(socket.IPPROTO_IP, Kernel.MRT_ADD_MFC, struct_mfcctl) self.socket.setsockopt(socket.IPPROTO_IP, Kernel.MRT_ADD_MFC, struct_mfcctl)
def set_flood_multicast_route(self, source_ip, group_ip, inbound_interface_index):
source_ip = socket.inet_aton(source_ip)
group_ip = socket.inet_aton(group_ip)
outbound_interfaces = [1]*self.MAXVIFS
outbound_interfaces[inbound_interface_index] = 0
#outbound_interfaces_and_other_parameters = list(kernel_entry.outbound_interfaces) + [0]*4
outbound_interfaces_and_other_parameters = outbound_interfaces + [0]*3 + [20]
#outbound_interfaces, 0, 0, 0, 0 <- only works with python>=3.5
#struct_mfcctl = struct.pack("4s 4s H " + "B"*Kernel.MAXVIFS + " IIIi", source_ip, group_ip, inbound_interface_index, *outbound_interfaces, 0, 0, 0, 0)
struct_mfcctl = struct.pack("4s 4s H " + "B"*Kernel.MAXVIFS + " IIIi", source_ip, group_ip, inbound_interface_index, *outbound_interfaces_and_other_parameters)
self.socket.setsockopt(socket.IPPROTO_IP, Kernel.MRT_ADD_MFC, struct_mfcctl)
def remove_multicast_route(self, kernel_entry: KernelEntry): def remove_multicast_route(self, kernel_entry: KernelEntry):
source_ip = socket.inet_aton(kernel_entry.source_ip) source_ip = socket.inet_aton(kernel_entry.source_ip)
...@@ -341,6 +355,8 @@ class Kernel: ...@@ -341,6 +355,8 @@ class Kernel:
if ip_src not in self.routing: if ip_src not in self.routing:
self.routing[ip_src] = {} self.routing[ip_src] = {}
iif = self.vif_dic.get(UnicastRouting.check_rpf(ip_src))
self.set_flood_multicast_route(ip_src, ip_dst, iif)
self.routing[ip_src][ip_dst] = kernel_entry self.routing[ip_src][ip_dst] = kernel_entry
return kernel_entry return kernel_entry
else: else:
......
from pyroute2 import IPDB, IPRoute
import socket import socket
import RWLock
import Main
import ipaddress import ipaddress
from threading import RLock
from pyroute2 import IPDB, IPRoute
import Main
def get_route(ip_dst: str): def get_route(ip_dst: str):
return UnicastRouting.get_route(ip_dst) return UnicastRouting.get_route(ip_dst)
def get_metric(ip_dst: str): def get_metric(ip_dst: str):
return UnicastRouting.get_metric(ip_dst) return UnicastRouting.get_metric(ip_dst)
def check_rpf(ip_dst): def check_rpf(ip_dst):
return UnicastRouting.check_rpf(ip_dst) return UnicastRouting.check_rpf(ip_dst)
...@@ -18,36 +20,37 @@ def check_rpf(ip_dst): ...@@ -18,36 +20,37 @@ def check_rpf(ip_dst):
class UnicastRouting(object): class UnicastRouting(object):
ipr = None ipr = None
ipdb = None ipdb = None
lock = RLock()
def __init__(self): def __init__(self):
UnicastRouting.ipr = IPRoute() UnicastRouting.ipr = IPRoute()
UnicastRouting.ipdb = IPDB() UnicastRouting.ipdb = IPDB()
self._ipdb = UnicastRouting.ipdb self._ipdb = UnicastRouting.ipdb
self._ipdb.register_callback(UnicastRouting.unicast_changes) self._ipdb.register_callback(UnicastRouting.unicast_changes, mode="post")
@staticmethod @staticmethod
def get_route(ip_dst: str): def get_route(ip_dst: str):
ipdb = UnicastRouting.ipdb
ip_bytes = socket.inet_aton(ip_dst) ip_bytes = socket.inet_aton(ip_dst)
ip_int = int.from_bytes(ip_bytes, byteorder='big') ip_int = int.from_bytes(ip_bytes, byteorder='big')
info = None info = None
for mask_len in range(32, 0, -1): with UnicastRouting.lock:
ip_bytes = (ip_int & (0xFFFFFFFF << (32 - mask_len))).to_bytes(4, "big") ipdb = UnicastRouting.ipdb # type:IPDB
ip_dst = socket.inet_ntoa(ip_bytes) + "/" + str(mask_len)
print(ip_dst) for mask_len in range(32, 0, -1):
try: ip_bytes = (ip_int & (0xFFFFFFFF << (32 - mask_len))).to_bytes(4, "big")
info = ipdb.routes[ip_dst] ip_dst = socket.inet_ntoa(ip_bytes) + "/" + str(mask_len)
break print(ip_dst)
except: if ip_dst in ipdb.routes:
continue info = ipdb.routes[ip_dst]
if not info: break
print("0.0.0.0/0") else:
info = ipdb.routes["default"] continue
print(info) if not info:
return info print("0.0.0.0/0")
info = ipdb.routes["default"]
print(info)
return info
# get metrics (routing preference and cost) to IP ip_dst # get metrics (routing preference and cost) to IP ip_dst
@staticmethod @staticmethod
...@@ -60,7 +63,6 @@ class UnicastRouting(object): ...@@ -60,7 +63,6 @@ class UnicastRouting(object):
entry_cost = 0 entry_cost = 0
return (entry_protocol, entry_cost, mask) return (entry_protocol, entry_cost, mask)
# get output interface IP, used to send data to IP ip_dst # get output interface IP, used to send data to IP ip_dst
# (root interface IP to ip_dst) # (root interface IP to ip_dst)
@staticmethod @staticmethod
...@@ -74,11 +76,11 @@ class UnicastRouting(object): ...@@ -74,11 +76,11 @@ class UnicastRouting(object):
rpf_interface_source = UnicastRouting.ipr.get_routes(family=socket.AF_INET, dst=ip_dst)[0]['attrs'][3][1] rpf_interface_source = UnicastRouting.ipr.get_routes(family=socket.AF_INET, dst=ip_dst)[0]['attrs'][3][1]
return rpf_interface_source return rpf_interface_source
@staticmethod @staticmethod
def unicast_changes(ipdb, msg, action): def unicast_changes(ipdb, msg, action):
print("unicast change?") print("unicast change?")
print(action) print(action)
UnicastRouting.lock.acquire()
UnicastRouting.ipdb = ipdb UnicastRouting.ipdb = ipdb
if action == "RTM_NEWROUTE" or action == "RTM_DELROUTE": if action == "RTM_NEWROUTE" or action == "RTM_DELROUTE":
print(ipdb.routes) print(ipdb.routes)
...@@ -87,7 +89,7 @@ class UnicastRouting(object): ...@@ -87,7 +89,7 @@ class UnicastRouting(object):
attrs = msg["attrs"] attrs = msg["attrs"]
print(attrs) print(attrs)
for (key, value) in attrs: for (key, value) in attrs:
print((key,value)) print((key, value))
if key == "RTA_DST": if key == "RTA_DST":
network_address = value network_address = value
break break
...@@ -98,8 +100,10 @@ class UnicastRouting(object): ...@@ -98,8 +100,10 @@ class UnicastRouting(object):
print(network_address + "/" + str(mask_len)) print(network_address + "/" + str(mask_len))
subnet = ipaddress.ip_network(network_address + "/" + str(mask_len)) subnet = ipaddress.ip_network(network_address + "/" + str(mask_len))
print(str(subnet)) print(str(subnet))
UnicastRouting.lock.release()
Main.kernel.notify_unicast_changes(subnet) Main.kernel.notify_unicast_changes(subnet)
elif action == "RTM_NEWADDR" or action == "RTM_DELADDR": elif action == "RTM_NEWADDR" or action == "RTM_DELADDR":
UnicastRouting.lock.release()
# TODO ALTERACOES NA INTERFACE # TODO ALTERACOES NA INTERFACE
''' '''
print(action) print(action)
...@@ -111,11 +115,11 @@ class UnicastRouting(object): ...@@ -111,11 +115,11 @@ class UnicastRouting(object):
if key == "IFA_LABEL": if key == "IFA_LABEL":
interface_name = value interface_name = value
break break
Main.kernel.notify_interface_change(interface_name) Main.kernel.notify_interface_change(interface_name)
''' '''
pass else:
UnicastRouting.lock.release()
def stop(self): def stop(self):
if UnicastRouting.ipr: if UnicastRouting.ipr:
......
...@@ -19,24 +19,9 @@ class KernelEntry: ...@@ -19,24 +19,9 @@ class KernelEntry:
self.source_ip = source_ip self.source_ip = source_ip
self.group_ip = group_ip self.group_ip = group_ip
# ip of neighbor of the rpf # CHECK UNICAST ROUTING INFORMATION###################################################
#next_hop = UnicastRouting.get_route(source_ip)["gateway"] # CHOSE RPC INTERFACE
#self.rpf_node = source_ip if next_hop is None else next_hop # GET RPC TO SOURCE
'''
next_hop = UnicastRouting.get_route(source_ip)["gateway"]
multipaths = UnicastRouting.get_route(source_ip)["multipath"]
self.rpf_node = next_hop if next_hop is not None else source_ip
print("MUL", multipaths)
#self.rpf_node = multipaths[0]["gateway"]
for m in multipaths:
if m["gateway"] is None:
self.rpf_node = source_ip
break
else:
self.rpf_node = m["gateway"]
'''
unicast_route = UnicastRouting.get_route(source_ip) unicast_route = UnicastRouting.get_route(source_ip)
next_hop = unicast_route["gateway"] next_hop = unicast_route["gateway"]
multipaths = unicast_route["multipath"] multipaths = unicast_route["multipath"]
......
from abc import ABCMeta, abstractstaticmethod from abc import ABCMeta, abstractmethod
import tree.globals as pim_globals import tree.globals as pim_globals
from .metric import AssertMetric from .metric import AssertMetric
...@@ -8,7 +8,8 @@ if TYPE_CHECKING: ...@@ -8,7 +8,8 @@ if TYPE_CHECKING:
class AssertStateABC(metaclass=ABCMeta): class AssertStateABC(metaclass=ABCMeta):
@abstractstaticmethod @staticmethod
@abstractmethod
def receivedDataFromDownstreamIf(interface: "TreeInterfaceDownstream"): def receivedDataFromDownstreamIf(interface: "TreeInterfaceDownstream"):
""" """
An (S,G) Data packet received on downstream interface An (S,G) Data packet received on downstream interface
...@@ -17,7 +18,8 @@ class AssertStateABC(metaclass=ABCMeta): ...@@ -17,7 +18,8 @@ class AssertStateABC(metaclass=ABCMeta):
""" """
raise NotImplementedError() raise NotImplementedError()
@abstractstaticmethod @staticmethod
@abstractmethod
def receivedInferiorMetricFromWinner(interface: "TreeInterfaceDownstream"): def receivedInferiorMetricFromWinner(interface: "TreeInterfaceDownstream"):
""" """
Receive Inferior (Assert OR State Refresh) from Assert Winner Receive Inferior (Assert OR State Refresh) from Assert Winner
...@@ -26,7 +28,8 @@ class AssertStateABC(metaclass=ABCMeta): ...@@ -26,7 +28,8 @@ class AssertStateABC(metaclass=ABCMeta):
""" """
raise NotImplementedError() raise NotImplementedError()
@abstractstaticmethod @staticmethod
@abstractmethod
def receivedInferiorMetricFromNonWinner_couldAssertIsTrue(interface: "TreeInterfaceDownstream"): def receivedInferiorMetricFromNonWinner_couldAssertIsTrue(interface: "TreeInterfaceDownstream"):
""" """
Receive Inferior (Assert OR State Refresh) from non-Assert Winner Receive Inferior (Assert OR State Refresh) from non-Assert Winner
...@@ -36,7 +39,8 @@ class AssertStateABC(metaclass=ABCMeta): ...@@ -36,7 +39,8 @@ class AssertStateABC(metaclass=ABCMeta):
""" """
raise NotImplementedError() raise NotImplementedError()
@abstractstaticmethod @staticmethod
@abstractmethod
def receivedPreferedMetric(interface: "TreeInterfaceDownstream", better_metric): def receivedPreferedMetric(interface: "TreeInterfaceDownstream", better_metric):
""" """
Receive Preferred Assert OR State Refresh Receive Preferred Assert OR State Refresh
...@@ -46,7 +50,8 @@ class AssertStateABC(metaclass=ABCMeta): ...@@ -46,7 +50,8 @@ class AssertStateABC(metaclass=ABCMeta):
""" """
raise NotImplementedError() raise NotImplementedError()
@abstractstaticmethod @staticmethod
@abstractmethod
def sendStateRefresh(interface: "TreeInterfaceDownstream", time): def sendStateRefresh(interface: "TreeInterfaceDownstream", time):
""" """
Send State Refresh Send State Refresh
...@@ -57,7 +62,8 @@ class AssertStateABC(metaclass=ABCMeta): ...@@ -57,7 +62,8 @@ class AssertStateABC(metaclass=ABCMeta):
""" """
raise NotImplementedError() raise NotImplementedError()
@abstractstaticmethod @staticmethod
@abstractmethod
def assertTimerExpires(interface: "TreeInterfaceDownstream"): def assertTimerExpires(interface: "TreeInterfaceDownstream"):
""" """
AT(S,G) Expires AT(S,G) Expires
...@@ -66,7 +72,8 @@ class AssertStateABC(metaclass=ABCMeta): ...@@ -66,7 +72,8 @@ class AssertStateABC(metaclass=ABCMeta):
""" """
raise NotImplementedError() raise NotImplementedError()
@abstractstaticmethod @staticmethod
@abstractmethod
def couldAssertIsNowFalse(interface: "TreeInterfaceDownstream"): def couldAssertIsNowFalse(interface: "TreeInterfaceDownstream"):
""" """
CouldAssert -> FALSE CouldAssert -> FALSE
...@@ -75,7 +82,8 @@ class AssertStateABC(metaclass=ABCMeta): ...@@ -75,7 +82,8 @@ class AssertStateABC(metaclass=ABCMeta):
""" """
raise NotImplementedError() raise NotImplementedError()
@abstractstaticmethod @staticmethod
@abstractmethod
def couldAssertIsNowTrue(interface: "TreeInterfaceDownstream"): def couldAssertIsNowTrue(interface: "TreeInterfaceDownstream"):
""" """
CouldAssert -> TRUE CouldAssert -> TRUE
...@@ -84,7 +92,8 @@ class AssertStateABC(metaclass=ABCMeta): ...@@ -84,7 +92,8 @@ class AssertStateABC(metaclass=ABCMeta):
""" """
raise NotImplementedError() raise NotImplementedError()
@abstractstaticmethod @staticmethod
@abstractmethod
def winnerLivelinessTimerExpires(interface: "TreeInterfaceDownstream"): def winnerLivelinessTimerExpires(interface: "TreeInterfaceDownstream"):
""" """
Winner’s NLT(N,I) Expires Winner’s NLT(N,I) Expires
...@@ -93,7 +102,8 @@ class AssertStateABC(metaclass=ABCMeta): ...@@ -93,7 +102,8 @@ class AssertStateABC(metaclass=ABCMeta):
""" """
raise NotImplementedError() raise NotImplementedError()
@abstractstaticmethod @staticmethod
@abstractmethod
def receivedPruneOrJoinOrGraft(interface: "TreeInterfaceDownstream"): def receivedPruneOrJoinOrGraft(interface: "TreeInterfaceDownstream"):
""" """
Receive Prune(S,G), Join(S,G) or Graft(S,G) Receive Prune(S,G), Join(S,G) or Graft(S,G)
...@@ -198,7 +208,7 @@ class NoInfoState(AssertStateABC): ...@@ -198,7 +208,7 @@ class NoInfoState(AssertStateABC):
interface.assert_logger.debug('receivedPruneOrJoinOrGraft, NI -> NI') interface.assert_logger.debug('receivedPruneOrJoinOrGraft, NI -> NI')
def __str__(self) -> str: def __str__(self) -> str:
return "NI" return "NoInfo"
class WinnerState(AssertStateABC): class WinnerState(AssertStateABC):
...@@ -288,7 +298,7 @@ class WinnerState(AssertStateABC): ...@@ -288,7 +298,7 @@ class WinnerState(AssertStateABC):
pass pass
def __str__(self) -> str: def __str__(self) -> str:
return "W" return "Winner"
...@@ -383,7 +393,7 @@ class LoserState(AssertStateABC): ...@@ -383,7 +393,7 @@ class LoserState(AssertStateABC):
interface.set_assert_state(AssertState.NoInfo) interface.set_assert_state(AssertState.NoInfo)
def __str__(self) -> str: def __str__(self) -> str:
return "L" return "Loser"
class AssertState(): class AssertState():
NoInfo = NoInfoState() NoInfo = NoInfoState()
......
from abc import ABCMeta, abstractstaticmethod from abc import ABCMeta, abstractmethod
from tree import globals as pim_globals from tree import globals as pim_globals
from utils import TYPE_CHECKING from utils import TYPE_CHECKING
...@@ -6,7 +6,8 @@ if TYPE_CHECKING: ...@@ -6,7 +6,8 @@ if TYPE_CHECKING:
from .tree_if_downstream import TreeInterfaceDownstream from .tree_if_downstream import TreeInterfaceDownstream
class DownstreamStateABS(metaclass=ABCMeta): class DownstreamStateABS(metaclass=ABCMeta):
@abstractstaticmethod @staticmethod
@abstractmethod
def receivedPrune(interface: "TreeInterfaceDownstream", holdtime): def receivedPrune(interface: "TreeInterfaceDownstream", holdtime):
""" """
Receive Prune(S,G) Receive Prune(S,G)
...@@ -15,7 +16,8 @@ class DownstreamStateABS(metaclass=ABCMeta): ...@@ -15,7 +16,8 @@ class DownstreamStateABS(metaclass=ABCMeta):
""" """
raise NotImplementedError() raise NotImplementedError()
@abstractstaticmethod @staticmethod
@abstractmethod
def receivedJoin(interface: "TreeInterfaceDownstream"): def receivedJoin(interface: "TreeInterfaceDownstream"):
""" """
Receive Join(S,G) Receive Join(S,G)
...@@ -24,7 +26,8 @@ class DownstreamStateABS(metaclass=ABCMeta): ...@@ -24,7 +26,8 @@ class DownstreamStateABS(metaclass=ABCMeta):
""" """
raise NotImplementedError() raise NotImplementedError()
@abstractstaticmethod @staticmethod
@abstractmethod
def receivedGraft(interface: "TreeInterfaceDownstream", source_ip): def receivedGraft(interface: "TreeInterfaceDownstream", source_ip):
""" """
Receive Graft(S,G) Receive Graft(S,G)
...@@ -33,7 +36,8 @@ class DownstreamStateABS(metaclass=ABCMeta): ...@@ -33,7 +36,8 @@ class DownstreamStateABS(metaclass=ABCMeta):
""" """
raise NotImplementedError() raise NotImplementedError()
@abstractstaticmethod @staticmethod
@abstractmethod
def PPTexpires(interface: "TreeInterfaceDownstream"): def PPTexpires(interface: "TreeInterfaceDownstream"):
""" """
PPT(S,G) Expires PPT(S,G) Expires
...@@ -42,7 +46,8 @@ class DownstreamStateABS(metaclass=ABCMeta): ...@@ -42,7 +46,8 @@ class DownstreamStateABS(metaclass=ABCMeta):
""" """
raise NotImplementedError() raise NotImplementedError()
@abstractstaticmethod @staticmethod
@abstractmethod
def PTexpires(interface: "TreeInterfaceDownstream"): def PTexpires(interface: "TreeInterfaceDownstream"):
""" """
PT(S,G) Expires PT(S,G) Expires
...@@ -51,7 +56,8 @@ class DownstreamStateABS(metaclass=ABCMeta): ...@@ -51,7 +56,8 @@ class DownstreamStateABS(metaclass=ABCMeta):
""" """
raise NotImplementedError() raise NotImplementedError()
@abstractstaticmethod @staticmethod
@abstractmethod
def is_now_RPF_Interface(interface: "TreeInterfaceDownstream"): def is_now_RPF_Interface(interface: "TreeInterfaceDownstream"):
""" """
RPF_Interface(S) becomes I RPF_Interface(S) becomes I
...@@ -60,7 +66,8 @@ class DownstreamStateABS(metaclass=ABCMeta): ...@@ -60,7 +66,8 @@ class DownstreamStateABS(metaclass=ABCMeta):
""" """
raise NotImplementedError() raise NotImplementedError()
@abstractstaticmethod @staticmethod
@abstractmethod
def send_state_refresh(interface: "TreeInterfaceDownstream"): def send_state_refresh(interface: "TreeInterfaceDownstream"):
""" """
Send State Refresh(S,G) out I Send State Refresh(S,G) out I
...@@ -88,6 +95,7 @@ class NoInfo(DownstreamStateABS): ...@@ -88,6 +95,7 @@ class NoInfo(DownstreamStateABS):
@type interface: TreeInterfaceDownstreamDownstream @type interface: TreeInterfaceDownstreamDownstream
""" """
interface.join_prune_logger.debug("receivedPrune, NI -> PP")
interface.set_prune_state(DownstreamState.PrunePending) interface.set_prune_state(DownstreamState.PrunePending)
time = 0 time = 0
...@@ -96,9 +104,6 @@ class NoInfo(DownstreamStateABS): ...@@ -96,9 +104,6 @@ class NoInfo(DownstreamStateABS):
interface.set_prune_pending_timer(time) interface.set_prune_pending_timer(time)
#print("receivedPrune, NI -> PP")
interface.join_prune_logger.debug("receivedPrune, NI -> PP")
@staticmethod @staticmethod
def receivedJoin(interface: "TreeInterfaceDownstream"): def receivedJoin(interface: "TreeInterfaceDownstream"):
""" """
...@@ -106,9 +111,7 @@ class NoInfo(DownstreamStateABS): ...@@ -106,9 +111,7 @@ class NoInfo(DownstreamStateABS):
@type interface: TreeInterfaceDownstreamDownstream @type interface: TreeInterfaceDownstreamDownstream
""" """
# Do nothing # Do nothing
#print("receivedJoin, NI -> NI")
interface.join_prune_logger.debug("receivedJoin, NI -> NI") interface.join_prune_logger.debug("receivedJoin, NI -> NI")
@staticmethod @staticmethod
...@@ -118,10 +121,8 @@ class NoInfo(DownstreamStateABS): ...@@ -118,10 +121,8 @@ class NoInfo(DownstreamStateABS):
@type interface: TreeInterfaceDownstreamDownstream @type interface: TreeInterfaceDownstreamDownstream
""" """
interface.send_graft_ack(source_ip)
#print('receivedGraft, NI -> NI')
interface.join_prune_logger.debug('receivedGraft, NI -> NI') interface.join_prune_logger.debug('receivedGraft, NI -> NI')
interface.send_graft_ack(source_ip)
@staticmethod @staticmethod
def PPTexpires(interface: "TreeInterfaceDownstream"): def PPTexpires(interface: "TreeInterfaceDownstream"):
...@@ -164,7 +165,7 @@ class NoInfo(DownstreamStateABS): ...@@ -164,7 +165,7 @@ class NoInfo(DownstreamStateABS):
return return
def __str__(self): def __str__(self):
return "NI" return "NoInfo"
...@@ -185,8 +186,6 @@ class PrunePending(DownstreamStateABS): ...@@ -185,8 +186,6 @@ class PrunePending(DownstreamStateABS):
@type interface: TreeInterfaceDownstreamDownstream @type interface: TreeInterfaceDownstreamDownstream
""" """
#print('receivedPrune, PP -> PP')
interface.join_prune_logger.debug('receivedPrune, PP -> PP') interface.join_prune_logger.debug('receivedPrune, PP -> PP')
...@@ -197,12 +196,12 @@ class PrunePending(DownstreamStateABS): ...@@ -197,12 +196,12 @@ class PrunePending(DownstreamStateABS):
@type interface: TreeInterfaceDownstreamDownstream @type interface: TreeInterfaceDownstreamDownstream
""" """
interface.join_prune_logger.debug('receivedJoin, PP -> NI')
interface.clear_prune_pending_timer() interface.clear_prune_pending_timer()
interface.set_prune_state(DownstreamState.NoInfo) interface.set_prune_state(DownstreamState.NoInfo)
#print('receivedJoin, PP -> NI')
interface.join_prune_logger.debug('receivedJoin, PP -> NI')
@staticmethod @staticmethod
def receivedGraft(interface: "TreeInterfaceDownstream", source_ip): def receivedGraft(interface: "TreeInterfaceDownstream", source_ip):
...@@ -211,14 +210,13 @@ class PrunePending(DownstreamStateABS): ...@@ -211,14 +210,13 @@ class PrunePending(DownstreamStateABS):
@type interface: TreeInterfaceDownstreamDownstream @type interface: TreeInterfaceDownstreamDownstream
""" """
interface.join_prune_logger.debug('receivedGraft, PP -> NI')
interface.clear_prune_pending_timer() interface.clear_prune_pending_timer()
interface.set_prune_state(DownstreamState.NoInfo) interface.set_prune_state(DownstreamState.NoInfo)
interface.send_graft_ack(source_ip) interface.send_graft_ack(source_ip)
#print('receivedGraft, PP -> NI')
interface.join_prune_logger.debug('receivedGraft, PP -> NI')
@staticmethod @staticmethod
def PPTexpires(interface: "TreeInterfaceDownstream"): def PPTexpires(interface: "TreeInterfaceDownstream"):
""" """
...@@ -226,15 +224,13 @@ class PrunePending(DownstreamStateABS): ...@@ -226,15 +224,13 @@ class PrunePending(DownstreamStateABS):
@type interface: TreeInterfaceDownstreamDownstream @type interface: TreeInterfaceDownstreamDownstream
""" """
interface.join_prune_logger.debug('PPTexpires, PP -> P')
interface.set_prune_state(DownstreamState.Pruned) interface.set_prune_state(DownstreamState.Pruned)
interface.set_prune_timer(interface.get_received_prune_holdtime() - pim_globals.JP_OVERRIDE_INTERVAL) interface.set_prune_timer(interface.get_received_prune_holdtime() - pim_globals.JP_OVERRIDE_INTERVAL)
if len(interface.get_interface().neighbors) > 1: if len(interface.get_interface().neighbors) > 1:
interface.send_pruneecho() interface.send_pruneecho()
#print('PPTexpires, PP -> P')
interface.join_prune_logger.debug('PPTexpires, PP -> P')
@staticmethod @staticmethod
def PTexpires(interface: "TreeInterfaceDownstream"): def PTexpires(interface: "TreeInterfaceDownstream"):
""" """
...@@ -242,7 +238,6 @@ class PrunePending(DownstreamStateABS): ...@@ -242,7 +238,6 @@ class PrunePending(DownstreamStateABS):
@type interface: TreeInterfaceDownstreamDownstream @type interface: TreeInterfaceDownstreamDownstream
""" """
#assert False, "PTexpires in state PP" #assert False, "PTexpires in state PP"
return return
...@@ -253,12 +248,12 @@ class PrunePending(DownstreamStateABS): ...@@ -253,12 +248,12 @@ class PrunePending(DownstreamStateABS):
@type interface: TreeInterfaceDownstreamDownstream @type interface: TreeInterfaceDownstreamDownstream
""" """
interface.join_prune_logger.debug('is_now_RPF_Interface, PP -> NI')
interface.clear_prune_pending_timer() interface.clear_prune_pending_timer()
interface.set_prune_state(DownstreamState.NoInfo) interface.set_prune_state(DownstreamState.NoInfo)
print('is_now_RPF_Interface, PP -> NI')
@staticmethod @staticmethod
def send_state_refresh(interface: "TreeInterfaceDownstream"): def send_state_refresh(interface: "TreeInterfaceDownstream"):
""" """
...@@ -269,7 +264,7 @@ class PrunePending(DownstreamStateABS): ...@@ -269,7 +264,7 @@ class PrunePending(DownstreamStateABS):
return return
def __str__(self): def __str__(self):
return "PP" return "PrunePending"
class Pruned(DownstreamStateABS): class Pruned(DownstreamStateABS):
''' '''
...@@ -287,12 +282,10 @@ class Pruned(DownstreamStateABS): ...@@ -287,12 +282,10 @@ class Pruned(DownstreamStateABS):
@type interface: TreeInterfaceDownstreamDownstream @type interface: TreeInterfaceDownstreamDownstream
""" """
interface.join_prune_logger.debug('receivedPrune, P -> P')
if holdtime > interface.remaining_prune_timer(): if holdtime > interface.remaining_prune_timer():
interface.set_prune_timer(holdtime) interface.set_prune_timer(holdtime)
#print('receivedPrune, P -> P')
interface.join_prune_logger.debug('receivedPrune, P -> P')
@staticmethod @staticmethod
def receivedJoin(interface: "TreeInterfaceDownstream"): def receivedJoin(interface: "TreeInterfaceDownstream"):
""" """
...@@ -300,13 +293,12 @@ class Pruned(DownstreamStateABS): ...@@ -300,13 +293,12 @@ class Pruned(DownstreamStateABS):
@type interface: TreeInterfaceDownstreamDownstream @type interface: TreeInterfaceDownstreamDownstream
""" """
interface.join_prune_logger.debug('receivedPrune, P -> NI')
interface.clear_prune_timer() interface.clear_prune_timer()
interface.set_prune_state(DownstreamState.NoInfo) interface.set_prune_state(DownstreamState.NoInfo)
#print('receivedPrune, P -> NI')
interface.join_prune_logger.debug('receivedPrune, P -> NI')
@staticmethod @staticmethod
def receivedGraft(interface: "TreeInterfaceDownstream", source_ip): def receivedGraft(interface: "TreeInterfaceDownstream", source_ip):
""" """
...@@ -314,13 +306,11 @@ class Pruned(DownstreamStateABS): ...@@ -314,13 +306,11 @@ class Pruned(DownstreamStateABS):
@type interface: TreeInterfaceDownstreamDownstream @type interface: TreeInterfaceDownstreamDownstream
""" """
interface.join_prune_logger.debug('receivedGraft, P -> NI')
interface.clear_prune_timer() interface.clear_prune_timer()
interface.set_prune_state(DownstreamState.NoInfo) interface.set_prune_state(DownstreamState.NoInfo)
interface.send_graft_ack(source_ip) interface.send_graft_ack(source_ip)
#print('receivedGraft, P -> NI')
interface.join_prune_logger.debug('receivedGraft, P -> NI')
@staticmethod @staticmethod
def PPTexpires(interface: "TreeInterfaceDownstream"): def PPTexpires(interface: "TreeInterfaceDownstream"):
""" """
...@@ -338,10 +328,8 @@ class Pruned(DownstreamStateABS): ...@@ -338,10 +328,8 @@ class Pruned(DownstreamStateABS):
@type interface: TreeInterfaceDownstreamDownstream @type interface: TreeInterfaceDownstreamDownstream
""" """
interface.set_prune_state(DownstreamState.NoInfo)
#print('PTexpires, P -> NI')
interface.join_prune_logger.debug('PTexpires, P -> NI') interface.join_prune_logger.debug('PTexpires, P -> NI')
interface.set_prune_state(DownstreamState.NoInfo)
@staticmethod @staticmethod
def is_now_RPF_Interface(interface: "TreeInterfaceDownstream"): def is_now_RPF_Interface(interface: "TreeInterfaceDownstream"):
...@@ -350,11 +338,10 @@ class Pruned(DownstreamStateABS): ...@@ -350,11 +338,10 @@ class Pruned(DownstreamStateABS):
@type interface: TreeInterfaceDownstreamDownstream @type interface: TreeInterfaceDownstreamDownstream
""" """
interface.join_prune_logger('is_now_RPF_Interface, P -> NI')
interface.clear_prune_timer() interface.clear_prune_timer()
interface.set_prune_state(DownstreamState.NoInfo) interface.set_prune_state(DownstreamState.NoInfo)
print('is_now_RPF_Interface, P -> NI')
@staticmethod @staticmethod
def send_state_refresh(interface: "TreeInterfaceDownstream"): def send_state_refresh(interface: "TreeInterfaceDownstream"):
""" """
...@@ -362,14 +349,12 @@ class Pruned(DownstreamStateABS): ...@@ -362,14 +349,12 @@ class Pruned(DownstreamStateABS):
@type interface: TreeInterfaceDownstreamDownstream @type interface: TreeInterfaceDownstreamDownstream
""" """
interface.join_prune_logger.debug('send_state_refresh, P -> P')
if interface.get_interface().is_state_refresh_capable(): if interface.get_interface().is_state_refresh_capable():
interface.set_prune_timer(interface.get_received_prune_holdtime()) interface.set_prune_timer(interface.get_received_prune_holdtime())
#print('send_state_refresh, P -> P')
interface.join_prune_logger.debug('send_state_refresh, P -> P')
def __str__(self): def __str__(self):
return "P" return "Pruned"
class DownstreamState(): class DownstreamState():
NoInfo = NoInfo() NoInfo = NoInfo()
......
...@@ -30,30 +30,25 @@ class Originator(OriginatorStateABC): ...@@ -30,30 +30,25 @@ class Originator(OriginatorStateABC):
''' '''
@type tree: Tree @type tree: Tree
''' '''
tree.originator_logger.debug('SRT expired, O -> O')
tree.set_state_refresh_timer() tree.set_state_refresh_timer()
tree.create_state_refresh_msg() tree.create_state_refresh_msg()
#print('SRT expired, O to O')
tree.originator_logger.debug('SRT expired, O -> O')
@staticmethod @staticmethod
def SATexpires(tree): def SATexpires(tree):
tree.originator_logger.debug('SAT expired, O -> NO')
tree.clear_state_refresh_timer() tree.clear_state_refresh_timer()
tree.set_originator_state(OriginatorState.NotOriginator) tree.set_originator_state(OriginatorState.NotOriginator)
#print('SAT expired, O to NO')
tree.originator_logger.debug('SAT expired, O -> NO')
@staticmethod @staticmethod
def SourceNotConnected(tree): def SourceNotConnected(tree):
tree.originator_logger.debug('Source no longer directly connected, O -> NO')
tree.clear_state_refresh_timer() tree.clear_state_refresh_timer()
tree.clear_source_active_timer() tree.clear_source_active_timer()
tree.set_originator_state(OriginatorState.NotOriginator) tree.set_originator_state(OriginatorState.NotOriginator)
#print('Source no longer directly connected, O to NO')
tree.originator_logger.debug('Source no longer directly connected, O -> NO')
def __str__(self): def __str__(self):
return 'O' return 'Originator'
class NotOriginator(OriginatorStateABC): class NotOriginator(OriginatorStateABC):
@staticmethod @staticmethod
...@@ -61,14 +56,12 @@ class NotOriginator(OriginatorStateABC): ...@@ -61,14 +56,12 @@ class NotOriginator(OriginatorStateABC):
''' '''
@type interface: Tree @type interface: Tree
''' '''
tree.originator_logger.debug('new DataMsg from Source, NO -> O')
tree.set_originator_state(OriginatorState.Originator) tree.set_originator_state(OriginatorState.Originator)
tree.set_state_refresh_timer() tree.set_state_refresh_timer()
tree.set_source_active_timer() tree.set_source_active_timer()
#print('new DataMsg from Source, NO to O')
tree.originator_logger.debug('new DataMsg from Source, NO -> O')
@staticmethod @staticmethod
def SRTexpires(tree): def SRTexpires(tree):
assert False, "SRTexpires in NO" assert False, "SRTexpires in NO"
...@@ -82,7 +75,7 @@ class NotOriginator(OriginatorStateABC): ...@@ -82,7 +75,7 @@ class NotOriginator(OriginatorStateABC):
return return
def __str__(self): def __str__(self):
return 'NO' return 'NotOriginator'
class OriginatorState(): class OriginatorState():
......
...@@ -25,7 +25,7 @@ class TreeInterfaceDownstream(TreeInterface): ...@@ -25,7 +25,7 @@ class TreeInterfaceDownstream(TreeInterface):
logger = logging.LoggerAdapter(TreeInterfaceDownstream.LOGGER, extra_dict_logger) logger = logging.LoggerAdapter(TreeInterfaceDownstream.LOGGER, extra_dict_logger)
TreeInterface.__init__(self, kernel_entry, interface_id, logger) TreeInterface.__init__(self, kernel_entry, interface_id, logger)
self.logger.debug('Created DownstreamInterface') self.logger.debug('Created DownstreamInterface')
self.join_prune_logger.debug(str(self._prune_state)) self.join_prune_logger.debug('Downstream state transitions to ' + str(self._prune_state))
# Last state refresh message sent (resend in case of new neighbors) # Last state refresh message sent (resend in case of new neighbors)
self._last_state_refresh_message = None self._last_state_refresh_message = None
...@@ -37,7 +37,7 @@ class TreeInterfaceDownstream(TreeInterface): ...@@ -37,7 +37,7 @@ class TreeInterfaceDownstream(TreeInterface):
with self.get_state_lock(): with self.get_state_lock():
if new_state != self._prune_state: if new_state != self._prune_state:
self._prune_state = new_state self._prune_state = new_state
self.join_prune_logger.debug(str(new_state)) self.join_prune_logger.debug('Downstream state transitions to ' + str(new_state))
self.change_tree() self.change_tree()
self.evaluate_ingroup() self.evaluate_ingroup()
......
...@@ -35,7 +35,7 @@ class TreeInterfaceUpstream(TreeInterface): ...@@ -35,7 +35,7 @@ class TreeInterfaceUpstream(TreeInterface):
self._override_timer = None self._override_timer = None
self._prune_limit_timer = None self._prune_limit_timer = None
self._last_rpf = self.get_neighbor_RPF() self._last_rpf = self.get_neighbor_RPF()
self.join_prune_logger.debug(str(self._graft_prune_state)) self.join_prune_logger.debug('Upstream state transitions to ' + str(self._graft_prune_state))
# Originator state # Originator state
self._originator_state = OriginatorState.NotOriginator self._originator_state = OriginatorState.NotOriginator
...@@ -43,7 +43,7 @@ class TreeInterfaceUpstream(TreeInterface): ...@@ -43,7 +43,7 @@ class TreeInterfaceUpstream(TreeInterface):
self._source_active_timer = None self._source_active_timer = None
self._prune_now_counter = 0 self._prune_now_counter = 0
self.originator_logger = logging.LoggerAdapter(TreeInterfaceUpstream.LOGGER.getChild('Originator'), extra_dict_logger) self.originator_logger = logging.LoggerAdapter(TreeInterfaceUpstream.LOGGER.getChild('Originator'), extra_dict_logger)
self.originator_logger.debug(str(self._originator_state)) self.originator_logger.debug('StateRefresh state transitions to ' + str(self._originator_state))
if self.is_S_directly_conn(): if self.is_S_directly_conn():
self._graft_prune_state.sourceIsNowDirectConnect(self) self._graft_prune_state.sourceIsNowDirectConnect(self)
...@@ -82,7 +82,7 @@ class TreeInterfaceUpstream(TreeInterface): ...@@ -82,7 +82,7 @@ class TreeInterfaceUpstream(TreeInterface):
with self.get_state_lock(): with self.get_state_lock():
if new_state != self._graft_prune_state: if new_state != self._graft_prune_state:
self._graft_prune_state = new_state self._graft_prune_state = new_state
self.join_prune_logger.debug(str(new_state)) self.join_prune_logger.debug('Upstream state transitions to ' + str(new_state))
self.change_tree() self.change_tree()
self.evaluate_ingroup() self.evaluate_ingroup()
...@@ -90,7 +90,7 @@ class TreeInterfaceUpstream(TreeInterface): ...@@ -90,7 +90,7 @@ class TreeInterfaceUpstream(TreeInterface):
def set_originator_state(self, new_state: OriginatorStateABC): def set_originator_state(self, new_state: OriginatorStateABC):
if new_state != self._originator_state: if new_state != self._originator_state:
self._originator_state = new_state self._originator_state = new_state
self.originator_logger.debug(str(new_state)) self.originator_logger.debug('StateRefresh state transitions to ' + str(new_state))
########################################## ##########################################
# Check timers # Check timers
......
...@@ -55,7 +55,7 @@ class TreeInterface(metaclass=ABCMeta): ...@@ -55,7 +55,7 @@ class TreeInterface(metaclass=ABCMeta):
self._assert_state = AssertState.NoInfo self._assert_state = AssertState.NoInfo
self._assert_winner_metric = AssertMetric() self._assert_winner_metric = AssertMetric()
self._assert_timer = None self._assert_timer = None
self.assert_logger.debug("NI") self.assert_logger.debug("Assert state transitions to NoInfo")
# Received prune hold time # Received prune hold time
self._received_prune_holdtime = None self._received_prune_holdtime = None
...@@ -70,7 +70,7 @@ class TreeInterface(metaclass=ABCMeta): ...@@ -70,7 +70,7 @@ class TreeInterface(metaclass=ABCMeta):
with self.get_state_lock(): with self.get_state_lock():
if new_state != self._assert_state: if new_state != self._assert_state:
self._assert_state = new_state self._assert_state = new_state
self.assert_logger.debug(str(new_state)) self.assert_logger.debug('Assert state transitions to ' + str(new_state))
self.change_tree() self.change_tree()
self.evaluate_ingroup() self.evaluate_ingroup()
......
This diff is collapsed.
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