/// <summary>
        /// Encode NetWork Detection Request
        /// </summary>
        /// <param name="sendBuffer">The buffer list to contain the encoded PDU.</param>
        /// <param name="networkDetectionRequest">The Network Detect Request want to be encoded</param>
        internal static void EncodeNetworkDetectionRequest(List <byte> sendBuffer, NETWORK_DETECTION_REQUEST networkDetectionRequest, bool isSubHeader = false)
        {
            if (!isSubHeader)
            {
                EncodeStructure(sendBuffer, networkDetectionRequest.headerLength);
                EncodeStructure(sendBuffer, (byte)networkDetectionRequest.headerTypeId);
            }
            EncodeStructure(sendBuffer, networkDetectionRequest.sequenceNumber);
            EncodeStructure(sendBuffer, (ushort)networkDetectionRequest.requestType);

            AUTO_DETECT_REQUEST_TYPE requestType = networkDetectionRequest.requestType;

            if (requestType == AUTO_DETECT_REQUEST_TYPE.RDP_RTT_REQUEST_IN_CONNECTTIME || requestType == AUTO_DETECT_REQUEST_TYPE.RDP_RTT_REQUEST_AFTER_CONNECTTIME)
            {
                //RDP_RTT_REQUEST
            }
            else if (requestType == AUTO_DETECT_REQUEST_TYPE.RDP_BW_START_IN_CONNECTTIME || requestType == AUTO_DETECT_REQUEST_TYPE.RDP_BW_START_AFTER_CONNECTTIME_OR_RELIABLEUDP || requestType == AUTO_DETECT_REQUEST_TYPE.RDP_BW_START_AFTER_CONNECTTIME_OR_LOSSYUDP)
            {
                //RDP_BW_START
            }
            else if (requestType == AUTO_DETECT_REQUEST_TYPE.RDP_BW_PAYLOAD)
            {
                //RDP_BW_PAYLOAD
                RDP_BW_PAYLOAD bwPayload = (RDP_BW_PAYLOAD)networkDetectionRequest;
                EncodeStructure(sendBuffer, bwPayload.payloadLength);
                EncodeBytes(sendBuffer, bwPayload.payload);
            }
            else if (requestType == AUTO_DETECT_REQUEST_TYPE.RDP_BW_STOP_IN_CONNECTTIME || requestType == AUTO_DETECT_REQUEST_TYPE.RDP_BW_STOP_AFTER_CONNECTTIME_OR_RELIABLEUDP || requestType == AUTO_DETECT_REQUEST_TYPE.RDP_BW_STOP_AFTER_CONNECTTIME_OR_LOSSYUDP)
            {
                //RDP_BW_STOP
                if (requestType == AUTO_DETECT_REQUEST_TYPE.RDP_BW_STOP_IN_CONNECTTIME)
                {
                    RDP_BW_STOP bwStop = (RDP_BW_STOP)networkDetectionRequest;
                    EncodeStructure(sendBuffer, bwStop.payloadLength);
                    EncodeBytes(sendBuffer, bwStop.payload);
                }
            }
            else if (requestType == AUTO_DETECT_REQUEST_TYPE.RDP_NETCHAR_RESULT_BANDWIDTH_AVERAGERTT || requestType == AUTO_DETECT_REQUEST_TYPE.RDP_NETCHAR_RESULT_BASERTT_AVERAGERTT || requestType == AUTO_DETECT_REQUEST_TYPE.RDP_NETCHAR_RESULT_BASERTT_BANDWIDTH_AVERAGERTT)
            {
                //RDP_NETCHAR_RESULT
                RDP_NETCHAR_RESULT netCharResult = (RDP_NETCHAR_RESULT)networkDetectionRequest;
                if (requestType == AUTO_DETECT_REQUEST_TYPE.RDP_NETCHAR_RESULT_BANDWIDTH_AVERAGERTT)
                {
                    EncodeStructure(sendBuffer, netCharResult.bandwidth);
                    EncodeStructure(sendBuffer, netCharResult.averageRTT);
                }
                else if (requestType == AUTO_DETECT_REQUEST_TYPE.RDP_NETCHAR_RESULT_BASERTT_AVERAGERTT)
                {
                    EncodeStructure(sendBuffer, netCharResult.baseRTT);
                    EncodeStructure(sendBuffer, netCharResult.averageRTT);
                }
                else if (requestType == AUTO_DETECT_REQUEST_TYPE.RDP_NETCHAR_RESULT_BASERTT_BANDWIDTH_AVERAGERTT)
                {
                    EncodeStructure(sendBuffer, netCharResult.baseRTT);
                    EncodeStructure(sendBuffer, netCharResult.bandwidth);
                    EncodeStructure(sendBuffer, netCharResult.averageRTT);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Send a Tunnel Data PDU with RDP_BW_STOP in its subheader
        /// </summary>
        /// <param name="requestedProtocol"></param>
        /// <param name="sequenceNumber"></param>
        private void SendTunnelDataPdu_BWStop(Multitransport_Protocol_value requestedProtocol, ushort sequenceNumber)
        {
            AUTO_DETECT_REQUEST_TYPE requestType  = AUTO_DETECT_REQUEST_TYPE.RDP_BW_STOP_AFTER_CONNECTTIME_OR_RELIABLEUDP;
            RdpemtServer             rdpemtServer = rdpemtServerR;

            if (requestedProtocol == Multitransport_Protocol_value.INITITATE_REQUEST_PROTOCOL_UDPFECL)
            {
                requestType  = AUTO_DETECT_REQUEST_TYPE.RDP_BW_STOP_AFTER_CONNECTTIME_OR_LOSSYUDP;
                rdpemtServer = rdpemtServerL;
            }
            RDP_BW_STOP bwStop = RdpbcgrUtility.GenerateBandwidthMeasureStop(requestType, sequenceNumber);

            byte[]        reqData       = rdpbcgrServer.EncodeNetworkDetectionRequest(bwStop, true);
            List <byte[]> subHdDataList = new List <byte[]>();

            subHdDataList.Add(reqData);
            RDP_TUNNEL_DATA tunnelData = rdpemtServer.CreateTunnelDataPdu(null, subHdDataList);

            rdpemtServer.SendRdpemtPacket(tunnelData);
        }
Esempio n. 3
0
        /// <summary>
        /// Send a Tunnel Data PDU with RTT Measure Request in its subheader
        /// </summary>
        /// <param name="udpTransportMode">Transport Mode: Reliable or Lossy</param>
        private void SendTunnelDataPdu_RTTMeasureRequest(Multitransport_Protocol_value requestedProtocol, ushort sequenceNumber)
        {
            AUTO_DETECT_REQUEST_TYPE requestType  = AUTO_DETECT_REQUEST_TYPE.RDP_RTT_REQUEST_AFTER_CONNECTTIME;
            RdpemtServer             rdpemtServer = rdpemtServerR;

            if (requestedProtocol == Multitransport_Protocol_value.INITITATE_REQUEST_PROTOCOL_UDPFECL)
            {
                rdpemtServer = rdpemtServerL;
            }
            RDP_RTT_REQUEST RTTRequest = RdpbcgrUtility.GenerateRTTMeasureRequest(requestType, sequenceNumber);

            byte[]        reqData       = rdpbcgrServer.EncodeNetworkDetectionRequest(RTTRequest, true);
            List <byte[]> subHdDataList = new List <byte[]>();

            subHdDataList.Add(reqData);
            RDP_TUNNEL_DATA tunnelData = rdpemtServer.CreateTunnelDataPdu(null, subHdDataList);

            rttDataStore.requestTime = DateTime.Now;
            rdpemtServer.SendRdpemtPacket(tunnelData);
        }