Example #1
0
def test():
    """ Simple test driver that verifies basic correctness. """

    import switch
    
    switch.reset_flow_table()
    assert switch.add_rules(config.flow_count) == config.flow_count    
    
    run()
    print state.global_stat
Example #2
0
def send_and_count(pkt_size, gap_ms):
    """
    Sends 1500 flows, each of FLOW_LENGTH packets of size pkt_size, and with gap_ms in
    microseconds. Returns the number of rules in the TCAM and the software table.
    
    """
    
    switch.reset_flow_table() 
    
    tcpdump.sniff_and_send(pkt_count_arg=FLOW_COUNT,
                           pkt_size_arg=pkt_size, 
                           gap_ns_arg=gap_ms*(10**6), 
                           flow_count_arg=FLOW_COUNT)
    
    time.sleep(5)

    flow_table = switch.dump_tables(filter='')

    return (len(filter(lambda x: x.find('table_id=0') >=0, flow_table)),
            len(filter(lambda x: x.find('table_id=2') >=0, flow_table)))