The RDP_BW_STOP structure is used to stop a bandwidth measurement operation.
Inheritance: NETWORK_DETECTION_REQUEST
コード例 #1
0
        /// <summary>
        /// Parse NETWORK_DETECTION_REQUEST
        /// </summary>
        /// <param name="data"></param>
        /// <param name="currentIndex"></param>
        /// <returns></returns>
        public NETWORK_DETECTION_REQUEST ParseNetworkDectectRequest(byte[] data, ref int currentIndex)
        {
            NETWORK_DETECTION_REQUEST detectRequest = null;
            byte headerLength = ParseByte(data, ref currentIndex);
            HeaderTypeId_Values headerTypeId = (HeaderTypeId_Values)ParseByte(data, ref currentIndex);
            ushort sequenceNumber = ParseUInt16(data, ref currentIndex, false);
            AUTO_DETECT_REQUEST_TYPE requestType = (AUTO_DETECT_REQUEST_TYPE)ParseUInt16(data, ref currentIndex, false);

            if (requestType == AUTO_DETECT_REQUEST_TYPE.RDP_RTT_REQUEST_IN_CONNECTTIME
                || requestType == AUTO_DETECT_REQUEST_TYPE.RDP_RTT_REQUEST_AFTER_CONNECTTIME)
            {
                RDP_RTT_REQUEST req = new RDP_RTT_REQUEST();
                req.headerLength = headerLength;
                req.headerTypeId = headerTypeId;
                req.sequenceNumber = sequenceNumber;
                req.requestType = requestType;

                detectRequest = req;
            }
            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 req = new RDP_BW_START();
                req.headerLength = headerLength;
                req.headerTypeId = headerTypeId;
                req.sequenceNumber = sequenceNumber;
                req.requestType = requestType;

                detectRequest = req;
            }
            else if (requestType == AUTO_DETECT_REQUEST_TYPE.RDP_BW_PAYLOAD)
            {
                RDP_BW_PAYLOAD req = new RDP_BW_PAYLOAD();
                req.headerLength = headerLength;
                req.headerTypeId = headerTypeId;
                req.sequenceNumber = sequenceNumber;
                req.requestType = requestType;
                req.payloadLength = ParseUInt16(data, ref currentIndex, false);
                req.payload = GetBytes(data, ref currentIndex, req.payloadLength);

                detectRequest = req;
            }
            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 req = new RDP_BW_STOP();
                req.headerLength = headerLength;
                req.headerTypeId = headerTypeId;
                req.sequenceNumber = sequenceNumber;
                req.requestType = requestType;
                if (req.headerLength > 0x06)
                {
                    req.payloadLength = ParseUInt16(data, ref currentIndex, false);
                    req.payload = GetBytes(data, ref currentIndex, req.payloadLength);
                }

                detectRequest = req;
            }
            else
            {
                RDP_NETCHAR_RESULT req = new RDP_NETCHAR_RESULT();
                req.headerLength = headerLength;
                req.headerTypeId = headerTypeId;
                req.sequenceNumber = sequenceNumber;
                req.requestType = requestType;
                if (requestType == AUTO_DETECT_REQUEST_TYPE.RDP_NETCHAR_RESULT_BANDWIDTH_AVERAGERTT)
                {
                    req.bandwidth = ParseUInt32(data, ref currentIndex, false);
                    req.averageRTT = ParseUInt32(data, ref currentIndex, false);
                }
                else if (requestType == AUTO_DETECT_REQUEST_TYPE.RDP_NETCHAR_RESULT_BASERTT_AVERAGERTT)
                {
                    req.baseRTT = ParseUInt32(data, ref currentIndex, false);
                    req.averageRTT = ParseUInt32(data, ref currentIndex, false);
                }
                else if (requestType == AUTO_DETECT_REQUEST_TYPE.RDP_NETCHAR_RESULT_BASERTT_BANDWIDTH_AVERAGERTT)
                {
                    req.baseRTT = ParseUInt32(data, ref currentIndex, false);
                    req.bandwidth = ParseUInt32(data, ref currentIndex, false);
                    req.averageRTT = ParseUInt32(data, ref currentIndex, false);
                }
                detectRequest = req;
            }

            return detectRequest;
        }
コード例 #2
0
        /// <summary>
        /// Encode a RDP_BW_STOP structure for subheader, don't encode the first two field 
        /// </summary>
        /// <param name="bwStop"></param>
        /// <returns></returns>
        public static byte[] EncodeRdpBWStop(RDP_BW_STOP bwStop)
        {
            List<byte> bufferList = new List<byte>();
            bufferList.AddRange(ToBytes(bwStop.sequenceNumber));
            bufferList.AddRange(ToBytes((ushort)bwStop.requestType));

            // payloadLength and payload Must not be present when the structure is in SubHeaderData of RDP_TUNNEL_SUBHEADER
            return bufferList.ToArray();
        }
コード例 #3
0
 public override NETWORK_DETECTION_REQUEST Clone()
 {
     RDP_BW_STOP bwStop = new RDP_BW_STOP();
     bwStop.headerLength = this.headerLength;
     bwStop.headerTypeId = this.headerTypeId;
     bwStop.requestType = this.requestType;
     bwStop.sequenceNumber = this.sequenceNumber;
     if (this.payloadLength != 0)
     {
         bwStop.payloadLength = this.payloadLength;
         bwStop.payload = RdpbcgrUtility.CloneByteArray(this.payload);
     }
     return bwStop;
 }
コード例 #4
0
        /// <summary>
        /// Parse RDP_BW_STOP structure from RDPEMT subheader
        /// </summary>
        /// <param name="data">Data of subheader, not include first two bytes of Parse RDP_BW_STOP</param>
        /// <returns></returns>
        public static RDP_BW_STOP ParseRdpBWStop(byte[] data)
        {
            RDP_BW_STOP bwStop = new RDP_BW_STOP();
            bwStop.sequenceNumber = ParseUInt16(data, 0);
            bwStop.requestType = (AUTO_DETECT_REQUEST_TYPE)ParseUInt16(data, 2);
            // payloadLength and payload Must not be present when the structure is in SubHeaderData of RDP_TUNNEL_SUBHEADER

            return bwStop;
        }