Commit 8c035030 authored by Pedro Oliveira's avatar Pedro Oliveira

Test neighbors/hello using logging events

parent ce962a7a
Script started on Sun Jul 22 17:48:54 2018
root@switch1:~# tcpdump -i br0 -Q in -w /hosh thome/Desktop/p test_pim/TestNeighbor1.txt   pcap &
[1] 1566
root@switch1:~# tcpdump: listening on br0, link-type EN10MB (Ethernet), capture size 262144 bytes
root@switch1:~# python3 ServerLog.py
About to start TCP server...
pim.Interface DEBUG 2018-07-22 17:50:19,356 0 eth0 R1 Send Hello message
pim.Interface DEBUG 2018-07-22 17:50:25,854 0 eth0 R2 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 17:50:25,913 0 eth0 R1 Monitoring new neighbor 10.0.0.2 with GenerationID: 3312157476; HelloHoldTime: 105; StateRefreshCapable: False
pim.Interface.Neighbor DEBUG 2018-07-22 17:50:25,914 0 eth0 R1 Neighbor Liveness Timer reseted of 10.0.0.2
pim.Interface DEBUG 2018-07-22 17:50:30,449 0 eth0 R1 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 17:50:30,463 0 eth0 R2 Monitoring new neighbor 10.0.0.1 with GenerationID: 1217533332; HelloHoldTime: 105; StateRefreshCapable: False
pim.Interface.Neighbor DEBUG 2018-07-22 17:50:30,463 0 eth0 R2 Neighbor Liveness Timer reseted of 10.0.0.1
pim.Interface DEBUG 2018-07-22 17:50:31,433 0 eth0 R2 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 17:50:31,442 0 eth0 R1 Receive Hello message with HelloHoldTime: 105; GenerationID: 3312157476; StateRefreshCapable: False from neighbor 10.0.0.2
pim.Interface.Neighbor DEBUG 2018-07-22 17:50:31,443 0 eth0 R1 Neighbor Liveness Timer reseted of 10.0.0.2
pim.Interface DEBUG 2018-07-22 17:51:00,481 0 eth0 R1 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 17:51:00,489 0 eth0 R2 Receive Hello message with HelloHoldTime: 105; GenerationID: 1217533332; StateRefreshCapable: False from neighbor 10.0.0.1
pim.Interface.Neighbor DEBUG 2018-07-22 17:51:00,493 0 eth0 R2 Neighbor Liveness Timer reseted of 10.0.0.1
pim.Interface DEBUG 2018-07-22 17:51:01,474 0 eth0 R2 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 17:51:01,483 0 eth0 R1 Receive Hello message with HelloHoldTime: 105; GenerationID: 3312157476; StateRefreshCapable: False from neighbor 10.0.0.2
pim.Interface.Neighbor DEBUG 2018-07-22 17:51:01,487 0 eth0 R1 Neighbor Liveness Timer reseted of 10.0.0.2
pim.Interface DEBUG 2018-07-22 17:51:30,547 0 eth0 R1 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 17:51:30,551 0 eth0 R2 Receive Hello message with HelloHoldTime: 105; GenerationID: 1217533332; StateRefreshCapable: False from neighbor 10.0.0.1
pim.Interface.Neighbor DEBUG 2018-07-22 17:51:30,552 0 eth0 R2 Neighbor Liveness Timer reseted of 10.0.0.1
pim.Interface DEBUG 2018-07-22 17:51:31,530 0 eth0 R2 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 17:51:31,536 0 eth0 R1 Receive Hello message with HelloHoldTime: 105; GenerationID: 3312157476; StateRefreshCapable: False from neighbor 10.0.0.2
pim.Interface.Neighbor DEBUG 2018-07-22 17:51:31,538 0 eth0 R1 Neighbor Liveness Timer reseted of 10.0.0.2
pim.Interface DEBUG 2018-07-22 17:52:00,592 0 eth0 R1 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 17:52:00,598 0 eth0 R2 Receive Hello message with HelloHoldTime: 105; GenerationID: 1217533332; StateRefreshCapable: False from neighbor 10.0.0.1
pim.Interface.Neighbor DEBUG 2018-07-22 17:52:00,601 0 eth0 R2 Neighbor Liveness Timer reseted of 10.0.0.1
pim.Interface DEBUG 2018-07-22 17:52:01,549 0 eth0 R2 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 17:52:01,559 0 eth0 R1 Receive Hello message with HelloHoldTime: 105; GenerationID: 3312157476; StateRefreshCapable: False from neighbor 10.0.0.2
pim.Interface.Neighbor DEBUG 2018-07-22 17:52:01,563 0 eth0 R1 Neighbor Liveness Timer reseted of 10.0.0.2
pim.Interface DEBUG 2018-07-22 17:52:30,660 0 eth0 R1 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 17:52:30,666 0 eth0 R2 Receive Hello message with HelloHoldTime: 105; GenerationID: 1217533332; StateRefreshCapable: False from neighbor 10.0.0.1
pim.Interface.Neighbor DEBUG 2018-07-22 17:52:30,668 0 eth0 R2 Neighbor Liveness Timer reseted of 10.0.0.1
pim.Interface DEBUG 2018-07-22 17:52:31,614 0 eth0 R2 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 17:52:31,625 0 eth0 R1 Receive Hello message with HelloHoldTime: 105; GenerationID: 3312157476; StateRefreshCapable: False from neighbor 10.0.0.2
pim.Interface.Neighbor DEBUG 2018-07-22 17:52:31,630 0 eth0 R1 Neighbor Liveness Timer reseted of 10.0.0.2
pim.Interface DEBUG 2018-07-22 17:53:00,691 0 eth0 R1 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 17:53:00,694 0 eth0 R2 Receive Hello message with HelloHoldTime: 105; GenerationID: 1217533332; StateRefreshCapable: False from neighbor 10.0.0.1
pim.Interface.Neighbor DEBUG 2018-07-22 17:53:00,695 0 eth0 R2 Neighbor Liveness Timer reseted of 10.0.0.1
pim.Interface DEBUG 2018-07-22 17:53:01,674 0 eth0 R2 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 17:53:01,684 0 eth0 R1 Receive Hello message with HelloHoldTime: 105; GenerationID: 3312157476; StateRefreshCapable: False from neighbor 10.0.0.2
pim.Interface.Neighbor DEBUG 2018-07-22 17:53:01,685 0 eth0 R1 Neighbor Liveness Timer reseted of 10.0.0.2
pim.Interface DEBUG 2018-07-22 17:53:30,712 0 eth0 R1 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 17:53:30,720 0 eth0 R2 Receive Hello message with HelloHoldTime: 105; GenerationID: 1217533332; StateRefreshCapable: False from neighbor 10.0.0.1
pim.Interface.Neighbor DEBUG 2018-07-22 17:53:30,721 0 eth0 R2 Neighbor Liveness Timer reseted of 10.0.0.1
pim.Interface DEBUG 2018-07-22 17:53:31,703 0 eth0 R2 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 17:53:31,712 0 eth0 R1 Receive Hello message with HelloHoldTime: 105; GenerationID: 3312157476; StateRefreshCapable: False from neighbor 10.0.0.2
pim.Interface.Neighbor DEBUG 2018-07-22 17:53:31,725 0 eth0 R1 Neighbor Liveness Timer reseted of 10.0.0.2
^CTraceback (most recent call last):
File "ServerLog.py", line 105, in <module>
main()
File "ServerLog.py", line 101, in main
tcpserver.serve_until_stopped()
File "ServerLog.py", line 83, in serve_until_stopped
self.timeout)
KeyboardInterrupt
^CException KeyboardInterrupt: KeyboardInterrupt() in <module 'threading' from '/usr/lib/python3.2/threading.py'> ignored
root@switch1:~# fg
tcpdump -i br0 -Q in -w /hosthome/Desktop/test_pim/TestNeighbor1.pcap
^C98 packets captured
162 packets received by filter
0 packets dropped by kernel
root@switch1:~# exit
exit
Script done on Sun Jul 22 17:53:49 2018
Script started on Sun Jul 22 17:56:45 2018
root@switch1:~# exitfgpython3 ServerLog.py root@switch1:~# tcpdump -i br0 -Q in -w /hosthome/Desktop/test_pim/TestNeighbor2.pcap &
[1] 1588
root@switch1:~# tcpdump: listening on br0, link-type EN10MB (Ethernet), capture size 262144 bytes
root@switch1:~# tcpdump -i br0 -Q in -w /hosthome/Desktop/test_pim/TestNeighbor2.pcap & root@switch1:~# exitfgpython3 ServerLog.py
About to start TCP server...
pim.Interface DEBUG 2018-07-22 17:57:26,060 0 eth0 R1 Send Hello message
pim.Interface DEBUG 2018-07-22 17:57:41,093 0 eth0 R2 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 17:57:41,113 0 eth0 R1 Monitoring new neighbor 10.0.0.2 with GenerationID: 3806743712; HelloHoldTime: 105; StateRefreshCapable: False
pim.Interface.Neighbor DEBUG 2018-07-22 17:57:41,113 0 eth0 R1 Neighbor Liveness Timer reseted of 10.0.0.2
pim.Interface DEBUG 2018-07-22 17:57:46,127 0 eth0 R1 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 17:57:46,146 0 eth0 R2 Monitoring new neighbor 10.0.0.1 with GenerationID: 3164982407; HelloHoldTime: 105; StateRefreshCapable: False
pim.Interface.Neighbor DEBUG 2018-07-22 17:57:46,147 0 eth0 R2 Neighbor Liveness Timer reseted of 10.0.0.1
pim.Interface DEBUG 2018-07-22 17:57:46,523 0 eth0 R2 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 17:57:46,538 0 eth0 R1 Receive Hello message with HelloHoldTime: 105; GenerationID: 3806743712; StateRefreshCapable: False from neighbor 10.0.0.2
pim.Interface.Neighbor DEBUG 2018-07-22 17:57:46,545 0 eth0 R1 Neighbor Liveness Timer reseted of 10.0.0.2
pim.Interface DEBUG 2018-07-22 17:58:16,162 0 eth0 R1 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 17:58:16,168 0 eth0 R2 Receive Hello message with HelloHoldTime: 105; GenerationID: 3164982407; StateRefreshCapable: False from neighbor 10.0.0.1
pim.Interface.Neighbor DEBUG 2018-07-22 17:58:16,170 0 eth0 R2 Neighbor Liveness Timer reseted of 10.0.0.1
pim.Interface DEBUG 2018-07-22 17:58:16,608 0 eth0 R2 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 17:58:16,616 0 eth0 R1 Receive Hello message with HelloHoldTime: 105; GenerationID: 3806743712; StateRefreshCapable: False from neighbor 10.0.0.2
pim.Interface.Neighbor DEBUG 2018-07-22 17:58:16,622 0 eth0 R1 Neighbor Liveness Timer reseted of 10.0.0.2
pim.Interface DEBUG 2018-07-22 17:58:30,542 0 eth0 R2 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 17:58:30,550 0 eth0 R1 Receive Hello message with HelloHoldTime: 105; GenerationID: 1471879794; StateRefreshCapable: False from neighbor 10.0.0.2
pim.Interface.Neighbor DEBUG 2018-07-22 17:58:30,551 0 eth0 R1 Detected reset of 10.0.0.2... new GenerationID: 1471879794
pim.Interface.Neighbor DEBUG 2018-07-22 17:58:30,566 0 eth0 R1 Neighbor Liveness Timer reseted of 10.0.0.2
pim.Interface DEBUG 2018-07-22 17:58:30,611 0 eth0 R1 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 17:58:30,701 0 eth0 R2 Monitoring new neighbor 10.0.0.1 with GenerationID: 3164982407; HelloHoldTime: 105; StateRefreshCapable: False
pim.Interface.Neighbor DEBUG 2018-07-22 17:58:30,702 0 eth0 R2 Neighbor Liveness Timer reseted of 10.0.0.1
pim.Interface DEBUG 2018-07-22 17:58:32,890 0 eth0 R2 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 17:58:32,899 0 eth0 R1 Receive Hello message with HelloHoldTime: 105; GenerationID: 1471879794; StateRefreshCapable: False from neighbor 10.0.0.2
pim.Interface.Neighbor DEBUG 2018-07-22 17:58:32,900 0 eth0 R1 Neighbor Liveness Timer reseted of 10.0.0.2
pim.Interface DEBUG 2018-07-22 17:59:00,673 0 eth0 R1 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 17:59:00,680 0 eth0 R2 Receive Hello message with HelloHoldTime: 105; GenerationID: 3164982407; StateRefreshCapable: False from neighbor 10.0.0.1
pim.Interface.Neighbor DEBUG 2018-07-22 17:59:00,681 0 eth0 R2 Neighbor Liveness Timer reseted of 10.0.0.1
pim.Interface DEBUG 2018-07-22 17:59:02,920 0 eth0 R2 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 17:59:02,931 0 eth0 R1 Receive Hello message with HelloHoldTime: 105; GenerationID: 1471879794; StateRefreshCapable: False from neighbor 10.0.0.2
pim.Interface.Neighbor DEBUG 2018-07-22 17:59:02,934 0 eth0 R1 Neighbor Liveness Timer reseted of 10.0.0.2
pim.Interface DEBUG 2018-07-22 17:59:30,701 0 eth0 R1 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 17:59:30,707 0 eth0 R2 Receive Hello message with HelloHoldTime: 105; GenerationID: 3164982407; StateRefreshCapable: False from neighbor 10.0.0.1
pim.Interface.Neighbor DEBUG 2018-07-22 17:59:30,707 0 eth0 R2 Neighbor Liveness Timer reseted of 10.0.0.1
pim.Interface DEBUG 2018-07-22 17:59:32,992 0 eth0 R2 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 17:59:33,003 0 eth0 R1 Receive Hello message with HelloHoldTime: 105; GenerationID: 1471879794; StateRefreshCapable: False from neighbor 10.0.0.2
pim.Interface.Neighbor DEBUG 2018-07-22 17:59:33,009 0 eth0 R1 Neighbor Liveness Timer reseted of 10.0.0.2
pim.Interface DEBUG 2018-07-22 18:00:00,726 0 eth0 R1 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 18:00:00,733 0 eth0 R2 Receive Hello message with HelloHoldTime: 105; GenerationID: 3164982407; StateRefreshCapable: False from neighbor 10.0.0.1
pim.Interface.Neighbor DEBUG 2018-07-22 18:00:00,735 0 eth0 R2 Neighbor Liveness Timer reseted of 10.0.0.1
pim.Interface DEBUG 2018-07-22 18:00:03,064 0 eth0 R2 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 18:00:03,074 0 eth0 R1 Receive Hello message with HelloHoldTime: 105; GenerationID: 1471879794; StateRefreshCapable: False from neighbor 10.0.0.2
pim.Interface.Neighbor DEBUG 2018-07-22 18:00:03,077 0 eth0 R1 Neighbor Liveness Timer reseted of 10.0.0.2
^CTraceback (most recent call last):
File "ServerLog.py", line 105, in <module>
main()
File "ServerLog.py", line 101, in main
tcpserver.serve_until_stopped()
File "ServerLog.py", line 83, in serve_until_stopped
self.timeout)
KeyboardInterrupt
^CException KeyboardInterrupt: KeyboardInterrupt() in <module 'threading' from '/usr/lib/python3.2/threading.py'> ignored
root@switch1:~# fg
tcpdump -i br0 -Q in -w /hosthome/Desktop/test_pim/TestNeighbor2.pcap
^C95 packets captured
157 packets received by filter
0 packets dropped by kernel
root@switch1:~# exit
exit
Script done on Sun Jul 22 18:00:13 2018
Script started on Sun Jul 22 18:00:55 2018
root@switch1:~# exitfgpython3 ServerLog.py root@switch1:~# tcpdump -i br0 -Q in -w /hosthome/Desktop/test_pim/TestNeighbor2.pcap &[1@3
[1] 1606
root@switch1:~# tcpdump: listening on br0, link-type EN10MB (Ethernet), capture size 262144 bytes
root@switch1:~# tcpdump -i br0 -Q in -w /hosthome/Desktop/test_pim/TestNeighbor3.pcap & root@switch1:~# exitfgpython3 ServerLog.py
About to start TCP server...
pim.Interface DEBUG 2018-07-22 18:01:13,411 0 eth0 R1 Send Hello message
pim.Interface DEBUG 2018-07-22 18:01:17,640 0 eth0 R2 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 18:01:17,656 0 eth0 R1 Monitoring new neighbor 10.0.0.2 with GenerationID: 2817810609; HelloHoldTime: 105; StateRefreshCapable: False
pim.Interface.Neighbor DEBUG 2018-07-22 18:01:17,656 0 eth0 R1 Neighbor Liveness Timer reseted of 10.0.0.2
pim.Interface DEBUG 2018-07-22 18:01:19,715 0 eth0 R1 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 18:01:19,744 0 eth0 R2 Monitoring new neighbor 10.0.0.1 with GenerationID: 3534546943; HelloHoldTime: 105; StateRefreshCapable: False
pim.Interface.Neighbor DEBUG 2018-07-22 18:01:19,744 0 eth0 R2 Neighbor Liveness Timer reseted of 10.0.0.1
pim.Interface DEBUG 2018-07-22 18:01:21,667 0 eth0 R2 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 18:01:21,676 0 eth0 R1 Receive Hello message with HelloHoldTime: 105; GenerationID: 2817810609; StateRefreshCapable: False from neighbor 10.0.0.2
pim.Interface.Neighbor DEBUG 2018-07-22 18:01:21,676 0 eth0 R1 Neighbor Liveness Timer reseted of 10.0.0.2
pim.Interface DEBUG 2018-07-22 18:01:49,737 0 eth0 R1 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 18:01:49,745 0 eth0 R2 Receive Hello message with HelloHoldTime: 105; GenerationID: 3534546943; StateRefreshCapable: False from neighbor 10.0.0.1
pim.Interface.Neighbor DEBUG 2018-07-22 18:01:49,754 0 eth0 R2 Neighbor Liveness Timer reseted of 10.0.0.1
pim.Interface DEBUG 2018-07-22 18:01:51,696 0 eth0 R2 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 18:01:51,707 0 eth0 R1 Receive Hello message with HelloHoldTime: 105; GenerationID: 2817810609; StateRefreshCapable: False from neighbor 10.0.0.2
pim.Interface.Neighbor DEBUG 2018-07-22 18:01:51,708 0 eth0 R1 Neighbor Liveness Timer reseted of 10.0.0.2
pim.Interface DEBUG 2018-07-22 18:02:19,802 0 eth0 R1 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 18:02:19,810 0 eth0 R2 Receive Hello message with HelloHoldTime: 105; GenerationID: 3534546943; StateRefreshCapable: False from neighbor 10.0.0.1
pim.Interface.Neighbor DEBUG 2018-07-22 18:02:19,812 0 eth0 R2 Neighbor Liveness Timer reseted of 10.0.0.1
pim.Interface DEBUG 2018-07-22 18:02:21,723 0 eth0 R2 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 18:02:21,733 0 eth0 R1 Receive Hello message with HelloHoldTime: 105; GenerationID: 2817810609; StateRefreshCapable: False from neighbor 10.0.0.2
pim.Interface.Neighbor DEBUG 2018-07-22 18:02:21,733 0 eth0 R1 Neighbor Liveness Timer reseted of 10.0.0.2
pim.Interface DEBUG 2018-07-22 18:02:49,824 0 eth0 R1 Send Hello message
pim.Interface DEBUG 2018-07-22 18:03:19,851 0 eth0 R1 Send Hello message
pim.Interface DEBUG 2018-07-22 18:03:49,873 0 eth0 R1 Send Hello message
pim.Interface.Neighbor DEBUG 2018-07-22 18:04:06,757 0 eth0 R1 Neighbor Liveness Timer expired of 10.0.0.2
pim.Interface DEBUG 2018-07-22 18:04:06,760 0 eth0 R1 Remove neighbor: 10.0.0.2
pim.Interface DEBUG 2018-07-22 18:04:19,925 0 eth0 R1 Send Hello message
pim.Interface DEBUG 2018-07-22 18:04:49,945 0 eth0 R1 Send Hello message
^CTraceback (most recent call last):
File "ServerLog.py", line 105, in <module>
main()
File "ServerLog.py", line 101, in main
tcpserver.serve_until_stopped()
File "ServerLog.py", line 83, in serve_until_stopped
self.timeout)
KeyboardInterrupt
^CException KeyboardInterrupt: KeyboardInterrupt() in <module 'threading' from '/usr/lib/python3.2/threading.py'> ignored
root@switch1:~# fg
tcpdump -i br0 -Q in -w /hosthome/Desktop/test_pim/TestNeighbor3.pcap
^C78 packets captured
121 packets received by filter
0 packets dropped by kernel
root@switch1:~# exit
exit
Script done on Sun Jul 22 18:04:56 2018
import rpyc
import time
from subprocess import Popen
def test_neighbor_table(router_id_str, router_rpc, expected_neighbors):
print("\ttesting " + router_id_str)
success = False
while not success:
(table, dict) = router_rpc.root.get_neighbors()
if "eth0" in dict:
neighbors_of_eth = dict["eth0"]
elif len(expected_neighbors) != 0:
print("\t\x1b[1;31;20m[NOT OK]\x1b[0m " + router_id_str + " table empty")
time.sleep(5)
continue
else:
print("\t\x1b[1;32;40m[OK]\x1b[0m " + router_id_str + " neighbor table is empty")
break
if len(expected_neighbors) != len(neighbors_of_eth):
print("\t\x1b[1;31;20m[NOT OK]\x1b[0m " + router_id_str + " different number of neighbors")
time.sleep(5)
continue
success = True
for n in expected_neighbors:
if (n not in neighbors_of_eth):
print("\t\x1b[1;31;20m[NOT OK]\x1b[0m " + router_id_str + " doesn't know about " + n)
print("\t ... trying again ...")
success = False
time.sleep(2)
break
print("\t\x1b[1;32;20m[OK]\x1b[0m " + router_id_str + " success")
print(table + "\n\n\n")
return dict
print("START TCPDUMP CAPTURE")
p = Popen(['tcpdump', '-i', 'br0', '-w', './capture.pcap'])
ips = ["10.0.0.1", "10.0.0.2", "10.0.0.3", "10.0.0.4"]
expected_neighbors = [["10.0.0.2", "10.0.0.3", "10.0.0.4"], ["10.0.0.1", "10.0.0.3", "10.0.0.4"], ["10.0.0.1", "10.0.0.2", "10.0.0.4"], ["10.0.0.2", "10.0.0.3", "10.0.0.1"]]
r1 = rpyc.connect("10.0.0.1", 10000)
r2 = rpyc.connect("10.0.0.2", 10000)
r3 = rpyc.connect("10.0.0.3", 10000)
r4 = rpyc.connect("10.0.0.4", 10000)
print("Test1: Start PIM process and check if neighbor tables are empty")
test_neighbor_table("R1", r1, [])
test_neighbor_table("R2", r2, [])
test_neighbor_table("R3", r3, [])
test_neighbor_table("R4", r4, [])
print("\x1b[1;32;20m[OK]\x1b[0m Test1 success")
print("============================\n\n\n")
print("Enabling R1's interface eth0...")
r1.root.add_interface("eth0")
print("Enabling R2's interface eth0...")
r2.root.add_interface("eth0")
print("Enabling R3's interface eth0...")
r3.root.add_interface("eth0")
print("Enabling R4's interface eth0...")
r4.root.add_interface("eth0")
print("Test2: Check if routers establish neighborship relations")
dict = test_neighbor_table("R1", r1, expected_neighbors[0])
test_neighbor_table("R2", r2, expected_neighbors[1])
test_neighbor_table("R3", r3, expected_neighbors[2])
test_neighbor_table("R4", r4, expected_neighbors[3])
print("\x1b[1;32;20m[OK]\x1b[0m Test2 Success")
print("============================\n\n\n")
print("Test3: Disable Router3 and check if others router react to R3 HelloHoldTime=0")
print("Disabling R3's interface eth0...")
r3.root.remove_interface("eth0")
expected_neighbors = [["10.0.0.2", "10.0.0.4"], ["10.0.0.1", "10.0.0.4"], [], ["10.0.0.2", "10.0.0.1"]]
test_neighbor_table("R1", r1, expected_neighbors[0])
test_neighbor_table("R2", r2, expected_neighbors[1])
test_neighbor_table("R4", r4, expected_neighbors[3])
print("\x1b[1;32;20m[OK]\x1b[0m Test3 success")
print("============================\n\n\n")
print("Test4: KILL router (doesn't send Hello with HelloHoldTime set to 0) and check if others remove that router after timeout")
print("Route4 has HelloHoldTime set to: " + str(dict["eth0"]["10.0.0.4"][0]))
print("Killing router4...")
r4.root.kill()
print("Waiting for " + str(str(dict["eth0"]["10.0.0.4"][0])) + " seconds...")
time.sleep(int(dict["eth0"]["10.0.0.4"][0]))
expected_neighbors = [["10.0.0.2"], ["10.0.0.1"], [], []]
test_neighbor_table("R1", r1, expected_neighbors[0])
test_neighbor_table("R2", r2, expected_neighbors[1])
print("\x1b[1;32;20m[OK]\x1b[0m Test4 success")
print("============================\n\n\n")
print("Test5: ReEnable router R3 and check if Generation ID is different")
print("R3 had old GenerationID set to: " + str(dict["eth0"]["10.0.0.3"][1]))
print("Enabling router3...")
r3.root.add_interface("eth0")
print("Enabled router3...")
expected_neighbors = [["10.0.0.2", "10.0.0.3"], ["10.0.0.1", "10.0.0.3"], ["10.0.0.1", "10.0.0.2"], []]
new_dict_r1 = test_neighbor_table("R1", r1, expected_neighbors[0])
new_dict_r2 = test_neighbor_table("R2", r2, expected_neighbors[1])
new_dict_r3 = test_neighbor_table("R3", r3, expected_neighbors[2])
print("R1 has in its neighbor table, R3 with GenerationID set to: " + new_dict_r1["eth0"]["10.0.0.3"][1])
print("R2 has in its neighbor table, R3 with GenerationID set to: " + new_dict_r2["eth0"]["10.0.0.3"][1])
if new_dict_r1["eth0"]["10.0.0.3"][1] == new_dict_r2["eth0"]["10.0.0.3"][1]:
print("\x1b[1;32;20m[OK]\x1b[0m R1 and R2 have same R3's GenerationID")
else:
print("\x1b[1;31;20m[NOT OK]\x1b[0m R1 and R2 have different R3's GenerationID")
exit()
if dict["eth0"]["10.0.0.3"][1] != new_dict_r2["eth0"]["10.0.0.3"][1]:
print("\x1b[1;32;20m[OK]\x1b[0m old and new GenerationID are differents (" + dict["eth0"]["10.0.0.3"][1] + " != " + new_dict_r1["eth0"]["10.0.0.3"][1] + ")")
else:
print("\x1b[1;31;20m[NOT OK]\x1b[0m old and new GenerationID are equal (" + dict["eth0"]["10.0.0.3"][1] + " == " + new_dict_r1["eth0"]["10.0.0.3"][1] + ")")
exit()
print("FINISH TCPDUMP CAPTURE")
p.terminate()
\ No newline at end of file
import rpyc
import socket
import _pickle as pickle
from argparse import Namespace
import os
class MyService(rpyc.Service):
daemon = None
def client_socket(self, data_to_send):
# Create a UDS socket
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
# Connect the socket to the port where the server is listening
server_address = './uds_socket'
# print('connecting to %s' % server_address)
try:
sock.connect(server_address)
sock.sendall(pickle.dumps(data_to_send))
data_rcv = sock.recv(1024 * 256)
if data_rcv:
return pickle.loads(data_rcv)
except socket.error as error:
print(error)
pass
finally:
# print('closing socket')
sock.close()
def on_connect(self):
# code that runs when a connection is created
# (to init the serivce, if needed)
os.system("python3 Run.py -restart")
pass
def on_disconnect(self):
# code that runs when the connection has already closed
# (to finalize the service, if needed)
pass
def exposed_kill(self):
import signal
with open("/tmp/Daemon-pim.pid", 'r') as pf:
pid = int(pf.read().strip())
os.kill(pid, signal.SIGTERM)
def exposed_add_interface(self, interface_name):
self.client_socket(Namespace(add_interface_igmp=[interface_name]))
self.client_socket(Namespace(add_interface=[interface_name]))
def exposed_remove_interface(self, interface_name):
self.client_socket(Namespace(remove_interface_igmp=[interface_name]))
self.client_socket(Namespace(remove_interface=[interface_name]))
def exposed_get_neighbors(self): # this is an exposed method
import re
table_list_neighbors = self.client_socket(Namespace(list_neighbors=True))
#x = table_list_neighbors.replace("-", "").replace("+", "").replace("\n", "").replace(" ", "").split("|")
x = re.sub(r"[\s\-\+]+", "", table_list_neighbors).split("|")
x = list(filter(lambda a: a != '', x))
dict = {}
for i in range(5, len(x), 5):
print(x[i+1])
if x[i] not in dict:
dict[x[i]] = {x[i+1]: [x[i+2], x[i+3], x[i+4]]}
else:
dict[x[i]][x[i+1]] = [x[i+2], x[i+3], x[i+4]]
return (table_list_neighbors, dict)
def exposed_list_igm_state(self): # this is an exposed method
x = self.client_socket(Namespace(list_state=True))
x = x.split("Multicast Routing State:")[0]
x = x.replace(" - ", "No")
x = x.replace("-", "").replace("+", "").replace("\n", "").replace(" ", "").split("|")
x = list(filter(lambda a: a != '', x))
for i in range(0, len(x), 4):
print(x[i+1])
def exposed_list_state(self): # this is an exposed method
x = self.client_socket(Namespace(list_state=True))
x = x.split("Multicast Routing State:")[1]
x = x.replace(" - ", "No")
x = x.replace("-", "").replace("+", "").replace("\n", "").replace(" ", "").split("|")
x = list(filter(lambda a: a != '', x))
for i in range(0, len(x), 7):
print(x[i+1])
def get_question(self): # while this method is not exposed
return "what is the airspeed velocity of an unladen swallow?"
if __name__ == "__main__":
from rpyc.utils.server import ThreadedServer
t = ThreadedServer(MyService, port = 10000)
t.start()
\ No newline at end of file
......@@ -2,9 +2,3 @@ ip addr add dev eth0 10.0.0.1/24
ip link set dev eth0 up
#NAT for private ip's
iptables -t nat -A POSTROUTING -s 0.0.0.0/0 -o eth1 -j MASQUERADE
#apt-get update && apt-get --assume-yes install python3 python3-pip
rm -rf MulticastRouting/
cp -rf /hosthome/Desktop/pim/ MulticastRouting/
cd MulticastRouting
pip-3.2 install --index-url=https://pypi.python.org/simple/ -r requirements.txt
python3 Server.py
python3 Run.py -stop
python3 Run.py -start
python3 Run.py -t R1 10.0.0.5
python3 Run.py -ai eth0
python3 Run.py -v
ip addr add dev eth0 10.0.0.2/24
ip link set dev eth0 up
#default route para obter conectividade internet
ip route add 0.0.0.0/0 via 10.0.0.1
# install python
#apt-get update && apt-get --assume-yes install python3 python3-pip
rm -rf MulticastRouting/
cp -rf /hosthome/Desktop/pim/ MulticastRouting/
cd MulticastRouting
pip-3.2 install --index-url=https://pypi.python.org/simple/ -r requirements.txt
python3 Server.py
python3 Run.py -stop
python3 Run.py -start
python3 Run.py -t R2 10.0.0.5
python3 Run.py -ai eth0
python3 Run.py -v
ip addr add dev eth0 10.0.0.3/24
ip link set dev eth0 up
#default route para obter conectividade internet
ip route add 0.0.0.0/0 via 10.0.0.1
# install python
#apt-get update && apt-get --assume-yes install python3 python3-pip
rm -rf MulticastRouting/
cp -rf /hosthome/Desktop/pim/ MulticastRouting/
cd MulticastRouting
pip-3.2 install --index-url=https://pypi.python.org/simple/ -r requirements.txt
python3 Server.py
python3 Run.py -stop
python3 Run.py -start
python3 Run.py -t R3 10.0.0.5
python3 Run.py -ai eth0
python3 Run.py -v
ip addr add dev eth0 10.0.0.4/24
ip link set dev eth0 up
#default route para obter conectividade internet
ip route add 0.0.0.0/0 via 10.0.0.1
# install python
#apt-get update && apt-get --assume-yes install python3 python3-pip
rm -rf MulticastRouting/
cp -rf /hosthome/Desktop/pim/ MulticastRouting/
cd MulticastRouting
pip-3.2 install --index-url=https://pypi.python.org/simple/ -r requirements.txt
python3 Server.py
python3 Run.py -stop
python3 Run.py -start
python3 Run.py -t R4 10.0.0.5
python3 Run.py -ai eth0
python3 Run.py -v
......@@ -10,11 +10,6 @@ brctl addif br0 eth3
ip link set dev br0 up
ip addr add dev br0 10.0.0.5/24
#default route para obter conectividade internet
ip route add 0.0.0.0/0 via 10.0.0.1
# install python
#apt-get update && apt-get --assume-yes install python3 python3-pip
# identify ports with routers (they need to receive all multicast traffic!)
echo "2" > /sys/devices/virtual/net/br0/brif/eth0/multicast_router
......
import pickle
import logging
import logging.handlers
import socketserver
import struct
import sys
import threading
from queue import Queue
q = Queue()
def worker():
while True:
item = q.get()
if item is None:
break
logger = logging.getLogger('my_logger')
logger.handle(item)
q.task_done()
class TestHandler(logging.StreamHandler):
def emit(self, record):
super().emit(record)
class CustomFilter(logging.Filter):
def filter(self, record):
return record.name in ("pim.Interface.Neighbor", 'pim.Interface') and record.routername in ["R1", "R2"]
class LogRecordStreamHandler(socketserver.StreamRequestHandler):
"""Handler for a streaming logging request.
This basically logs the record using whatever logging policy is
configured locally.
"""
def handle(self):
"""
Handle multiple requests - each expected to be a 4-byte length,
followed by the LogRecord in pickle format. Logs the record
according to whatever policy is configured locally.
"""
while True:
chunk = self.connection.recv(4)
if len(chunk) < 4:
break
slen = struct.unpack('>L', chunk)[0]
chunk = self.connection.recv(slen)
while len(chunk) < slen:
chunk = chunk + self.connection.recv(slen - len(chunk))
obj = self.unPickle(chunk)
record = logging.makeLogRecord(obj)
q.put(item=record)
def unPickle(self, data):
return pickle.loads(data)
class LogRecordSocketReceiver(socketserver.ThreadingTCPServer):
"""
Simple TCP socket-based logging receiver suitable for testing.
"""
allow_reuse_address = True
def __init__(self, host='localhost',
port=logging.handlers.DEFAULT_TCP_LOGGING_PORT,
handler=LogRecordStreamHandler):
TestHandler.main = self
socketserver.ThreadingTCPServer.__init__(self, (host, port), handler)
self.abort = 0
self.timeout = 1
self.logname = None
def serve_until_stopped(self):
import select
abort = 0
while not abort:
rd, wr, ex = select.select([self.socket.fileno()],
[], [],
self.timeout)
if rd:
self.handle_request()
abort = self.abort
def main():
handler = TestHandler(sys.stdout)
formatter = logging.Formatter('%(name)-35s %(levelname)-8s %(asctime)-25s %(vif)-2s %(interfacename)-5s %(routername)-2s %(message)s')
handler.setFormatter(formatter)
logging.getLogger('my_logger').addHandler(handler)
logging.getLogger('my_logger').addFilter(CustomFilter())
t = threading.Thread(target=worker)
t.start()
tcpserver = LogRecordSocketReceiver(host='10.0.0.5')
print('About to start TCP server...')
tcpserver.serve_until_stopped()
if __name__ == '__main__':
main()
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