private void sendSearch(VarID SinkID, int searchCount) { PEQMessageSearch msg = new PEQMessageSearch(new VarID(SinkID.SizeOf()), _id, _sequenceNumber++, SinkID); msg._nextHopCheat = _location; PEQTimerMessage timerEvent = new PEQTimerMessage(msg, _eventManager.CurrentClock + _TIMER_RANDOM_WAIT_SEND * _randomValue.NextDouble(), this); _eventManager.AddEvent(timerEvent); PEQTimerSearch searchTimer = new PEQTimerSearch(_eventManager.CurrentClock + _physicalProcessor.MaximumRange * _TIMER_SEARCH / _physicalProcessor.PropagationSpeed, this); searchTimer._SinkID = SinkID; searchTimer._Count = ++searchCount; _eventManager.AddEvent(searchTimer); }
private void processSearchTimer(PEQTimerSearch timer) { // Find all Response entries and restart search if any are // not marked received in the table. if (timer._Count < 2) { foreach (PEQTableEntrySearch entry in _tableSearch) { if (entry._SinkID == timer._SinkID) { if (!entry._ResponseReceived) { // Resend search message & reset timer sendSearch(timer._SinkID, timer._Count); return; } } } } else { completeSearch(timer._SinkID); } clearTableSearch(timer._SinkID); }