예제 #1
0
        private void IncomingOlsrTopologyControlMessageHandler(NetSimMessage message)
        {
            OlsrTopologyControlMessage topMessage = (OlsrTopologyControlMessage)message;

            // if own tc message
            if (topMessage.Sender.Equals(this.Client.Id))
            {
                // drop message
                return;
            }

            // process tc message
            foreach (var mprSelector in topMessage.MultiPointRelaySelectorSet)
            {
                if (
                    !this.TopologyTable.Entries.Any(
                        e => e.OriginatorId.Equals(topMessage.Sender) && e.MprSelectorId.Equals(mprSelector)))
                {
                    this.TopologyTable.AddEntry(topMessage.Sender, mprSelector);
                    this.IsTopologyUpdate = true;
                }
            }

            // A node P forwards control messages only from MPRsel(P)
            if (this.MultiPointRelaySelectorSet.Contains(topMessage.Sender))
            {
                // forward message
                this.BroadcastTopologyControlMessages(topMessage);
            }
        }
예제 #2
0
        /// <summary>
        /// Clones this instance.
        /// </summary>
        /// <returns>
        /// A new object that is a copy of this instance.
        /// </returns>
        public override object Clone()
        {
            var clone = new OlsrTopologyControlMessage()
            {
                SequenceNr = (OlsrSequence)this.SequenceNr?.Clone(),
                MultiPointRelaySelectorSet = new List <string>(this.MultiPointRelaySelectorSet)
            };

            return(this.CopyTo(clone));
        }
예제 #3
0
        /// <summary>
        /// Broadcasts the topology control messages.
        /// </summary>
        /// <param name="message">The message.</param>
        private void BroadcastTopologyControlMessages(OlsrTopologyControlMessage message)
        {
            // TODO Check if send to every node or only to MPRsel set

            // broadcast topology control messages to mpr selector set neighbors
            foreach (var entry in this.OneHopNeighborTable.Entries)
            {
                // TODO  .Where(e => MultiPointRelaySelectorSet.Contains(e.NeighborId))
                // copy message before forwarding
                var localMessageCopy = (OlsrTopologyControlMessage)message.Clone();

                // A node P sends control messages only to MPRsel(P)
                localMessageCopy.Receiver = entry.NeighborId;

                if (this.IsConnectionReachable(entry.NeighborId))
                {
                    this.Client.Connections[entry.NeighborId].StartTransportMessage(
                        localMessageCopy,
                        this.Client.Id,
                        entry.NeighborId);
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Broadcasts the topology control messages.
        /// </summary>
        private void BroadcastTopologyControlMessages()
        {
            // broadcast topology control messages to mpr selector set neighbors
            foreach (
                var entry in
                this.OneHopNeighborTable.Entries.Where(e => this.MultiPointRelaySelectorSet.Contains(e.NeighborId)))
            {
                // A node P sends control messages only to MPRsel(P)
                var message = new OlsrTopologyControlMessage()
                {
                    Sender   = this.Client.Id,
                    Receiver = entry.NeighborId,
                    MultiPointRelaySelectorSet = new List <string>(this.MultiPointRelaySelectorSet)
                };

                if (this.IsConnectionReachable(entry.NeighborId))
                {
                    this.Client.Connections[entry.NeighborId].StartTransportMessage(
                        message,
                        this.Client.Id,
                        entry.NeighborId);
                }
            }
        }