def test_get_trace_list_custom(self):
        with tempfile.NamedTemporaryFile() as mapping_file:
            mapping_file.write(
b'''[
    {
        "direction": "upstream", 
        "noise": "0M", 
        "typeofmeasure": "active", 
        "last_timestamp": "2020-01-31 21:16:45.000000", 
        "first_timestamp": "2020-01-24 15:36:55.000000", 
        "path": "inputFiles/active/wifi-TCPBandwidth-upstream-noise0M_Client-Observer_edge.txt", 
        "ObserverPos": "edge", 
        "receiverIdentity": "Observer", 
        "access-technology": "wifi", 
        "senderIdentity": "Client", 
        "command": "TCPBandwidth"
    }
    ]
''')
            mapping_file.flush()
            trace_list = NetworkTraceManager.get_tracelist(mapping_file.name)
            self.assertEqual(1, len(trace_list))
            self.assertEqual('active', trace_list[0]['typeofmeasure'])
            self.assertEqual('TCPBandwidth', trace_list[0]['command'])
            self.assertEqual('edge', trace_list[0]['ObserverPos'])
            self.assertEqual('0M', trace_list[0]['noise'])
            self.assertEqual('wifi', trace_list[0]['access-technology'])
            self.assertEqual('upstream', trace_list[0]['direction'])
            self.assertEqual('Client', trace_list[0]['senderIdentity'])
            self.assertEqual('Observer', trace_list[0]['receiverIdentity'])
Example #2
0
from network_trace_manager import NetworkTraceManager

logging.basicConfig(
    filename="file.log",
    filemode='w',
    format=
    '%(asctime)s,%(msecs)d %(name)s %(levelname)s %(funcName)s(): %(message)s',
    datefmt='%H:%M:%S',
    level=logging.DEBUG)

config = configparser.ConfigParser()
config.read("conf.ini")

for elem in NetworkTraceManager.get_tracelist("inputFiles/mapping.json",
                                              command="TCPRTT",
                                              direction="upstream",
                                              typeofmeasure="active"):
    print(elem)

network_trace1 = NetworkTraceManager(config["conf1"])
network_trace2 = NetworkTraceManager(config["conf2"])

print(network_trace1.get_rtt(1))
print(network_trace1.get_rtt(3.1))
print(network_trace1.get_rtt(2.3))
print(network_trace1.get_rtt(4.2))
print("\n")

print(network_trace2.get_rtt(1))
print(network_trace2.get_rtt(6))
print(network_trace2.get_rtt(8))
 def test_get_trace_list(self):
     trace_list = NetworkTraceManager.get_tracelist('inputFiles/mapping.json')
     self.assertEqual(288, len(trace_list))