The RDP_BW_RESULTS structure is used to send the results of a bandwidth measurement operation to the initiating end-point.
Inheritance: NETWORK_DETECTION_RESPONSE
        /// <summary>
        /// Encode a RDP_BW_RESULTS structure for subheader, don't encode the first two field 
        /// </summary>
        /// <param name="bwStop"></param>
        /// <returns></returns>
        public static byte[] EncodeRdpBWResults(RDP_BW_RESULTS bwRes)
        {
            List<byte> bufferList = new List<byte>();
            bufferList.AddRange(ToBytes(bwRes.sequenceNumber));
            bufferList.AddRange(ToBytes((ushort)bwRes.responseType));
            bufferList.AddRange(ToBytes(bwRes.timeDelta));
            bufferList.AddRange(ToBytes(bwRes.byteCount));

            return bufferList.ToArray();
        }
 /// <summary>
 /// Verify RDP Bandwidth Measure Result packet
 /// </summary>
 /// <param name="BwResult">RDP Bandwidth Result packet</param>
 /// <param name="sequenceNumber">The sequence Number</param>
 private void VerifyTunnelDataPdu_BWResult(RDP_BW_RESULTS BwResult, ushort sequenceNumber)
 {
     if (BwResult == null)
     {
         Site.Assert.Fail("Not get Bandwidth Measure Result");
     }
     if (BwResult.sequenceNumber != sequenceNumber)
     {
         Site.Assert.Fail("Expect sequence Number is {0}, but receive sequence Number: {1}", sequenceNumber, BwResult.sequenceNumber);
     }
 }
 /// <summary>
 /// Parse Network Detection Response Structures
 /// </summary>
 /// <param name="data"></param>
 /// <param name="currentIndex"></param>
 /// <returns>A specific Network Detection Response Structure</returns>
 public NETWORK_DETECTION_RESPONSE ParseNetworkDetectionResponse(byte[] data, ref int currentIndex, bool isSubHeader = false)
 {
     byte headerLength = (byte)data.Length;
     HeaderTypeId_Values headerTypeId = HeaderTypeId_Values.TYPE_ID_AUTODETECT_RESPONSE;
     if (isSubHeader)
     {
         headerLength += 2;
     }
     else
     {
         headerLength = ParseByte(data, ref currentIndex);
         headerTypeId = (HeaderTypeId_Values)ParseByte(data, ref currentIndex);
     }
     ushort sequenceNumber = ParseUInt16(data, ref currentIndex, false);
     AUTO_DETECT_RESPONSE_TYPE responseType = (AUTO_DETECT_RESPONSE_TYPE)ParseUInt16(data, ref currentIndex, false);
     if (responseType == AUTO_DETECT_RESPONSE_TYPE.RDP_RTT_RESPONSE)
     {
         RDP_RTT_RESPONSE rttResp = new RDP_RTT_RESPONSE();
         rttResp.headerLength = headerLength;
         rttResp.headerTypeId = headerTypeId;
         rttResp.sequenceNumber = sequenceNumber;
         rttResp.responseType = responseType;
         return rttResp;
     }
     else if (responseType == AUTO_DETECT_RESPONSE_TYPE.RDP_BW_RESULTS_AFTER_CONNECT || responseType == AUTO_DETECT_RESPONSE_TYPE.RDP_BW_RESULTS_DURING_CONNECT)
     {
         RDP_BW_RESULTS bwResults = new RDP_BW_RESULTS();
         bwResults.headerLength = headerLength;
         bwResults.headerTypeId = headerTypeId;
         bwResults.sequenceNumber = sequenceNumber;
         bwResults.responseType = responseType;
         bwResults.timeDelta = ParseUInt32(data, ref currentIndex, false);
         bwResults.byteCount = ParseUInt32(data, ref currentIndex, false);
         return bwResults;
     }
     else if (responseType == AUTO_DETECT_RESPONSE_TYPE.RDP_NETCHAR_SYNC)
     {
         RDP_NETCHAR_SYNC netCharSync = new RDP_NETCHAR_SYNC();
         netCharSync.headerLength = headerLength;
         netCharSync.headerTypeId = headerTypeId;
         netCharSync.sequenceNumber = sequenceNumber;
         netCharSync.responseType = responseType;
         netCharSync.bandwidth = ParseUInt32(data, ref currentIndex, false);
         netCharSync.rtt = ParseUInt32(data, ref currentIndex, false);
         return netCharSync;
     }
     else
     {
         throw new FormatException(ConstValue.ERROR_MESSAGE_ENUM_UNRECOGNIZED);
     }
 }
        public override NETWORK_DETECTION_RESPONSE Clone()
        {
            RDP_BW_RESULTS bwResults = new RDP_BW_RESULTS();
            bwResults.headerLength = this.headerLength;
            bwResults.headerTypeId = this.headerTypeId;
            bwResults.sequenceNumber = this.sequenceNumber;
            bwResults.responseType = this.responseType;

            bwResults.timeDelta = this.timeDelta;
            bwResults.byteCount = this.byteCount;

            return bwResults;
        }
        /// <summary>
        /// Parse RDP_BW_RESULTS structure from RDPEMT subheader
        /// </summary>
        /// <param name="data">Data of subheader, not include first two bytes of Parse RDP_BW_RESULTS</param>
        /// <returns></returns>
        public static RDP_BW_RESULTS ParseRdpBWResults(byte[] data)
        {
            RDP_BW_RESULTS bwRes = new RDP_BW_RESULTS();
            bwRes.sequenceNumber = ParseUInt16(data, 0);
            bwRes.responseType = (AUTO_DETECT_RESPONSE_TYPE)ParseUInt16(data, 2);
            int index = 4;
            bwRes.timeDelta = ParseUInt32(data, index);
            index += 4;
            bwRes.byteCount = ParseUInt32(data, index);
            index += 4;

            return bwRes;
        }