コード例 #1
0
    def Filter(self, pkt):
        if _debug:
            AddressFilterTracer._debug("Filter %r", pkt)

        # apply the filters
        if filterSource:
            if not Match(pkt.pduSource, filterSource):
                if _debug:
                    AddressFilterTracer._debug("    - source filter fail")
                return
        if filterDestination:
            if not Match(pkt.pduDestination, filterDestination):
                if _debug:
                    AddressFilterTracer._debug("    - destination filter fail")
                return
        if filterHost:
            if (not Match(pkt.pduSource, filterHost)) and (
                not Match(pkt.pduDestination, filterHost)
            ):
                if _debug:
                    AddressFilterTracer._debug("    - host filter fail")
                return

        # passed all the filter tests
        print(strftimestamp(pkt._timestamp), pkt.__class__.__name__)
        pkt.debug_contents()
        print
コード例 #2
0
    def Filter(self, pkt):
        if _debug: WhoIsIAmDevice._debug("Filter %r", pkt)
        global requests

        # apply the filters
        if filterSource:
            if not Match(pkt.pduSource, filterSource):
                if _debug: WhoIsIAmDevice._debug("    - source filter fail")
                return
        if filterDestination:
            if not Match(pkt.pduDestination, filterDestination):
                if _debug: WhoIsIAmDevice._debug("    - destination filter fail")
                return
        if filterHost:
            if (not Match(pkt.pduSource, filterHost)) and (not Match(pkt.pduDestination, filterHost)):
                if _debug: WhoIsIAmDevice._debug("    - host filter fail")
                return

        # check for Who-Is
        if isinstance(pkt, WhoIsRequest):
            match = False
            if (pkt.deviceInstanceRangeLowLimit is None) or (pkt.deviceInstanceRangeHighLimit is None):
                match = True
            elif (pkt.deviceInstanceRangeLowLimit >= filterDevice) and (pkt.deviceInstanceRangeHighLimit <= filterDevice):
                match = True

            if match:
                print "[%d] %s WhoIs %-20s %-20s %8s %8s" % (
                    pkt._index + 1, strftimestamp(pkt._timestamp), 
                    pkt.pduSource, pkt.pduDestination,
                    pkt.deviceInstanceRangeLowLimit, pkt.deviceInstanceRangeHighLimit,
                    )

        # check for I-Am
        elif isinstance(pkt, IAmRequest):

            if (pkt.iAmDeviceIdentifier[1] == filterDevice):
                print "[%d] %s IAm   %-20s %-20s" % (
                    pkt._index + 1, strftimestamp(pkt._timestamp),
                    pkt.pduSource, pkt.pduDestination,
                    )
コード例 #3
0
    def Filter(self, pkt):
        if _debug: AddressFilterTracer._debug("Filter %r", pkt)

        # apply the filters
        if filterSource:
            if not Match(pkt.pduSource, filterSource):
                if _debug:
                    AddressFilterTracer._debug("    - source filter fail")
                return
        if filterDestination:
            if not Match(pkt.pduDestination, filterDestination):
                if _debug:
                    AddressFilterTracer._debug("    - destination filter fail")
                return
        if filterHost:
            if (not Match(pkt.pduSource, filterHost)) and (not Match(
                    pkt.pduDestination, filterHost)):
                if _debug: AddressFilterTracer._debug("    - host filter fail")
                return

        # passed all the filter tests
        print strftimestamp(pkt._timestamp), pkt.__class__.__name__
        pkt.debug_contents()
        print
コード例 #4
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]

    # 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")

コード例 #5
0
    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:
            print strftimestamp(req._timestamp), '\t', req.pduSource, '\t', "----------", '\t', "----------", '\t', msg.retry if (msg.retry != 1) else ""

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

        xlw, lw, q1, m, q3, uw, xuw = stats.Whisker()
        if m is not None:
            print "\t    %-8.1f" % smax
            print "\t    %-8.1f" % xuw
            print "\t--- %-8.1f" % uw
            print "\t | "
            print "\t.'. %-8.1f" % q3
            print "\t| |"
            print "\t|-| %-8.1f" % m
コード例 #6
0
    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)

# start out with no unmatched requests
requests = {}

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

# dump the requests that failed
for msg in traffic:
    if not msg.resp:
        print(
            "%s\t%s\t%s"
            % (
                strftimestamp(msg.req._timestamp),
                msg.req.objectIdentifier,
                msg.req.propertyIdentifier,
            )
        )
コード例 #7
0
    # 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:
            print strftimestamp(
                req._timestamp
            ), '\t', req.pduSource, '\t', "----------", '\t', "----------", '\t', msg.retry if (
                msg.retry != 1) else ""

    if stats:
        xlw, lw, q1, m, q3, uw, xuw = stats.Whisker()
        if m is not None:
            print "\t    %-6.1f" % xuw
            print "\t--- %-6.1f" % uw
            print "\t | "
            print "\t.'. %-6.1f" % q3
コード例 #8
0
        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:
            print "\t    %-8.1f" % smax
            print "\t    %-8.1f" % xuw
            print "\t--- %-8.1f" % uw
            print "\t | "
            print "\t.'. %-8.1f" % q3
            print "\t| |"
            print "\t|-| %-8.1f" % m
コード例 #9
0
        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:
            print "\t    %-8.1f" % smax
            print "\t    %-8.1f" % xuw
            print "\t--- %-8.1f" % uw
            print "\t | "
            print "\t.'. %-8.1f" % q3
            print "\t| |"
            print "\t|-| %-8.1f" % m
コード例 #10
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")
コード例 #11
0
# trace the file(s)
for fname in args.pcap:
    trace(fname, [ReadPropertySummary])

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

    if resp:
        deltatime = (resp._timestamp - req._timestamp) * 1000
        print(
            "%s\t%s\t%s\t%6.2fms\t%s"
            % (
                strftimestamp(req._timestamp),
                req.pduSource,
                resp.pduSource,
                deltatime,
                msg.retry if (msg.retry != 1) else "",
            )
        )
    else:
        print(
            "%s\t%s\t%s\t%6.2fms\t%s"
            % (
                strftimestamp(req._timestamp),
                req.pduSource,
                "-",
                0,
                msg.retry if (msg.retry != 1) else "",