Ejemplo n.º 1
0
class ReceiveEgress(PacketReceiver):
    
    def __init__(self, _):
        PacketReceiver.__init__(self)
        self._tcpdump = Tcpdump(config.active_config, 
                                filter='udp and dst port ' + str(TRIGGER_PORT))
        
    def start(self):
        self._tcpdump.start()
        PacketReceiver.start(self)
        
    def stop(self):
        PacketReceiver.stop(self)
        result = self._tcpdump.stop_and_get_result()
        self._recvd_count = result.recvd_pkt_count
Ejemplo n.º 2
0
def main():

    switch = lib.switch.Switch(config.active_config)
    switch.reset_flow_table()

    pktgen_obj = Pktgen(config.active_config)
    tcpdump_obj = Tcpdump(config.active_config)

    tcpdump_obj.start()
    pktgen_obj.start()

    time.sleep(config.active_config.max_time)

    pktgen_result = pktgen_obj.stop_and_get_result()
    print pktgen_result.__dict__

    time.sleep(2)
    tcpdump_result = tcpdump_obj.stop_and_get_result()
    print tcpdump_result.__dict__

    print "Success percentage:", (tcpdump_result.recvd_pkt_count * 100 / pktgen_result.sent_pkt_count)
Ejemplo n.º 3
0
 def __init__(self, _):
     PacketReceiver.__init__(self)
     self._tcpdump = Tcpdump(config.active_config, 
                             filter='udp and dst port ' + str(TRIGGER_PORT))
Ejemplo n.º 4
0
def run(packet_per_second=100, pkt_size=1500, run_time=220):
    """
    Returns (pktgen_pps, pkt_in_pps, flow_mod_pps, flow_mod_pps_stdev, pkt_out_pps), where
    pps_in is the actual number of packets/sec of pktgen, and flow_mod_pps and
    flow_mod_pps_stdev are the mean and stdev pps of successful flow
    installations at steady state.
    
    """
    util.ping_test()
    
    switch = Switch(config.active_config)
    switch.reset_flow_table()

    # Initialize the experimental controller so that POX would have the
    # necessary settings.
    control_client = ExpControlClient('mumu.ucsd.edu')
    control_client.execute(['RESET'])
    control_client.execute(['SET', 'flow_stat_interval', 20])
    control_client.execute(['SET', 'install_bogus_rules', True])
    control_client.execute(['SET', 'emulate_hp_switch', True])

    # Start capturing packets.
    tcpdump = Tcpdump(config.active_config)
    tcpdump.start()
    tcpdump_start_time = time.time()

    # Start firing packets.
    pktgen = Pktgen(config.active_config)
    gap = 1.0 / packet_per_second
    pkt_count = int(run_time * packet_per_second)
    pktgen.low_level_start(pkt_count=pkt_count, pkt_size=pkt_size, 
                           gap_ns=gap*1000*1000*1000, flow_count=1)

    pktgen_start_time = time.time()
    flow_mod_pps_list = []
    
    # How fast were rules successfully written into the hardware table? We take
    # statistics at steady state. Also display flow statistics once in a while.
    last_stat_time = [0]
    def callback(t_left):
        flow_stat_dict = control_client.execute(['GET',  'flow_count_dict'])
        for stat_time in sorted(flow_stat_dict.keys()):
            if stat_time > last_stat_time[0]:
                last_stat_time[0] = stat_time
                flow_count = flow_stat_dict[stat_time]
                print t_left, 'seconds left, with flows', flow_count
                if pktgen_start_time + 60 <= time.time() <= pktgen_start_time + 180:
                    flow_mod_pps_list.append(flow_count / 10.0)

    # Check the stat every 20 seconds.                     
    util.callback_sleep(run_time, callback, interval=20)
    
    # How fast were packets actually generated?
    pktgen_result = pktgen.stop_and_get_result()
    pktgen_pps = pktgen_result.sent_pkt_count / pktgen_result.running_time
    
    # How fast were pkt_out events?
    tcpdump_end_time = time.time()
    tcpdump_result = tcpdump.stop_and_get_result()
    pkt_out_pps = (tcpdump_result.dropped_pkt_count + tcpdump_result.recvd_pkt_count) / \
                    (tcpdump_end_time - tcpdump_start_time)
    
    # Calculate the mean and stdev of successful flow_mod pps.
    (flow_mod_pps, flow_mod_pps_stdev) = util.get_mean_and_stdev(flow_mod_pps_list)
    
    # How fast were pkt_in events arriving?
    pkt_in_count = control_client.execute(['GET', 'pkt_in_count'])
    pkt_in_start_time = control_client.execute(['GET', 'pkt_in_start_time'])
    pkt_in_end_time = control_client.execute(['GET', 'pkt_in_end_time'])
    pkt_in_pps = pkt_in_count / (pkt_in_end_time - pkt_in_start_time)
    
    return (pktgen_pps, pkt_in_pps, flow_mod_pps, flow_mod_pps_stdev, pkt_out_pps)