def test_uri(uri):
    t = plt.trace(uri)
    t.start()

    nip = n = 0
    for pkt in t:
        n += 1
        print "n = %4d" % n,
        ipf = natkit.IPflow(pkt)
        if not ipf:
            print
            continue
        nip += 1

        print "  %d %3d  %5d->%5d  %s->%s" % (ipf.version, ipf.proto,
                                              ipf.src_port, ipf.dst_port,
                                              ipf.src_prefix, ipf.dst_prefix)

        fwd = ipf.fwd_key
        #print "fwd = %s" % fwd
        v = test_dict.get(fwd)
        if v:
            v.fwd += 1
        else:
            rev = ipf.rev_key
            #print "rev = %s" % rev
            v = test_dict.get(rev)
            if v:
                v.rev += 1
            else:
                test_dict[fwd] = flow(ipf, n)

        #fwd = ipf.fwd_key
        #test_dict[fwd] = flow(ipf, n)

        #rev = ipf.rev_key
        #test_dict[rev] = flow(ipf, n+1000)

        if nip == 10:
            break

    t.close()

    print
    sk = sorted(test_dict)
    for dk in sk:
        #print "dk = >%s<, val[k] = %d" % (dk, test_dict[dk])
        val = test_dict[dk]
        f = val.ipf
        print "      %3d: %d+%d; %d %d  %d->%d  %s->%s" % (
            val.first_n, val.fwd, val.rev, f.version, f.proto, f.src_port,
            f.dst_port, f.src_prefix, f.dst_prefix)
Beispiel #2
0
def test_uri(uri, tag=''):
    t = plt.trace(uri)
    t.start()

    nip = n = 0
    for pkt in t:
        n += 1
        test_println("n = %d" % n, tag + get_tag("n:" + str(n)))
        try:
            ipf = natkit.IPflow(pkt)
        except:
            test_println("probably not an IP packet",
                         tag + get_tag("n:" + str(n)))
            continue

        nip += 1

        test_println(
            "%5d: %d %3d  %5d %5d  %s  %s" % (
                n,  # v6
                ipf.version,
                ipf.proto,
                ipf.src_port,
                ipf.dst_port,
                ipf.src_prefix,
                ipf.dst_prefix),
            tag + get_tag("n:" + str(n)))

        fwd = ipf.fwd_key
        test_print("fwd =", tag + get_tag("n:" + str(n)))
        for b in fwd:
            test_print(" %02x" % b)

        rev = ipf.rev_key
        test_println('')
        test_print("rev =", tag + get_tag("n:" + str(n)))
        for b in rev:
            test_print(" %02x" % b)
        test_println('')

        if nip == 4:
            break

    t.close()
Beispiel #3
0
def test_uri(uri):
    t = plt.trace(uri)
    t.start()

    nip = n = 0
    for pkt in t:
        n += 1
        print "n = %d" % n
        try:
            ipf = natkit.IPflow(pkt)
        except:
            print "probably not an IP packet"
            continue

        nip += 1

        print "%5d: %d %3d  %5d %5d  %s  %s" % (
            n,  # v6
            ipf.version,
            ipf.proto,
            ipf.src_port,
            ipf.dst_port,
            ipf.src_prefix,
            ipf.dst_prefix)

        fwd = ipf.fwd_key
        print "fwd =",
        for b in fwd:
            print " %02x" % ord(b),

        rev = ipf.rev_key
        print "\nrev =",
        for b in rev:
            print " %02x" % ord(b),
        print

        if nip == 4:
            break

    t.close()
def test_uri(uri, tag=''):
    t = plt.trace(uri)
    t.start()

    nip = n = 0
    for pkt in t:
        n += 1
        test_println("n = %d" % n, tag + get_tag("n:" + str(n)))
        ipf = natkit.IPflow(pkt)
        if not ipf:
            test_println(" ", tag + get_tag())
            continue
        nip += 1

        test_println(
            "%5d: %d %3d  %5d %5d  %s  %s" % (
                n,  # v6
                ipf.version,
                ipf.proto,
                ipf.src_port,
                ipf.dst_port,
                ipf.src_prefix,
                ipf.dst_prefix),
            tag + get_tag("n:" + str(n)))

        fwd = ipf.fwd_key
        test_print("fwd =", tag + get_tag("n:" + str(n)))
        for b in fwd:
            test_print(" %02x" % b)

        rev = ipf.rev_key
        test_println('')
        test_print("rev =", tag + get_tag("n:" + str(n)))
        for b in rev:
            test_print(" %02x" % b)
        test_println('')

        v = test_dict.get(fwd)
        if v:
            v.fwd += 1
        else:
            rev = ipf.rev_key
            v = test_dict.get(rev)
            if v:
                v.rev += 1
            else:
                test_dict[fwd] = flow(ipf, n)
        if nip == 6:
            break

    t.close()
    test_println('')

    sk = sorted(test_dict)
    for dk in sk:
        #print "dk = >%s<, val[k] = %d" % (dk, test_dict[dk])
        val = test_dict[dk]
        f = val.ipf
        test_println(
            "      %3d: %d+%d; %d %d  %d->%d  %s->%s" %
            (val.first_n, val.fwd, val.rev, f.version, f.proto, f.src_port,
             f.dst_port, f.src_prefix, f.dst_prefix),
            tag + get_tag("n:" + str(n)))