Commit edf28819 authored by Pedro Oliveira's avatar Pedro Oliveira

Test Join/Prune/Graft

parent 39f0760e
...@@ -39,7 +39,7 @@ switch1[1]=switchnetwork1 ...@@ -39,7 +39,7 @@ switch1[1]=switchnetwork1
switch1[2]=switchnetwork2 switch1[2]=switchnetwork2
switch1[3]=switchnetwork3 switch1[3]=switchnetwork3
switch1[4]=switchnetwork4 switch1[4]=switchnetwork4
switch1[5]=log_server switch1[5]=logserver
switch1[mem]=256 switch1[mem]=256
...@@ -55,7 +55,7 @@ client0[mem]=256 ...@@ -55,7 +55,7 @@ client0[mem]=256
client1[0]=client1 client1[0]=client1
client1[mem]=256 client1[mem]=256
log_server[0]=log_server log_server[0]=logserver
log_server[mem]=256 log_server[mem]=256
......
...@@ -3,9 +3,7 @@ import logging ...@@ -3,9 +3,7 @@ import logging
import logging.handlers import logging.handlers
import socketserver import socketserver
import struct import struct
from TestAssert import CustomFilter, Test1, Test2, Test3 from TestJoinPrune import CustomFilter, Test1, Test2, Test3, Test4, Test5
import sys
import threading
from queue import Queue from queue import Queue
q = Queue() q = Queue()
...@@ -24,7 +22,7 @@ def worker(): ...@@ -24,7 +22,7 @@ def worker():
class TestHandler(logging.StreamHandler): class TestHandler(logging.StreamHandler):
currentTest = Test1() currentTest = Test1()
currentTest.print_test() currentTest.print_test()
nextTests = [Test2(), Test3()] nextTests = [Test2(), Test3(), Test4(), Test5()]
main = None main = None
def emit(self, record): def emit(self, record):
...@@ -37,6 +35,7 @@ class TestHandler(logging.StreamHandler): ...@@ -37,6 +35,7 @@ class TestHandler(logging.StreamHandler):
TestHandler.currentTest = None TestHandler.currentTest = None
TestHandler.main.abort = True TestHandler.main.abort = True
class LogRecordStreamHandler(socketserver.StreamRequestHandler): class LogRecordStreamHandler(socketserver.StreamRequestHandler):
"""Handler for a streaming logging request. """Handler for a streaming logging request.
...@@ -76,11 +75,10 @@ class LogRecordSocketReceiver(socketserver.ThreadingTCPServer): ...@@ -76,11 +75,10 @@ class LogRecordSocketReceiver(socketserver.ThreadingTCPServer):
def __init__(self, host='localhost', def __init__(self, host='localhost',
port=logging.handlers.DEFAULT_TCP_LOGGING_PORT, port=logging.handlers.DEFAULT_TCP_LOGGING_PORT,
handler=LogRecordStreamHandler): handler=LogRecordStreamHandler):
handler.main = self TestHandler.main = self
socketserver.ThreadingTCPServer.__init__(self, (host, port), handler) socketserver.ThreadingTCPServer.__init__(self, (host, port), handler)
self.abort = 0 self.abort = 0
self.timeout = 1 self.timeout = 1
self.logname = None
def serve_until_stopped(self): def serve_until_stopped(self):
import select import select
...@@ -95,12 +93,14 @@ class LogRecordSocketReceiver(socketserver.ThreadingTCPServer): ...@@ -95,12 +93,14 @@ class LogRecordSocketReceiver(socketserver.ThreadingTCPServer):
def main(): def main():
import sys
handler = TestHandler(sys.stdout) handler = TestHandler(sys.stdout)
formatter = logging.Formatter('%(name)-50s %(levelname)-8s %(tree)-35s %(vif)-2s %(interfacename)-5s %(routername)-2s %(message)s') formatter = logging.Formatter('%(name)-50s %(levelname)-8s %(tree)-35s %(vif)-2s %(interfacename)-5s %(routername)-2s %(message)s')
handler.setFormatter(formatter) handler.setFormatter(formatter)
logging.getLogger('my_logger').addHandler(handler) logging.getLogger('my_logger').addHandler(handler)
logging.getLogger('my_logger').addFilter(CustomFilter()) logging.getLogger('my_logger').addFilter(CustomFilter())
import threading
t = threading.Thread(target=worker) t = threading.Thread(target=worker)
t.start() t.start()
......
import logging
from abc import ABCMeta
class CustomFilter(logging.Filter):
def filter(self, record):
return record.name in ("pim.KernelEntry.DownstreamInterface.Assert", "pim.KernelEntry.UpstreamInterface.Assert", "pim.KernelInterface") and \
record.routername in ["R1", "R2", "R3", "R4", "R5", "R6"]
class Test():
__metaclass__ = ABCMeta
def __init__(self, testName, expectedState, success):
self.testName = testName
self.expectedState = expectedState
self.success = success
def test(self, record):
if record.routername not in self.expectedState:
return False
if record.msg == self.expectedState.get(record.routername).get(record.interfacename):
self.success[record.routername][record.interfacename] = True
for interface_test in self.success.values():
if False in interface_test.values():
return False
print('\x1b[1;32;40m' + self.testName + ' Success' + '\x1b[0m')
return True
class Test1(Test):
def __init__(self):
expectedState = {"R2": {"eth1": "L"},
"R3": {"eth1": "L"},
"R4": {"eth1": "W"},
"R5": {"eth0": "L"},
"R6": {"eth0": "L"},
}
success = {"R2": {"eth1": False},
"R3": {"eth1": False},
"R4": {"eth1": False},
"R5": {"eth0": False},
"R6": {"eth0": False},
}
super().__init__("Test1", expectedState, success)
def print_test(self):
print("Test1: No info about (10.1.1.100,224.12.12.12)")
print("Expected: R4 WINNER")
class Test2(Test):
def __init__(self):
expectedState = {"R2": {"eth1": "L"},
"R3": {"eth1": "W"},
"R5": {"eth0": "L"},
"R6": {"eth0": "L"},
}
success = {"R2": {"eth1": False},
"R3": {"eth1": False},
"R5": {"eth0": False},
"R6": {"eth0": False},
}
super().__init__("Test2", expectedState, success)
def print_test(self):
print("Test2: Kill assert winner")
print("Expected: R3 WINNER")
class Test3(Test):
def __init__(self):
expectedState = {"R2": {"eth1": "NI"},
"R3": {"eth1": "NI"},
}
success = {"R2": {"eth1": False},
"R3": {"eth1": False},
}
super().__init__("Test3", expectedState, success)
def print_test(self):
print("Test3: CouldAssert of AssertWinner(R3) -> False")
print("Expected: everyone NI")
import logging
from abc import ABCMeta, abstractmethod
class CustomFilter(logging.Filter):
def filter(self, record):
return record.name in ("pim.KernelEntry.DownstreamInterface.JoinPrune", "pim.KernelEntry.UpstreamInterface.JoinPrune", "pim.KernelInterface") and \
record.routername in ["R1", "R2","R3","R4","R5","R6"]
class Test(object):
__metaclass__ = ABCMeta
def __init__(self, testName, expectedState, success):
self.testName = testName
self.expectedState = expectedState
self.success = success
def test(self, record):
if record.routername not in self.expectedState:
return False
if record.msg == self.expectedState.get(record.routername).get(record.interfacename):
self.success[record.routername][record.interfacename] = True
for interface_test in self.success.values():
if False in interface_test.values():
#print(self.expectedState)
#print(self.success)
return False
print('\x1b[1;32;40m' + self.testName + ' Success' + '\x1b[0m')
return True
@abstractmethod
def print_test(self):
pass
class Test1(Test):
def __init__(self):
expectedState = {"R1": {"eth0": "F", "eth1": "P", "eth2": "P", "eth3": "NI"}, # Only downstream interface connected to AssertWinner \
# in NI state and upstream interface connected to source\
# in Forward state
"R2": {"eth0": "P"}, # Assert Loser upstream interface in pruned state
"R3": {"eth0": "P"}, # Assert Loser upstream interface in pruned state
"R4": {"eth0": "F", "eth1": "NI"}, # Assert Winner upstream interface in forward state
"R5": {"eth0": "F"}, # Downstream router interested (client0)
"R6": {"eth0": "F"}, # Downstream router interested (client0)
}
success = {"R1": {"eth0": False, "eth1": False, "eth2": False, "eth3": False},
"R2": {"eth0": False},
"R3": {"eth0": False},
"R4": {"eth0": False, "eth1": False},
"R5": {"eth0": False},
"R6": {"eth0": False},
}
super().__init__("Test1", expectedState, success)
def print_test(self):
print("Test1: Formation of (S,G) Broadcast Tree")
print("Having Client0 and Client1 interested")
class Test2(Test):
def __init__(self):
expectedState = {"R4": {"eth1": "PP"}, # Assert Winner upstream interface in PP because of Prune msg
"R6": {"eth0": "P"}, # Downstream router not interested
}
success = {"R4": {"eth1": False},
"R6": {"eth0": False},
}
super().__init__("Test2", expectedState, success)
def print_test(self):
print("Test2: Client1 not interested in receiving traffic destined to group G")
print("R6 sends a Prune and R5 overrides the prune")
class Test3(Test):
def __init__(self):
expectedState = {"R4": {"eth1": "NI"}, # Assert Winner upstream interface in PP because of Join msg
}
success = {"R4": {"eth1": False},
}
super().__init__("Test3", expectedState, success)
def print_test(self):
print("Test3: R5 overrides prune via Join")
print("R4 should transition to Forward state")
class Test4(Test):
def __init__(self):
expectedState = {"R1": {"eth3": "P"}, # Only interface eth3 changes to Pruned state... eth1 is directly connected so it should stay in a Forward state
#"R2": {"eth0": "P"}, #R2 already in a Pruned state
#"R3": {"eth0": "P"}, #R3 already in a Pruned state
"R4": {"eth0": "P", "eth1": "P"}, # Assert Winner upstream interface in forward state
"R5": {"eth0": "P"}, # Downstream router interested (client0)
#"R6": {"eth0": "P"}, # R6 already in a Pruned state
}
success = {"R1": {"eth3": False},
"R4": {"eth0": False, "eth1": False},
"R5": {"eth0": False},
}
super().__init__("Test4", expectedState, success)
def print_test(self):
print("Test4: No client interested")
print("Prune tree")
class Test5(Test):
def __init__(self):
expectedState = {"R1": {"eth3": "NI"}, # R4 grafted this interface
"R4": {"eth0": "F", "eth1": "NI"}, # R5 grafted this interface
"R5": {"eth0": "F"}, # client0 interested
}
success = {"R1": {"eth3": False},
"R4": {"eth0": False, "eth1": False},
"R5": {"eth0": False},
}
super().__init__("Test5", expectedState, success)
def print_test(self):
print("Test5: client0 interested in receiving traffic")
print("Graft tree")
pip-3.2 install --index-url=https://pypi.python.org/simple/ netifaces
cp /hosthome/PycharmProjects/Test/ServerLog.py .
cp /hosthome/PycharmProjects/Test/TestAssert.py .
python3 ServerLog.py
tcpdump -i br0 -Q in -w /hosthome/Desktop/assert_capture.pcap rm /hosthome/Desktop/join_prune_graft_capture.pcap
tcpdump -i br0 -Q in -w /hosthome/Desktop/join_prune_graft_capture.pcap
topology.png

65.6 KB | W: | H:

topology.png

65 KB | W: | H:

topology.png
topology.png
topology.png
topology.png
  • 2-up
  • Swipe
  • Onion skin
<mxfile userAgent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36" version="8.0.6" editor="www.draw.io" type="device"><diagram name="Page-1" id="11f5d53f-c264-6b31-e1a8-d7fc60da157b">7V1bc5s4FP41fowHSYjLY5M0uzvTnelMd2a3Tx1iE5stRl6Q66S/fgVIGCFRkxgpiU14sDkg25zvOzoXHcgM3Wwef8uj7fpPsozTGXSWjzN0O4MQhL7HXkrJUy2BEIe1ZJUnS37WQfAl+RlzocOlu2QZF9KJlJCUJltZuCBZFi+oJIvynOzl0x5IKn/rNlrFiuDLIkpV6d/Jkq5raQC9g/z3OFmtxTcDj1/ffbT4vsrJLuPfN4PoofqrD28i8Vn8Qot1tCT7lgh9nKGbnBBav9s83sRpqVyhtn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jg+/QO83jiKIwDUtL/8ovtdl6aPg5BaXRmOkBKGeJeAl9tZttDhZc6i4FD3pIrU0FICTI4bzwox3EFM3Exiw7UBNbsGztxnm5nevBO7++UYAIpqk41eHwC0sfKw5z1qyC37j3Omd2ddxFWbAn1j9NY2BXpse4P0Rk6ntdq32D4JNF26E70HgAbltiIEVX9rjN5QG8G+2N/iC0Gss06teXahMX8LeyPaCbFfINaJkEJjiLHdw78Kqo61/iET+vg/</diagram></mxfile> <mxfile userAgent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36" version="8.3.2" editor="www.draw.io" type="device"><diagram name="Page-1" id="11f5d53f-c264-6b31-e1a8-d7fc60da157b">7V1bb6M4FP41eWyEba6P03Y6u9KsNNKstLtPFU3chB2Cs+A07fz6NWATfMmUJphcG2kaDtCE833n6gMzQneL1y95vJz/QaY4HUFn+jpC9yMIozBk/5aCt1oAAuDWklmeTLlsI/ie/MRc6HDpKpniQjqQEpLSZCkLJyTL8IRKsjjPyVo+7Jmk8qcu4xnWBN8ncapL/0qmdF5LQ+hv5L/hZDYXnwz8qN7zFE9+zHKyyvjnjSB6rn7q3YtY/C1+ocU8npJ1S4Q+j9BdTgit3y1e73Ba6laorT7vYcve5nvnOKNdTgj5GQV9E9eOp0wVfDMjGft1W10QLk9x2NacLlL2FrC3+DWhf5fisce3/qm2opBvfsN5ssAU5/xc9rXyt9YZ5eY/7X3qCQWNc/qphHTzdSrZQ5KmzYlT5Qgmae3/F1P6xkkWryhhIpLTOZmRLE6/ErLkV1PQnPzAdyQleaUKhJDDfpo9ggoMpdtnklH+Jxm36+3WmQ/VD5PrgAiNk1U+4SoX7GHXNcP8sMCrZSUcrRM5jF8wYVrK39gBOU5jmrzIzI25Acya4zYkYG84D7ZwwtmPExuIaxo0GG8gv0iUA1dHWSA/PMrBnig3lh8KW+em/77lA1+mBUQXzQvfOSpe9BMRQJsUHSgBZUpEl80IQzzw3YM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yZsfD2JtQUb0CsNwMpH9hKjrGrYPOCQHnKUSUYQRZqmmvnNtqpcvweG6yGDqQqyV9+qyolYdb6/8b1+dNcwSOjO04dA7anOODCN2Mum6iKnJ9oBhXau7lZD15LmjPbpspdFzfl9xaNA4ZzBsVnjXKQXYx2nwMdnNqyGoFx4GWebfUsBJtLHPDgM6n0OY9jxvobDgaE55mmS4wmXsGKnVGYvztrXAUImO+kDoA6LfVUjsft1NQ8r4JCM2jf8GzMgZWnGMMltq9zwL6ln02D9PhOHUL2pBt+3ZHBPsWT4AC5ir+zSkX57la2KITKtQA/sL9T+BBrQX5jaE2frL8ItiB3GX9hoMaCT9BfdcRF75UlfOFxjKNIrmMH9BXTkZcIh8wvnkvxFtAWxw/gL/b6L/f0FPEl/0R0XsRfKAXbAjqSjWwyrGIGhYuxYy1+LSo6hjOkNcPSs0TWginpBVQ/eDFV4EahWjUhbqCLlHp5ID+32QN3aY9OaO+iK2BbEhjRCveJmeCETXidlYT6yCFegGph+/5Y9wDp3T4WI6Sn7iCdt90uUc08H/kCBf40L2g/6rkhpOPo69rb6ss2TcN7Pg06rc+5ZNNamcc7hEs9zG8RWjY8dAqZnDOnTaMdULewQ0WQjMTwhxNbyEnD09sLu1UKJjXtKtnTjQXvG5CpNI1/vmlgzJmAsArcEPvMzvI4cxR4AasZffjH9birT+0FI7650R0hLQ/xLwMtVli1MeNmzKNg1POkiPbWUAJPzxrNCzFMQEzeTDBHagF5dA2ccsNcRzua5rpwDQNFtGmLWBwBjrtztkY8Gcsvx45zprayLuPpQoK1nuwHzU1R99jpCeiNHGa0OBhyfBIYp3Su9O4AG5bEiBPV4a43e0JjB7hxvvQtBTFmnNjy70Fq8hVsz2itiv0BMyZAia4ixzc3/FlTta/2XTOjz/w==</diagram></mxfile>
\ No newline at end of file \ No newline at end of file
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