Exemplo n.º 1
0
        static void MacBase_OnNeighborChange(IMAC macInstance, DateTime time)
        {
            var neighborList = MACBase.NeighborListArray();

            macInstance.NeighborList(neighborList);
            PrintNeighborList("\t\tNeighbor list CHANGE for Node [" + _macBase.MACRadioObj.RadioAddress + "]: ", neighborList);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Send a message to all neighbors
        /// </summary>
        /// <param name="mac"></param>
        /// <param name="message"></param>
        /// <param name="messageLength"></param>
        public static void Broadcast(IMAC mac, byte[] message, int messageLength)
        {
            var neighbors = MACBase.NeighborListArray();

            mac.NeighborList(neighbors);
#if !DBG_LOGIC
            PrintNeighborList(mac);
#endif

            var pipe = mac as MACPipe;

#if DBG_VERBOSE
            if (pipe != null)
            {
                PrintNumericVals("Broadcast (on MACPipe " + pipe.PayloadType + "): ", message, messageLength);
            }
            else
            {
                PrintNumericVals("Broadcast: ", message, messageLength);
            }
#endif
            foreach (var theNeighbor in neighbors)
            {
                if (theNeighbor == 0)
                {
                    continue;
                }
                var status = pipe.EnqueueToSend(theNeighbor, message, 0, (ushort)messageLength);

#if DBG_VERBOSE
                if (status != NetOpStatus.S_Success)
                {
                    Debug.Print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Send status: " + status);
                }

                Debug.Print("\tSent to " + theNeighbor);
#elif DBG_SIMPLE
                Debug.Print("\tSent to " + theNeighbor + ", status: " + status);
#endif
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Send a message to all neighbors - moved here from SystemGlobal
        /// </summary>
        /// <param name="mac"></param>
        /// <param name="message"></param>
        /// <param name="messageLength"></param>
        public static void BroadcastBeacon(IMAC mac, byte[] message, int messageLength)
        {
            var neighbors = MACBase.NeighborListArray();

            mac.NeighborList(neighbors);
#if !DBG_LOGIC
            SystemGlobal.PrintNeighborList(mac);
#endif

            var pipe = mac as MACPipe;

#if DBG_VERBOSE
            if (pipe != null)
            {
                PrintNumericVals("Broadcast (on MACPipe " + pipe.PayloadType + "): ", message, messageLength);
            }
            else
            {
                PrintNumericVals("Broadcast: ", message, messageLength);
            }
#endif
            foreach (var theNeighbor in neighbors)
            {
                if (theNeighbor == 0)
                {
                    continue;
                }
                var status = pipe.EnqueueToSend(theNeighbor, message, 0, (ushort)messageLength);

                if (pipe.IsMsgIDValid(status))
                {
                    // Update link metrics
                    if (theNeighbor == Parent)
                    {
                        UpdateNumTriesInCurrentWindow_Parent(1);
#if !DBG_LOGIC
                        Debug.Print("Updated numTriesInCurrentWindow for parent " + theNeighbor + "; new value = " + GetNumTriesInCurrentWindow_Parent());
#endif
                    }
                    else
                    {
                        byte cindex = CandidateTable.findIndex(theNeighbor);
                        if (cindex < byte.MaxValue)
                        {
                            CandidateTable._candidateList[cindex].UpdateNumTriesInCurrentWindow(1);
#if !DBG_LOGIC
                            Debug.Print("Updated numTriesInCurrentWindow for candidate " + theNeighbor + "; new value = " + CandidateTable._candidateList[cindex].GetNumTriesInCurrentWindow());
#endif
                        }
                    }


#if DBG_VERBOSE
                    if (status != NetOpStatus.S_Success)
                    {
                        Debug.Print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Send status: " + status);
                    }

                    Debug.Print("\tSent to " + theNeighbor);
#elif DBG_SIMPLE
                    Debug.Print("\tSent to " + theNeighbor + ", status: " + status);
#endif
                }
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Print the neighbor list from MACBase instance
 /// </summary>
 /// <param name="macBase"></param>
 public static void PrintNeighborList(IMAC macBase)
 {
     macBase.NeighborList(Neighbors);
     PrintNumericVals("Neighbor List [for " + macBase.MACRadioObj.RadioAddress + "] ", Neighbors);
 }