Ejemplo n.º 1
0
        private void sendResponse(PEQTableEntrySubscription Subscription,
            PEQMessageSearch msg)
        {
            PEQMessageResponse newMsg = new PEQMessageResponse(msg._SenderID,
                _id, msg._SequenceNumber, Subscription._HopCount,
                msg._SinkID);
            newMsg._nextHopCheat = _location;

            PEQTimerMessage timerEvent = new PEQTimerMessage(newMsg,
                _eventManager.CurrentClock + _TIMER_RANDOM_WAIT_SEND
                * RandomValue.NextDouble(), this);
            _eventManager.AddEvent(timerEvent);
        }
 public new object Clone()
 {
     PEQMessageResponse msg =
         new PEQMessageResponse(_DestinationID, _SenderID, _SequenceNumber,
         _HopCount, _SinkID);
     msg._nextHopCheat = _nextHopCheat;
     return msg;
 }
Ejemplo n.º 3
0
        private void processResponse(PEQMessageResponse msg)
        {
            bool allReceived = true;
            PEQTableEntrySearch winner = null;
            Byte hopCount = 0xFF;
            foreach (PEQTableEntrySearch entry in _tableSearch)
            {
                if ((msg._SinkID == entry._SinkID)
                    && (msg._SenderID == entry._DestinationID))
                {
                    entry._ResponseReceived = true;
                    entry._HopCount = msg._HopCount;
                    entry._nextHopCheat = msg._nextHopCheat;

                    // Update Subscription
                    bool found = false;
                    foreach (PEQTableEntrySubscription subscription in
                        _tableSubscription)
                    {
                        if ((subscription._DestinationID == msg._SenderID)
                            && (subscription._SinkID == msg._SinkID))
                        {
                            found = true;
                            subscription._HopCount = msg._HopCount;
                            subscription._Valid = true;
                            subscription._nextHopCheat = msg._nextHopCheat;
                            subscription._Timestamp = _eventManager.CurrentClock;
                        }
                    }
                    if (!found && (msg._HopCount < 0xFF)) // add!
                    {
                        PEQTableEntrySubscription newSubscription = new PEQTableEntrySubscription();
                        newSubscription._CriteriaType = 0x0001;  // this should be included with Search/Response message
                        newSubscription._DestinationID = msg._SenderID;
                        newSubscription._HopCount = msg._HopCount;
                        newSubscription._nextHopCheat = msg._nextHopCheat;
                        newSubscription._SinkID = msg._SinkID;
                        newSubscription._Timestamp = _eventManager.CurrentClock;
                        newSubscription._Valid = true;

                        _tableSubscription.Add(newSubscription);
                    }
                }
                else if ((msg._SinkID == entry._SinkID)
                    && (!entry._ResponseReceived))
                    allReceived = false;
                if (entry._HopCount < hopCount)
                {
                    hopCount = entry._HopCount;
                    winner = entry;
                }
            }

            if (allReceived)
            {
                completeSearch(winner);
            }
        }