if _debug: _log.debug("    - filterDestination: %r", filterDestination)
        del sys.argv[i:i+2]

    # check for host
    if ('--host' in sys.argv):
        i = sys.argv.index('--host')
        filterHost = Address(sys.argv[i+1])
        if _debug: _log.debug("    - filterHost: %r", filterHost)
        del sys.argv[i:i+2]

    # start out with no unmatched requests
    requests = {}

    # trace the file(s)
    for fname in sys.argv[1:]:
        trace(fname, [ConfirmedEventNotificationSummary])

    # print some stats at the end
    stats = Statistics()

    # dump everything
    for msg in traffic:
        req = msg.req
        resp = msg.resp

        if resp:
            deltatime = (resp._timestamp - req._timestamp) * 1000
            if stats:
                stats.Record(deltatime, req._timestamp)
            print strftimestamp(req._timestamp), '\t', req.pduSource, '\t', resp.pduSource, '\t', ("%8.2fms" % (deltatime,)), '\t', msg.retry if (msg.retry != 1) else ""
        else:
Beispiel #2
0
        i = sys.argv.index('--src')
        filterSource = Address(sys.argv[i+1])
        if _debug: _log.debug("    - filterSource: %r", filterSource)
        del sys.argv[i:i+2]

    # check for dest
    if ('--dest' in sys.argv):
        i = sys.argv.index('--dest')
        filterDestination = Address(sys.argv[i+1])
        if _debug: _log.debug("    - filterDestination: %r", filterDestination)
        del sys.argv[i:i+2]

    # check for host
    if ('--host' in sys.argv):
        i = sys.argv.index('--host')
        filterHost = Address(sys.argv[i+1])
        if _debug: _log.debug("    - filterHost: %r", filterHost)
        del sys.argv[i:i+2]

    # trace the file(s)
    for fname in sys.argv[1:]:
        trace(fname, [AddressFilterTracer])

except KeyboardInterrupt:
    pass
except Exception, e:
    _log.exception("an error has occurred: %s", e)
finally:
    if _debug: _log.debug("finally")

        if _debug: _log.debug("    - filterHost: %r", filterHost)
        del sys.argv[i:i+2]

    # check for eval
    if ('--eval' in sys.argv):
        i = sys.argv.index('--eval')
        filterEval = sys.argv[i+1]
        if _debug: _log.debug("    - filterEval: %r", filterEval)
        del sys.argv[i:i+2]

    # start out with no unmatched requests
    requests = {}

    # trace the file(s)
    for fname in sys.argv[1:]:
        trace(fname, [ReadPropertySummary])

    # print some stats at the end
    stats = Statistics()

    # dump everything
    for msg in traffic:
        req = msg.req
        resp = msg.resp

        if resp:
            deltatime = (resp._timestamp - req._timestamp) * 1000
            if stats:
                stats.Record(deltatime, req._timestamp)
            print strftimestamp(req._timestamp), '\t', req.pduSource, '\t', resp.pduSource, '\t', ("%6.2fms" % (deltatime,)), '\t', msg.retry if (msg.retry != 1) else ""
        else:
Beispiel #4
0
    if ('--dest' in sys.argv):
        i = sys.argv.index('--dest')
        filterDestination = Address(sys.argv[i + 1])
        if _debug: _log.debug("    - filterDestination: %r", filterDestination)
        del sys.argv[i:i + 2]

    # check for host
    if ('--host' in sys.argv):
        i = sys.argv.index('--host')
        filterHost = Address(sys.argv[i + 1])
        if _debug: _log.debug("    - filterHost: %r", filterHost)
        del sys.argv[i:i + 2]

    # trace the file(s)
    for fname in sys.argv[1:]:
        trace(fname, [WhoIsRouterToNetworkSummary])

    # sort the result, descending order by count
    items = requests.items()
    items.sort(lambda x, y: cmp(y[1], x[1]))

    # print everything out
    print "%-20s %5s" % ("Address", "Count")
    for key, count in items:
        print "%-20s %5d" % (key, count)

        # count the number of times of each network
        net_count = defaultdict(int)
        for net in networks[key]:
            net_count[net] += 1
Beispiel #5
0
        i = sys.argv.index('--dest')
        filterDestination = Address(sys.argv[i+1])
        if _debug: _log.debug("    - filterDestination: %r", filterDestination)
        del sys.argv[i:i+2]

    # check for host
    if ('--host' in sys.argv):
        i = sys.argv.index('--host')
        filterHost = Address(sys.argv[i+1])
        if _debug: _log.debug("    - filterHost: %r", filterHost)
        del sys.argv[i:i+2]

    # pcap_file
    pcap_file = sys.argv[1]
    if _debug: _log.debug("    - pcap_file: %r", pcap_file)

    # which device instance to look for
    filterDevice = int(sys.argv[2])
    if _debug: _log.debug("    - filterDevice: %r:", filterDevice)

    # trace the file
    trace(pcap_file, [WhoIsIAmDevice])

except KeyboardInterrupt:
    pass
except Exception, e:
    _log.exception("an error has occurred: %s", e)
finally:
    if _debug: _log.debug("finally")

        if _debug: _log.debug("    - filterDestination: %r", filterDestination)
        del sys.argv[i:i + 2]

    # check for host
    if ('--host' in sys.argv):
        i = sys.argv.index('--host')
        filterHost = Address(sys.argv[i + 1])
        if _debug: _log.debug("    - filterHost: %r", filterHost)
        del sys.argv[i:i + 2]

    # start out with no requests
    requests = {}

    # trace the file(s)
    for fname in sys.argv[1:]:
        trace(fname, [COVNotificationSummary])

    # sort the result, descending order by count
    items = requests.items()
    items.sort(lambda x, y: cmp(y[1], x[1]))

    # print everything out
    print "%-20s %8s %-15s %4s %5s" % ("Address", "Device", "Object", "",
                                       "Count")
    for key, count in items:
        print "%-20s %8s %-15s %4d %5d" % (key[0], key[1], key[2][0],
                                           key[2][1], count)

except KeyboardInterrupt:
    pass
except Exception, e:
    if ('--dest' in sys.argv):
        i = sys.argv.index('--dest')
        filterDestination = Address(sys.argv[i + 1])
        if _debug: _log.debug("    - filterDestination: %r", filterDestination)
        del sys.argv[i:i + 2]

    # check for host
    if ('--host' in sys.argv):
        i = sys.argv.index('--host')
        filterHost = Address(sys.argv[i + 1])
        if _debug: _log.debug("    - filterHost: %r", filterHost)
        del sys.argv[i:i + 2]

    # trace the file(s)
    for fname in sys.argv[1:]:
        trace(fname, [WhoIsIAmSummary])

    # dump request counts
    print "----- Top 20 Who-Is -----"
    print

    items = whoIsTraffic.items()
    items.sort(lambda x, y: cmp((y[1], y[0][0]), (x[1], x[0][0])))
    for item in items[:20]:
        print "%-20s %8s %8s %5d" % (item[0][0], item[0][1], item[0][2],
                                     item[1])
    print

    print "----- Top 20 I-Am -----"
    print
if args.source:
    filterSource = Address(args.source)
    if _debug:
        _log.debug("    - filterSource: %r", filterSource)
if args.destination:
    filterDestination = Address(args.destination)
    if _debug:
        _log.debug("    - filterDestination: %r", filterDestination)
if args.host:
    filterHost = Address(args.host)
    if _debug:
        _log.debug("    - filterHost: %r", filterHost)

# trace the file(s)
for fname in args.pcap:
    trace(fname, [IAmRouterToNetworkSummary])

# sort the result, descending order by count
items = requests.items()
items.sort(key=lambda x: x[1], reverse=True)

# print everything out
print("%-20s %5s" % ("Address", "Count"))
for key, count in items:
    print("%-20s %5d" % (key, count))

    # count the number of times of each network
    net_count = defaultdict(int)
    for subnet_list in networks[key]:
        for net in subnet_list:
            net_count[net] += 1
        if _debug: _log.debug("    - filterHost: %r", filterHost)
        del sys.argv[i:i + 2]

    # check for eval
    if ('--eval' in sys.argv):
        i = sys.argv.index('--eval')
        filterEval = sys.argv[i + 1]
        if _debug: _log.debug("    - filterEval: %r", filterEval)
        del sys.argv[i:i + 2]

    # start out with no unmatched requests
    requests = {}

    # trace the file(s)
    for fname in sys.argv[1:]:
        trace(fname, [ReadPropertySummary])

    # print some stats at the end
    stats = Statistics()

    # dump everything
    for msg in traffic:
        req = msg.req
        resp = msg.resp

        if resp:
            deltatime = (resp._timestamp - req._timestamp) * 1000
            if stats:
                stats.Record(deltatime, req._timestamp)
            print strftimestamp(
                req._timestamp
        del sys.argv[indx:]

    if _debug: _log.debug("initialization")

    # check for a custom interval
    if ('--interval' in sys.argv):
        i = sys.argv.index('--interval')
        interval = int(sys.argv[i+1])
        if _debug: _log.debug("    - interval: %r", interval)
        del sys.argv[i:i+2]
    else:
        interval = 60

    # trace the file(s)
    for fname in sys.argv[1:]:
        trace(fname, [PDUsPerMinuteTracer])

    # print some stats at the end
    stats = Statistics()

    # dump the counters
    for ts in range(min(counter), max(counter)+1, interval):
        print strftimestamp(ts), counter[ts]
        if stats:
            stats.Record(counter[ts], ts)

    if stats:
        smin, smax, _, _, _, _ = stats.Stats()

        xlw, lw, q1, m, q3, uw, xuw = stats.Whisker()
        if m is not None:
Beispiel #11
0
    if ('--src' in sys.argv):
        i = sys.argv.index('--src')
        filterSource = Address(sys.argv[i + 1])
        if _debug: _log.debug("    - filterSource: %r", filterSource)
        del sys.argv[i:i + 2]

    # check for dest
    if ('--dest' in sys.argv):
        i = sys.argv.index('--dest')
        filterDestination = Address(sys.argv[i + 1])
        if _debug: _log.debug("    - filterDestination: %r", filterDestination)
        del sys.argv[i:i + 2]

    # check for host
    if ('--host' in sys.argv):
        i = sys.argv.index('--host')
        filterHost = Address(sys.argv[i + 1])
        if _debug: _log.debug("    - filterHost: %r", filterHost)
        del sys.argv[i:i + 2]

    # trace the file(s)
    for fname in sys.argv[1:]:
        trace(fname, [AddressFilterTracer])

except KeyboardInterrupt:
    pass
except Exception, e:
    _log.exception("an error has occurred: %s", e)
finally:
    if _debug: _log.debug("finally")
Beispiel #12
0
        del sys.argv[indx:]

    if _debug: _log.debug("initialization")

    # check for a custom interval
    if ('--interval' in sys.argv):
        i = sys.argv.index('--interval')
        interval = int(sys.argv[i + 1])
        if _debug: _log.debug("    - interval: %r", interval)
        del sys.argv[i:i + 2]
    else:
        interval = 60

    # trace the file(s)
    for fname in sys.argv[1:]:
        trace(fname, [PDUsPerMinuteTracer])

    # print some stats at the end
    stats = Statistics()

    # dump the counters
    for ts in range(min(counter), max(counter) + 1, interval):
        print strftimestamp(ts), counter[ts]
        if stats:
            stats.Record(counter[ts], ts)

    if stats:
        smin, smax, _, _, _, _ = stats.Stats()

        xlw, lw, q1, m, q3, uw, xuw = stats.Whisker()
        if m is not None:
        if _debug: _log.debug("    - filterDestination: %r", filterDestination)
        del sys.argv[i:i + 2]

    # check for host
    if ('--host' in sys.argv):
        i = sys.argv.index('--host')
        filterHost = Address(sys.argv[i + 1])
        if _debug: _log.debug("    - filterHost: %r", filterHost)
        del sys.argv[i:i + 2]

    # start out with no unmatched requests
    requests = {}

    # trace the file(s)
    for fname in sys.argv[1:]:
        trace(fname, [ConfirmedEventNotificationSummary])

    # print some stats at the end
    stats = Statistics()

    # dump everything
    for msg in traffic:
        req = msg.req
        resp = msg.resp

        if resp:
            deltatime = (resp._timestamp - req._timestamp) * 1000
            if stats:
                stats.Record(deltatime, req._timestamp)
            print strftimestamp(
                req._timestamp
    if ('--dest' in sys.argv):
        i = sys.argv.index('--dest')
        filterDestination = Address(sys.argv[i+1])
        if _debug: _log.debug("    - filterDestination: %r", filterDestination)
        del sys.argv[i:i+2]

    # check for host
    if ('--host' in sys.argv):
        i = sys.argv.index('--host')
        filterHost = Address(sys.argv[i+1])
        if _debug: _log.debug("    - filterHost: %r", filterHost)
        del sys.argv[i:i+2]

    # trace the file(s)
    for fname in sys.argv[1:]:
        trace(fname, [WhoIsRouterToNetworkSummary])

    # sort the result, descending order by count
    items = requests.items()
    items.sort(lambda x, y: cmp(y[1], x[1]))

    # print everything out
    print "%-20s %5s" % ("Address", "Count")
    for key, count in items:
        print "%-20s %5d" % (key, count)

        # count the number of times of each network
        net_count = defaultdict(int)
        for net in networks[key]:
            net_count[net] += 1
if args.source:
    filterSource = Address(args.source)
    if _debug:
        _log.debug("    - filterSource: %r", filterSource)
if args.destination:
    filterDestination = Address(args.destination)
    if _debug:
        _log.debug("    - filterDestination: %r", filterDestination)
if args.host:
    filterHost = Address(args.host)
    if _debug:
        _log.debug("    - filterHost: %r", filterHost)

# trace the file(s)
for fname in args.pcap:
    trace(fname, [WhoIsIAmSummary])

# dump request counts
print("----- Top 20 Who-Is -----")
print("")

items = whoIsTraffic.items()
items.sort(key=lambda x: (x[1], x[0][0]), reverse=True)
for item in items[:20]:
    print("%-20s %8s %8s %5d" % (item[0][0], item[0][1], item[0][2], item[1]))
print("")

print("----- Top 20 I-Am -----")
print("")

items = iAmTraffic.items()
parser.add_argument("pcap", nargs="+", type=str, help="pcap file(s)")
args = parser.parse_args()

if _debug:
    _log.debug("initialization")
if _debug:
    _log.debug("    - args: %r", args)

# interpret the arguments
if args.source:
    filterSource = Address(args.source)
    if _debug:
        _log.debug("    - filterSource: %r", filterSource)
if args.destination:
    filterDestination = Address(args.destination)
    if _debug:
        _log.debug("    - filterDestination: %r", filterDestination)
if args.host:
    filterHost = Address(args.host)
    if _debug:
        _log.debug("    - filterHost: %r", filterHost)

# which device instance to look for
filterDevice = args.device[0]
if _debug:
    _log.debug("    - filterDevice: %r", filterDevice)

# trace the file(s)
for fname in args.pcap:
    trace(fname, [WhoIsIAmDevice])
        i = sys.argv.index('--dest')
        filterDestination = Address(sys.argv[i+1])
        if _debug: _log.debug("    - filterDestination: %r", filterDestination)
        del sys.argv[i:i+2]

    # check for host
    if ('--host' in sys.argv):
        i = sys.argv.index('--host')
        filterHost = Address(sys.argv[i+1])
        if _debug: _log.debug("    - filterHost: %r", filterHost)
        del sys.argv[i:i+2]

    # start out with no unmatched requests
    requests = {}

    # trace the file
    trace(sys.argv[1], [ReadPropertySummary])

    # dump the requests that failed
    for msg in traffic:
        if not msg.resp:
            print strftimestamp(msg.req._timestamp), msg.req.objectIdentifier, msg.req.propertyIdentifier

except KeyboardInterrupt:
    pass
except Exception, e:
    _log.exception("an error has occurred: %s", e)
finally:
    if _debug: _log.debug("finally")

    if ('--dest' in sys.argv):
        i = sys.argv.index('--dest')
        filterDestination = Address(sys.argv[i + 1])
        if _debug: _log.debug("    - filterDestination: %r", filterDestination)
        del sys.argv[i:i + 2]

    # check for host
    if ('--host' in sys.argv):
        i = sys.argv.index('--host')
        filterHost = Address(sys.argv[i + 1])
        if _debug: _log.debug("    - filterHost: %r", filterHost)
        del sys.argv[i:i + 2]

    # trace the file(s)
    for fname in sys.argv[1:]:
        trace(fname, [IAmRouterToNetworkSummary])

    # sort the result, descending order by count
    items = requests.items()
    items.sort(lambda x, y: cmp(y[1], x[1]))

    # print everything out
    print "%-20s %5s" % ("Address", "Count")
    for key, count in items:
        print "%-20s %5d" % (key, count)

        # count the number of times of each network
        net_count = defaultdict(int)
        for subnet_list in networks[key]:
            for net in subnet_list:
                net_count[net] += 1
        del sys.argv[i : i + 2]

    # check for host
    if "--host" in sys.argv:
        i = sys.argv.index("--host")
        filterHost = Address(sys.argv[i + 1])
        if _debug:
            _log.debug("    - filterHost: %r", filterHost)
        del sys.argv[i : i + 2]

    # start out with no requests
    requests = {}

    # trace the file(s)
    for fname in sys.argv[1:]:
        trace(fname, [COVNotificationSummary])

    # sort the result, descending order by count
    items = requests.items()
    items.sort(lambda x, y: cmp(y[1], x[1]))

    # print everything out
    print "%-20s %8s %-15s %4s %5s" % ("Address", "Device", "Object", "", "Count")
    for key, count in items:
        print "%-20s %8s %-15s %4d %5d" % (key[0], key[1], key[2][0], key[2][1], count)

except KeyboardInterrupt:
    pass
except Exception, e:
    _log.exception("an error has occurred: %s", e)
finally:
Beispiel #20
0
        filterDestination = Address(sys.argv[i + 1])
        if _debug: _log.debug("    - filterDestination: %r", filterDestination)
        del sys.argv[i:i + 2]

    # check for host
    if ('--host' in sys.argv):
        i = sys.argv.index('--host')
        filterHost = Address(sys.argv[i + 1])
        if _debug: _log.debug("    - filterHost: %r", filterHost)
        del sys.argv[i:i + 2]

    # start out with no unmatched requests
    requests = {}

    # trace the file
    trace(sys.argv[1], [ReadPropertySummary])

    # dump the requests that failed
    for msg in traffic:
        if not msg.resp:
            print strftimestamp(
                msg.req._timestamp
            ), msg.req.objectIdentifier, msg.req.propertyIdentifier

except KeyboardInterrupt:
    pass
except Exception, e:
    _log.exception("an error has occurred: %s", e)
finally:
    if _debug: _log.debug("finally")