public BACnetPacket waitForPacket(int timeout)
        {
            long startTime = _apm._stopWatch.ElapsedMilliseconds;

            while (_apm._stopWatch.ElapsedMilliseconds < startTime + timeout)
            {
                if (_apm.pktQueueToApplication.Count > 0)
                {
                    BACnetPacket bpk = _apm.pktQueueToApplication.myDequeue();
                    bpk.DecodeBACnet();
                    return(bpk);
                }
                Sleep(10);
            }
            // timeout - todo - one day create a timeout type of exception
            throw new TimeoutException();
        }
        // tests that only local devices answer to local broadcasts. (A type of router test).

        public override void Execute()
        {
            bool someFails = false;

            WaitForQuietOnIncomingPacketQueue();
            ClearIncomingPacketQueue();

            try
            {
                DADR dadr = new DADR(_bnm, BACnetPacket.ADDRESS_TYPE.LOCAL_BROADCAST);
                BACnetUtil.SendWhoIs(_apm, _bnm, dadr);
                // Sleep(1000);        // and perhaps longer on large networks....
                WaitForQuietOnIncomingPacketQueue();

                // check the incoming packets, make sure that they are all local addresses
                while (_apm.pktQueueToApplication.Count > 0)
                {
                    if (_apm.pktQueueToApplication.Count == 0)
                    {
                        // wait just a while longer, there may be more packets dribbling in. So by pausing here
                        // we wait 1 second longer than the last packet to arrive... seems reasonable to me
                        Sleep(1000);
                    }

                    BACnetPacket pkt = _apm.pktQueueToApplication.myDequeue();
                    pkt.DecodeBACnet();

                    if (pkt.srcDevice.adr.directlyConnected != true)
                    {
                        MarkDiagnosticFailed("A device [" + pkt.srcDevice.adr.ToString() + "] that is not directly connected responded");
                        someFails = true;
                    }
                }
            }
            catch (TimeoutException)
            {
                // todo-put a wrapper around execute and catch all executions in a common area..
                MarkDiagnosticFailed("Timeout");
                return;
            }
            if (someFails == false)
            {
                MarkDiagnosticSuccess();                     // Mark this diagnostic a success, any failures will re
            }
        }