private static ArrayList _retriedPackets = new ArrayList(); // assumed number of retries=1

        /// <summary>
        /// Initialize net manager
        /// </summary>
        /// <param name="routing"></param>
        /// <param name="macBase"></param>
        public static void Initialize(MACBase macBase)
        {
#if !DBG_LOGIC
            Debug.Print("\n*** Initializing NetManager ***\n");
#endif
            //_routing = routing;
            //_netManagerPipe = new SimpleCSMAStreamChannel(macBase, (byte)AppGlobal.MacPipeIds.NetworkManager);
            _netManagerPipe            = new MACPipe(macBase, SystemGlobal.MacPipeIds.NetworkManager);
            _netManagerPipe.OnReceive += NetManagerStreamReceive;
#if RELAY_NODE || CLIENT_NODE
            _netManagerPipe.OnSendStatus += OnSendStatus;
#endif

#if !DBG_LOGIC
            Debug.Print("***** subscribing to Net Manager on " + SystemGlobal.MacPipeIds.NetworkManager);
#endif

#if RELAY_NODE || CLIENT_NODE
#if FastHeartbeat
            _heartbeatTimer = new Timer(Send_Heartbeat, null, 0, 60 * 1000);
#else
            _heartbeatTimer = new Timer(Send_Heartbeat, null, 0, 360 * 10000);
#endif
#endif

#if BASE_STATION
#if FastHeartbeat
            _heartbeatTimer = new Timer(Send_Heartbeat, null, 0, 60 * 1000);
#else
            _heartbeatTimer = new Timer(Send_Heartbeat, null, 0, 360 * 10000);
#endif
#endif
        }
        /// <summary>
        /// Initialize neighborinfo manager
        /// </summary>
        /// <param name="routing"></param>
        /// <param name="macBase"></param>
        public static void Initialize(MACBase macBase)
        {
#if !DBG_LOGIC
            Debug.Print("\n*** Initializing Neighborhood Manager ***\n");
#endif
            //_routing = routing;
            //_neighborInfoManagerPipe = new SimpleCSMAStreamChannel(macBase, (byte)AppGlobal.MacPipeIds.NetworkManager);
            _neighborInfoManagerPipe            = new MACPipe(macBase, SystemGlobal.MacPipeIds.NeighborInfoManager);
            _neighborInfoManagerPipe.OnReceive += NetManagerStreamReceive;
#if RELAY_NODE || CLIENT_NODE
            _neighborInfoManagerPipe.OnSendStatus += OnSendStatus;
#endif

#if !DBG_LOGIC
            Debug.Print("***** subscribing to Neighborhood Manager on " + SystemGlobal.MacPipeIds.NeighborInfoManager);
#endif

#if RELAY_NODE || CLIENT_NODE
#if FastHeartbeat
            _nbrInfoTimer = new Timer(Send_AdvancedHeartbeat, null, 180 * 10000, 60 * 1000);
#else
            _nbrInfoTimer = new Timer(Send_AdvancedHeartbeat, null, 180 * 10000, 360 * 10000); // Starts at half an hour
#endif
#endif
        }
Esempio n. 3
0
        /// <summary>
        /// Send to parent, if any
        /// </summary>
        /// <remarks>
        /// User should first check if IsParent is true and only then invoke this method.
        /// </remarks>
        /// <param name="mac"></param>
        /// <param name="msgBytes"></param>
        /// <param name="length"></param>
        /// <returns></returns>
        public static ushort SendToParent(MACPipe mac, byte[] msgBytes, int length)
        {
            // If in a reset, do not forward
            if (RoutingGlobal._color == Color.Red)
            {
#if DBG_VERBOSE
                Debug.Print("\tIn a Reset wave... not forwarded");
#endif
                return(999);
            }
            ushort index = mac.EnqueueToSend(_parent, msgBytes, 0, (ushort)length);
            return(mac.IsMsgIDValid(index) ? index : (ushort)999);
        }
Esempio n. 4
0
        public static ushort SendToChild(MACPipe mac, ushort destination, byte[] msgBytes, int length)
        {
            ushort next_neighbor = RoutingGlobal.GetChild(destination);

            // If in a reset, do not forward
            if (RoutingGlobal._color == Color.Red)
            {
#if DBG_VERBOSE
                Debug.Print("\tIn a Reset wave... not forwarded");
#endif
                return(999);
            }

            ushort index = mac.EnqueueToSend(next_neighbor, msgBytes, 0, (ushort)length);
            return(mac.IsMsgIDValid(index) ? index : (ushort)999);
        }
Esempio n. 5
0
        public static void CleanseCandidateTable(MACPipe pipe)
        {
            ushort[] _neighborList = MACBase.NeighborListArray();
            pipe.NeighborList(_neighborList); // Get current neighborlist
            foreach (Candidate c in CandidateTable._candidateList)
            {
                ushort macID = c.GetMacID();
                if (Array.IndexOf(_neighborList, macID) == -1)
                {
#if DBG_VERBOSE
                    Debug.Print("--- CANDIDATE LIST CLEANUP: Removing stale candidate: " + macID + " ---");
#elif DBG_SIMPLE
                    Debug.Print("Removing stale candidate: " + macID);
#endif
                    CandidateTable.DropCandidate(macID);
                }
            }
        }
Esempio n. 6
0
        public static void Initialize(MACBase macBase)
        {
            if (!IsInitialized)
            {
#if !DBG_LOGIC
                Debug.Print("\n*** Initializing Distributed Reset Module ***\n");
#endif
                //_netManagerPipe = new SimpleCSMAStreamChannel(macBase, (byte)AppGlobal.MacPipeIds.NetworkManager);
                _distResetPipe            = new MACPipe(macBase, SystemGlobal.MacPipeIds.DistReset);
                _distResetPipe.OnReceive += DistResetStreamReceive;
#if !DBG_LOGIC
                Debug.Print("***** subscribing to Distributed Reset on " + SystemGlobal.MacPipeIds.DistReset);
#endif
                _children            = new ChildrenList();
                RoutingGlobal._color = Color.Green;
                _distResetTimer      = new Timer(Reset_State, null, Timeout.Infinite, Timeout.Infinite);
                _statusResponseTimer = new Timer(Status_Response, null, Timeout.Infinite, Timeout.Infinite);
                IsInitialized        = true;
            }
        }
Esempio n. 7
0
 public static ushort SendToTempParent(MACPipe mac, byte[] msgBytes, int length)
 {
     return(mac.EnqueueToSend(TempParent, msgBytes, 0, (ushort)length));
 }