Cleaning up test script
This commit is contained in:
parent
26b1f3422f
commit
be6066e979
|
@ -4,6 +4,7 @@ Author: Ryan Summers
|
||||||
|
|
||||||
Description: Provides a mechanism for measuring Stabilizer stream data throughput.
|
Description: Provides a mechanism for measuring Stabilizer stream data throughput.
|
||||||
"""
|
"""
|
||||||
|
import argparse
|
||||||
import socket
|
import socket
|
||||||
import collections
|
import collections
|
||||||
import struct
|
import struct
|
||||||
|
@ -93,9 +94,10 @@ class PacketParser:
|
||||||
def _parse(self):
|
def _parse(self):
|
||||||
""" Attempt to parse packets from the received buffer. """
|
""" Attempt to parse packets from the received buffer. """
|
||||||
# Attempt to parse a block from the buffer.
|
# Attempt to parse a block from the buffer.
|
||||||
if len(self.buf) < 4:
|
if len(self.buf) < 7:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
# Parse out the packet header
|
||||||
start_id, format_id, batch_count, batch_size = struct.unpack_from('<HHHB', self.buf)
|
start_id, format_id, batch_count, batch_size = struct.unpack_from('<HHHB', self.buf)
|
||||||
|
|
||||||
if format_id not in FORMAT:
|
if format_id not in FORMAT:
|
||||||
|
@ -135,8 +137,13 @@ def check_index(previous_index, next_index):
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
""" Main program. """
|
""" Main program. """
|
||||||
|
parser = argparse.ArgumentParser(description='Measure Stabilizer livestream quality')
|
||||||
|
parser.add_argument('--port', default=1111, help='The port that stabilizer is streaming to')
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
connection = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
connection = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
connection.bind(("", 1111))
|
connection.bind(("", args.port))
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO,
|
logging.basicConfig(level=logging.INFO,
|
||||||
format='%(asctime)s.%(msecs)03d %(levelname)-8s %(message)s')
|
format='%(asctime)s.%(msecs)03d %(levelname)-8s %(message)s')
|
||||||
|
@ -162,7 +169,7 @@ def main():
|
||||||
|
|
||||||
# Handle any dropped packets.
|
# Handle any dropped packets.
|
||||||
if not check_index(last_index, packet.index):
|
if not check_index(last_index, packet.index):
|
||||||
print('Drop from ', hex(last_index), hex(packet.index))
|
print(f'Drop from {hex(last_index)} to {hex(packet.index)}')
|
||||||
if packet.index < (last_index + 1):
|
if packet.index < (last_index + 1):
|
||||||
dropped = packet.index + 65536 - (last_index + 1)
|
dropped = packet.index + 65536 - (last_index + 1)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue