Example #1
0
        //  Overload for AckMode                (JNW Jan15)

        public Boolean Send(Frame.TransmitFrame transmitFrame)
        {
            String parsedFrameString = "";

            Byte[] buf = transmitFrame.ibuf;

            //
            // Post outbound packet to monitor queue if enabled
            //

            Byte[] tmp = new Byte[buf.Length];
            buf.CopyTo(tmp, 0);

            new Frame.ReceivedFrame(tmp, out parsedFrameString);

            if (!_packetMonitorEnable.Equals(PacketMonitorType.None))
            {
                StringBuilder frameString = new StringBuilder("|chan:" + chanNum.ToString() + "|-->", 4096);
                frameString.Append(parsedFrameString);
                if (_packetMonitorEnable.Equals(PacketMonitorType.LogFile) || _packetMonitorEnable.Equals(PacketMonitorType.Both))
                {
                    Support.PktPrint(frameString.ToString() + CRLF, ref packetLogSyncObject);
                }

                if (_packetMonitorEnable.Equals(PacketMonitorType.Queue) || _packetMonitorEnable.Equals(PacketMonitorType.Both))
                {
                    packetMonitorQueue.Enqueue(frameString.ToString());
                }
            }

            return(comSerialPort.SendCmd(chanNum, 0, transmitFrame));
        }
Example #2
0
        //
        // Procesing thread for incoming packets from the TNC.  The TNC places a buffer
        // containing the incoming data into the channel's receive queue.  This routine pulls
        // these frames from the queue for processing.
        //
        // Processing steps:
        //      - Parse the raw incoming frame into a receive buffer.
        //      - Find the Data Link Provider handling incoming data for the Station ID
        //        specified in the incoming address field of the packet.  If no matching
        //        dlp is registered, then we simply drop the packet.  (Future: we add in support
        //        for multi-cast packets, which will forward to all registered DLPs)
        //      - Place the frame, source, and buffer type into a packet object and place it into the
        //        receive queue of the target DLP.
        //

        void RecvFromPort()
        {
            String parsedFrameString = "";

            Byte[] buf;

            Support.DbgPrint(Thread.CurrentThread.Name + "Starting.");
            while (runFlag && comSerialPort.Enabled)
            {
                try
                {
                    buf = Recv();
                }
                catch
                {
                    continue;
                }

                if (buf == null)
                {
                    continue;
                }

                // check for ACKMODE Response (Need to be at channel level to find DLC)       (JNW Jan15)

                if (buf.Length == 2)            // Only ACK frames are this short
                {
                    Int16      AckID = (Int16)(buf[0] << 8 | buf[1]);
                    Connection con;

                    lock (dataLinkProviderList)

                        foreach (DataLinkProvider dlp in dataLinkProviderList)
                        {
                            con = GetConnectionByACKModeID(dlp, AckID);

                            if (con != null)
                            {
                                // Set Timer back to normal

                                con.timerAck.SetTime(con.smoothedRoundTrip, true);

                                break;
                            }
                        }

                    continue;                   // Donf pass Ack frame up to next level
                }


                //
                // Parse raw buffer
                //
                Frame.ReceivedFrame pFrame = new Frame.ReceivedFrame(buf, out parsedFrameString);

                //
                // Output to monitor queue is enabled
                //
                if (!_packetMonitorEnable.Equals(PacketMonitorType.None))
                {
                    StringBuilder frameString = new StringBuilder("|chan:" + chanNum.ToString() + "|<--", 4096);
                    frameString.Append(parsedFrameString);
                    if (_packetMonitorEnable.Equals(PacketMonitorType.LogFile) || _packetMonitorEnable.Equals(PacketMonitorType.Both))
                    {
                        Support.PktPrint(frameString.ToString() + CRLF, ref packetLogSyncObject);
                    }

                    if (_packetMonitorEnable.Equals(PacketMonitorType.Queue) || _packetMonitorEnable.Equals(PacketMonitorType.Both))
                    {
                        packetMonitorQueue.Enqueue(frameString.ToString());
                    }
                }

                Frame.Packet packet = new Frame.Packet(pFrame);


                DigipeatCheckAndProcess(packet);
                //continue;


                //
                // Send up to the data link provider handling the specified StationID
                //
                //dlp.Send(packet);
            }
            Support.DbgPrint(Thread.CurrentThread.Name + "Exiting.");
        }