The RDP_BW_START structure is used to start a bandwidth measurement operation.
Inheritance: NETWORK_DETECTION_REQUEST
Exemplo n.º 1
0
        /// <summary>
        /// Encode a RDP_BW_START structure for subheader, don't encode the first two field 
        /// </summary>
        /// <param name="bwStart"></param>
        /// <returns></returns>
        public static byte[] EncodeRdpBWStart(RDP_BW_START bwStart)
        {
            List<byte> bufferList = new List<byte>();
            bufferList.AddRange(ToBytes(bwStart.sequenceNumber));
            bufferList.AddRange(ToBytes((ushort)bwStart.requestType));

            return bufferList.ToArray();
        }
        /// <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;
        }
Exemplo n.º 3
0
 public override NETWORK_DETECTION_REQUEST Clone()
 {
     RDP_BW_START bwStart = new RDP_BW_START();
     bwStart.headerLength = this.headerLength;
     bwStart.headerTypeId = this.headerTypeId;
     bwStart.requestType = this.requestType;
     bwStart.sequenceNumber = this.sequenceNumber;
     return bwStart;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Parse RDP_BW_START structure from RDPEMT subheader
        /// </summary>
        /// <param name="data">Data of subheader, not include first two bytes of Parse RDP_BW_START</param>
        /// <returns></returns>
        public static RDP_BW_START ParseRdpBWStart(byte[] data)
        {
            RDP_BW_START bwStart = new RDP_BW_START();
            bwStart.sequenceNumber = ParseUInt16(data, 0);
            bwStart.requestType = (AUTO_DETECT_REQUEST_TYPE)ParseUInt16(data, 2);

            return bwStart;
        }