Commit f5fb3c58 authored by Pedro Oliveira's avatar Pedro Oliveira

scripts for tests

parent c04581c3
import socket
import struct
import sys
import netifaces
import signal
import sys
is_running = True
sock = None
def exit(signal, frame):
is_running = False
sock.close()
sys.exit(0)
def chooseInterface():
interfaces = netifaces.interfaces()
def printInterfaces():
print('Indique a interface de captura:')
for i in range(len(interfaces)):
print (i+1, '-', interfaces[i])
if len(interfaces) == 1: #user has just 1 interface and any
return interfaces[0]
else:
printInterfaces()
inputValue = input('Numero da interface: ')
if int(inputValue)-1 not in range(len(interfaces)):
raise Exception('numero de interface invalida')
inputValue = interfaces[int(inputValue)-1]
return inputValue
if not hasattr(socket, 'SO_BINDTODEVICE'):
socket.SO_BINDTODEVICE = 25
signal.signal(signal.SIGINT, exit)
signal.signal(signal.SIGTERM, exit)
multicast_group = '224.12.12.12'
server_address = ('', 10000)
# Create the socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# Bind to the server address
sock.bind(server_address)
#interface_name = input("interface name: ")
interface_name = chooseInterface()
ip_interface = netifaces.ifaddresses(interface_name)[netifaces.AF_INET][0]['addr']
# Tell the operating system to add the socket to the multicast group
# on all interfaces.
group = socket.inet_aton(multicast_group)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP,
socket.inet_aton(multicast_group) + socket.inet_aton(ip_interface))
#sock.setsockopt(socket.SOL_SOCKET, socket.SO_BINDTODEVICE, str(interface_name + "\0").encode('utf-8'))
# Receive/respond loop
while is_running:
#print >>sys.stderr, '\nwaiting to receive message'
data, address = sock.recvfrom(10240)
print(data.decode("utf-8"))
#print >>sys.stderr, 'received %s bytes from %s' % (len(data), address)
#print >>sys.stderr, data
#print >>sys.stderr, 'sending acknowledgement to', address
#sock.sendto('ack', address)
rm -rf test/
cp -rf /hosthome/PycharmProjects/RPC/ test/
cd test
pip-3.2 install --index-url=https://pypi.python.org/simple/ -r requirements.txt
python3 Client.py
pip-3.2 install --index-url=https://pypi.python.org/simple/ netifaces
python3 client.py
import socket
import struct
import sys
import netifaces
import traceback
import signal
is_running = True
sock = None
def exit(signal, frame):
is_running = False
sock.close()
sys.exit(0)
def chooseInterface():
interfaces = netifaces.interfaces()
def printInterfaces():
print('Indique a interface de captura:')
for i in range(len(interfaces)):
print (i+1, '-', interfaces[i])
if len(interfaces) == 1: #user has just 1 interface and any
return interfaces[0]
else:
printInterfaces()
inputValue = input('Numero da interface: ')
if int(inputValue)-1 not in range(len(interfaces)):
raise Exception('numero de interface invalida')
inputValue = interfaces[int(inputValue)-1]
return inputValue
signal.signal(signal.SIGINT, exit)
signal.signal(signal.SIGTERM, exit)
multicast_group = ('224.12.12.12', 10000)
# Create the datagram socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# Set the time-to-live for messages to 1 so they do not go past the
# local network segment.
ttl = struct.pack('b', 12)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, ttl)
interface_name = chooseInterface()
ip_interface = netifaces.ifaddresses(interface_name)[netifaces.AF_INET][0]['addr']
sock.bind((ip_interface, 10000))
try:
# Look for responses from all recipients
while is_running:
input_msg = input('msg --> ')
try:
sock.sendto(input_msg.encode("utf-8"), multicast_group)
except:
traceback.print_exc()
continue
#print >>sys.stderr, 'received "%s" from %s' % (data, server)
finally:
#print >>sys.stderr, 'closing socket'
sock.close()
import socket
import struct
import sys
import netifaces
import signal
import sys
is_running = True
sock = None
def exit(signal, frame):
is_running = False
sock.close()
sys.exit(0)
def chooseInterface():
interfaces = netifaces.interfaces()
def printInterfaces():
print('Indique a interface de captura:')
for i in range(len(interfaces)):
print (i+1, '-', interfaces[i])
if len(interfaces) == 1: #user has just 1 interface and any
return interfaces[0]
else:
printInterfaces()
inputValue = input('Numero da interface: ')
if int(inputValue)-1 not in range(len(interfaces)):
raise Exception('numero de interface invalida')
inputValue = interfaces[int(inputValue)-1]
return inputValue
if not hasattr(socket, 'SO_BINDTODEVICE'):
socket.SO_BINDTODEVICE = 25
signal.signal(signal.SIGINT, exit)
signal.signal(signal.SIGTERM, exit)
multicast_group = '224.12.12.12'
server_address = ('', 10000)
# Create the socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# Bind to the server address
sock.bind(server_address)
#interface_name = input("interface name: ")
interface_name = chooseInterface()
ip_interface = netifaces.ifaddresses(interface_name)[netifaces.AF_INET][0]['addr']
# Tell the operating system to add the socket to the multicast group
# on all interfaces.
group = socket.inet_aton(multicast_group)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP,
socket.inet_aton(multicast_group) + socket.inet_aton(ip_interface))
#sock.setsockopt(socket.SOL_SOCKET, socket.SO_BINDTODEVICE, str(interface_name + "\0").encode('utf-8'))
# Receive/respond loop
while is_running:
#print >>sys.stderr, '\nwaiting to receive message'
data, address = sock.recvfrom(10240)
print(data.decode("utf-8"))
#print >>sys.stderr, 'received %s bytes from %s' % (len(data), address)
#print >>sys.stderr, data
#print >>sys.stderr, 'sending acknowledgement to', address
#sock.sendto('ack', address)
rm -rf test/
cp -rf /hosthome/PycharmProjects/RPC/ test/
cd test
pip-3.2 install --index-url=https://pypi.python.org/simple/ -r requirements.txt
python3 Client.py
pip-3.2 install --index-url=https://pypi.python.org/simple/ netifaces
python3 client.py
import socket
import struct
import sys
import netifaces
import traceback
import signal
is_running = True
sock = None
def exit(signal, frame):
is_running = False
sock.close()
sys.exit(0)
def chooseInterface():
interfaces = netifaces.interfaces()
def printInterfaces():
print('Indique a interface de captura:')
for i in range(len(interfaces)):
print (i+1, '-', interfaces[i])
if len(interfaces) == 1: #user has just 1 interface and any
return interfaces[0]
else:
printInterfaces()
inputValue = input('Numero da interface: ')
if int(inputValue)-1 not in range(len(interfaces)):
raise Exception('numero de interface invalida')
inputValue = interfaces[int(inputValue)-1]
return inputValue
signal.signal(signal.SIGINT, exit)
signal.signal(signal.SIGTERM, exit)
multicast_group = ('224.12.12.12', 10000)
# Create the datagram socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# Set the time-to-live for messages to 1 so they do not go past the
# local network segment.
ttl = struct.pack('b', 12)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, ttl)
interface_name = chooseInterface()
ip_interface = netifaces.ifaddresses(interface_name)[netifaces.AF_INET][0]['addr']
sock.bind((ip_interface, 10000))
try:
# Look for responses from all recipients
while is_running:
input_msg = input('msg --> ')
try:
sock.sendto(input_msg.encode("utf-8"), multicast_group)
except:
traceback.print_exc()
continue
#print >>sys.stderr, 'received "%s" from %s' % (data, server)
finally:
#print >>sys.stderr, 'closing socket'
sock.close()
import socket
import struct
import sys
import netifaces
import signal
import sys
is_running = True
sock = None
def exit(signal, frame):
is_running = False
sock.close()
sys.exit(0)
def chooseInterface():
interfaces = netifaces.interfaces()
def printInterfaces():
print('Indique a interface de captura:')
for i in range(len(interfaces)):
print (i+1, '-', interfaces[i])
if len(interfaces) == 1: #user has just 1 interface and any
return interfaces[0]
else:
printInterfaces()
inputValue = input('Numero da interface: ')
if int(inputValue)-1 not in range(len(interfaces)):
raise Exception('numero de interface invalida')
inputValue = interfaces[int(inputValue)-1]
return inputValue
if not hasattr(socket, 'SO_BINDTODEVICE'):
socket.SO_BINDTODEVICE = 25
signal.signal(signal.SIGINT, exit)
signal.signal(signal.SIGTERM, exit)
multicast_group = '224.12.12.12'
server_address = ('', 10000)
# Create the socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# Bind to the server address
sock.bind(server_address)
#interface_name = input("interface name: ")
interface_name = chooseInterface()
ip_interface = netifaces.ifaddresses(interface_name)[netifaces.AF_INET][0]['addr']
# Tell the operating system to add the socket to the multicast group
# on all interfaces.
group = socket.inet_aton(multicast_group)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP,
socket.inet_aton(multicast_group) + socket.inet_aton(ip_interface))
#sock.setsockopt(socket.SOL_SOCKET, socket.SO_BINDTODEVICE, str(interface_name + "\0").encode('utf-8'))
# Receive/respond loop
while is_running:
#print >>sys.stderr, '\nwaiting to receive message'
data, address = sock.recvfrom(10240)
print(data.decode("utf-8"))
#print >>sys.stderr, 'received %s bytes from %s' % (len(data), address)
#print >>sys.stderr, data
#print >>sys.stderr, 'sending acknowledgement to', address
#sock.sendto('ack', address)
rm -rf test/
cp -rf /hosthome/PycharmProjects/RPC/ test/
cd test
pip-3.2 install --index-url=https://pypi.python.org/simple/ -r requirements.txt
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
python3 Client.py
import socket
import struct
import sys
import netifaces
import traceback
import signal
is_running = True
sock = None
def exit(signal, frame):
is_running = False
sock.close()
sys.exit(0)
def chooseInterface():
interfaces = netifaces.interfaces()
def printInterfaces():
print('Indique a interface de captura:')
for i in range(len(interfaces)):
print (i+1, '-', interfaces[i])
if len(interfaces) == 1: #user has just 1 interface and any
return interfaces[0]
else:
printInterfaces()
inputValue = input('Numero da interface: ')
if int(inputValue)-1 not in range(len(interfaces)):
raise Exception('numero de interface invalida')
inputValue = interfaces[int(inputValue)-1]
return inputValue
signal.signal(signal.SIGINT, exit)
signal.signal(signal.SIGTERM, exit)
multicast_group = ('224.12.12.12', 10000)
# Create the datagram socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# Set the time-to-live for messages to 1 so they do not go past the
# local network segment.
ttl = struct.pack('b', 12)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, ttl)
interface_name = chooseInterface()
ip_interface = netifaces.ifaddresses(interface_name)[netifaces.AF_INET][0]['addr']
sock.bind((ip_interface, 10000))
try:
# Look for responses from all recipients
while is_running:
input_msg = input('msg --> ')
try:
sock.sendto(input_msg.encode("utf-8"), multicast_group)
except:
traceback.print_exc()
continue
#print >>sys.stderr, 'received "%s" from %s' % (data, server)
finally:
#print >>sys.stderr, 'closing socket'
sock.close()
......@@ -3,4 +3,15 @@ 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.5.5.100
python3 Run.py -aiigmp eth0
python3 Run.py -aiigmp eth1
python3 Run.py -aiigmp eth2
python3 Run.py -aiigmp eth3
python3 Run.py -ai eth0
python3 Run.py -ai eth1
python3 Run.py -ai eth2
python3 Run.py -ai eth3
python3 Run.py -v
......@@ -3,4 +3,11 @@ 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.5.5.100
python3 Run.py -aiigmp eth0
python3 Run.py -aiigmp eth1
python3 Run.py -ai eth0
python3 Run.py -ai eth1
python3 Run.py -v
......@@ -3,4 +3,12 @@ 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.5.5.100
python3 Run.py -aiigmp eth0
python3 Run.py -aiigmp eth1
python3 Run.py -ai eth0
python3 Run.py -ai eth1
python3 Run.py -v
......@@ -3,4 +3,11 @@ 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.5.5.100
python3 Run.py -aiigmp eth0
python3 Run.py -aiigmp eth1
python3 Run.py -ai eth0
python3 Run.py -ai eth1
python3 Run.py -v
......@@ -3,4 +3,11 @@ 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 R5 10.5.5.100
python3 Run.py -aiigmp eth0
python3 Run.py -aiigmp eth1
python3 Run.py -ai eth0
python3 Run.py -ai eth1
python3 Run.py -v
......@@ -3,4 +3,11 @@ 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 R6 10.5.5.100
python3 Run.py -aiigmp eth0
python3 Run.py -aiigmp eth1
python3 Run.py -ai eth0
python3 Run.py -ai eth1
python3 Run.py -v
import socket
import struct
import sys
import netifaces
import signal
import sys
is_running = True
sock = None
def exit(signal, frame):
is_running = False
sock.close()
sys.exit(0)
def chooseInterface():
interfaces = netifaces.interfaces()
def printInterfaces():
print('Indique a interface de captura:')
for i in range(len(interfaces)):
print (i+1, '-', interfaces[i])
if len(interfaces) == 1: #user has just 1 interface and any
return interfaces[0]
else:
printInterfaces()
inputValue = input('Numero da interface: ')
if int(inputValue)-1 not in range(len(interfaces)):
raise Exception('numero de interface invalida')
inputValue = interfaces[int(inputValue)-1]
return inputValue
if not hasattr(socket, 'SO_BINDTODEVICE'):
socket.SO_BINDTODEVICE = 25
signal.signal(signal.SIGINT, exit)
signal.signal(signal.SIGTERM, exit)
multicast_group = '224.12.12.12'
server_address = ('', 10000)
# Create the socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# Bind to the server address
sock.bind(server_address)
#interface_name = input("interface name: ")
interface_name = chooseInterface()
ip_interface = netifaces.ifaddresses(interface_name)[netifaces.AF_INET][0]['addr']
# Tell the operating system to add the socket to the multicast group
# on all interfaces.
group = socket.inet_aton(multicast_group)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP,
socket.inet_aton(multicast_group) + socket.inet_aton(ip_interface))
#sock.setsockopt(socket.SOL_SOCKET, socket.SO_BINDTODEVICE, str(interface_name + "\0").encode('utf-8'))
# Receive/respond loop
while is_running:
#print >>sys.stderr, '\nwaiting to receive message'
data, address = sock.recvfrom(10240)
print(data.decode("utf-8"))
#print >>sys.stderr, 'received %s bytes from %s' % (len(data), address)
#print >>sys.stderr, data
#print >>sys.stderr, 'sending acknowledgement to', address
#sock.sendto('ack', address)
rm -rf test/
cp -rf /hosthome/PycharmProjects/RPC/ test/
cd test
pip-3.2 install --index-url=https://pypi.python.org/simple/ -r requirements.txt
python3 Client.py
pip-3.2 install --index-url=https://pypi.python.org/simple/ netifaces
python3 server.py
import socket
import struct
import sys
import netifaces
import traceback
import signal
is_running = True
sock = None
def exit(signal, frame):
is_running = False
sock.close()
sys.exit(0)
def chooseInterface():
interfaces = netifaces.interfaces()
def printInterfaces():
print('Indique a interface de captura:')
for i in range(len(interfaces)):
print (i+1, '-', interfaces[i])
if len(interfaces) == 1: #user has just 1 interface and any
return interfaces[0]
else:
printInterfaces()
inputValue = input('Numero da interface: ')
if int(inputValue)-1 not in range(len(interfaces)):
raise Exception('numero de interface invalida')
inputValue = interfaces[int(inputValue)-1]
return inputValue
signal.signal(signal.SIGINT, exit)
signal.signal(signal.SIGTERM, exit)
multicast_group = ('224.12.12.12', 10000)
# Create the datagram socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# Set the time-to-live for messages to 1 so they do not go past the
# local network segment.
ttl = struct.pack('b', 12)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, ttl)
interface_name = chooseInterface()
ip_interface = netifaces.ifaddresses(interface_name)[netifaces.AF_INET][0]['addr']
sock.bind((ip_interface, 10000))
try:
# Look for responses from all recipients
while is_running:
input_msg = input('msg --> ')
try:
sock.sendto(input_msg.encode("utf-8"), multicast_group)
except:
traceback.print_exc()
continue
#print >>sys.stderr, 'received "%s" from %s' % (data, server)
finally:
#print >>sys.stderr, 'closing socket'
sock.close()
rm -rf test/
cp -rf /hosthome/PycharmProjects/RPC/ test/
cd test
pip-3.2 install --index-url=https://pypi.python.org/simple/ -r requirements.txt
python3 Client.py
tcpdump -i any -w /hosthome/Desktop/assert_capture.pcap
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