Beispiel #1
0
def test_header():
    version = get_netflow_packet_version(sample_v5[0:2])
    count = socket.ntohs(struct.unpack('H', sample_v5[2:4])[0])
    current_unix_sec = (struct.unpack('I', sample_v5[8:12])[0])
    eq_(version, 5, "test version")
    eq_(count, 1, "test count records")
    eq_(current_unix_sec, 1026403152, "test current unix sec")
Beispiel #2
0
def test_header_v9():
    version = get_netflow_packet_version(sample_v9[0:2])
    count = socket.ntohs(struct.unpack('H', sample_v9[2:4])[0])
    current_unix_sec = (struct.unpack('I', sample_v9[8:12])[0])
    #Other information in packet header v9
    sys_uptime_ms = (struct.unpack('!L', sample_v9[4:8])[0])
    unix_secs = (struct.unpack('!L', sample_v9[8:12])[0])
    package_sequence = (struct.unpack('!L', sample_v9[12:16])[0])
    source_id = (struct.unpack('!L', sample_v9[16:20])[0])

    eq_(version, 9, "test version")
    eq_(count, 2, "test count records")
    eq_(current_unix_sec, 0, "test current unix sec")
    eq_(sys_uptime_ms, 29134919, "test sys_uptime")
    eq_(unix_secs, 0, "test unix_secs")
    eq_(package_sequence, 111, "test package_sequene")
    eq_(source_id, 0, "test source_id")
Beispiel #3
0
def test_get_netflow_packet_version_incorrect():
    result = get_netflow_packet_version('\x00\x12')
    assert_not_equal(result, 5, "test incorrect version")
    assert_not_equal(result, 9, "test incorrect version")
Beispiel #4
0
def test_get_netflow_packet_version_v9():
    expected = 9
    result = get_netflow_packet_version(sample_v9[0:2])
    eq_(result, expected, "test v9 version")
Beispiel #5
0
def test_get_netflow_packet_version_v5():
    expected = 5
    result = get_netflow_packet_version(sample_v5[0:2])
    eq_(result, expected, "test v5 version")