Ejemplo n.º 1
0
        /// <summary>
        ///   What to do when a packet relevant to the highlight flooding algorithm is received
        ///
        ///   If the node has not already received one of the highlight flooding packets flood highlight packets along all links and send a new
        ///   highlight all packet back towards the source of the received packet
        /// </summary>
        /// <param name = "packet"></param>
        public void HighlightAll(IMNodeInternal hop)
        {
            if (HighlightingAll)
            {
                return;
            }

            lock (HighlightLock) {
                _highlightedLink = ForwardingTable.ContainsKey(_globalTargetKey) ? ForwardingTable[_globalTargetKey] : null;
                _highlightState  = HighlghtState.HighlightingAll;

                if (_highlightedLink != null)
                {
                    _highlightedLink.Colour = _globalHighlightColour;
                }

                foreach (IMLink l in _links)
                {
                    IMNode neighbour = l.OtherEnd(this);
                    if (!neighbour.Equals(hop))
                    {
                        neighbour.HighlightAll(this);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <inhertidoc />
        public void TriggerHighlight(string alg, IMNodeInternal target)
        {
            if (Equals(_globalHighlightTarget) || Equals(_globalHighlightRoot))
            {
                TriggerHighlightReset();
                return;
            }

            ClearOld();

            _globalTargetKey       = target.ID;
            _globalHighlightTarget = (IMNode)target;
            _globalHighlightRoot   = this;
            _globalHighlightColour = Colour;
            _globalHighlightState  = HighlghtState.HighlightingSingle;
            _highlightState        = HighlghtState.HighlightingSingle;

            //If there is a route
            if (ForwardingTable.ContainsKey(_globalTargetKey))
            {
                lock (HighlightLock) {
                    _highlightedLink        = ForwardingTable[_globalTargetKey];
                    _highlightedLink.Colour = _globalHighlightColour;
                    IMNode node = ForwardingTable[_globalTargetKey].OtherEnd(this);
                    node.Highlight(this);
                }
            }
            else
            {
                _highlightedLink = null;
            }
        }
Ejemplo n.º 3
0
        /// <Inheritdoc />
        public void Send(IMNodeExternal destination, Parameters parameters)
        {
            if (!ForwardingTable.ContainsKey(destination.ID))
            {
                Say("Unable to forward packet to " + destination.Name);
                return;
            }

            IMLink link = ForwardingTable[destination.ID];

            SendPacket(ID, link.ID, new MPacket(this, destination, this, parameters));
        }
Ejemplo n.º 4
0
 /// <summary>
 ///   What to do when a data packet is received.
 ///
 ///   Will either forward the packet along the relevant link in the routing table or
 ///   print out that the packet was received in world.
 /// </summary>
 /// <param name = "packet">The packet</param>
 protected virtual void ReceiveData(IMPacket packet)
 {
     if (ID.Equals(packet.D))
     {
         Say("Received " + packet.Name);
         Util.Wake(this);
     }
     else if (packet.D != null && ForwardingTable.ContainsKey(packet.D))
     {
         packet.Hop = this;
         SendPacket(this.ID, ForwardingTable[packet.D].ID, packet);
     }
     else
     {
         dropped(packet);
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        ///   What to do when notified that it should highlight
        ///
        ///   Will highlight the link and forward the packet on if necessary
        /// </summary>
        /// <param name = "packet">The packet received</param>
        public void Highlight(IMNodeInternal hop)
        {
            _highlightedLink = ForwardingTable.ContainsKey(_globalTargetKey) ? ForwardingTable[_globalTargetKey] : null;

            if (HighlightingSingle ||
                (_highlightedLink != null && _highlightedLink.OtherEnd(this).Equals(hop)))
            {
                return;
            }

            lock (HighlightLock) {
                _highlightState = HighlghtState.HighlightingSingle;

                if (_highlightedLink != null)
                {
                    _highlightedLink.Colour = _globalHighlightColour;
                    _highlightedLink.OtherEnd(this).Highlight(this);
                }
            }
        }
Ejemplo n.º 6
0
        /* komutacja, wejście to dane węzła źródłowego */
        public void Commutation(Cell cell)
        {
            cloud.Log.Queue.Enqueue("COMMUTATION (entry): " + cell.nodeID + " " + cell.portID);
            HalfEntryForwarding source = new HalfEntryForwarding(cell.nodeID, cell.portID);

            cloud.Log.Queue.Enqueue("Matrix {src}: " + "node=" + cell.nodeID + " port=" + cell.portID);

            if (fTable.ContainsKey(source))
            {
                HalfEntryForwarding target = fTable[source]; // znalezienie węzła docelowego w tablicy


                cell.nodeID = target.ID;
                cell.portID = target.Port;

                /* informacja o danych na wyjście */
                cloud.Log.Queue.Enqueue("Matrix {dest}: " + "node=" + cell.nodeID + " port=" + cell.portID);

                cloud.output.Send(cell);

                cloud.Log.Queue.Enqueue("Commutate to (node=" + cell.nodeID + " port=" + cell.portID + " VPI= " + cell.VPI + " VCI=" + cell.VCI + "): " + Encoding.UTF8.GetString(cell.Data));
            }
        }