/// <summary cref="Packet.ToString(StringOutputType)" />
        public override string ToString(StringOutputType outputFormat)
        {
            var    buffer      = new StringBuilder();
            string color       = "";
            string colorEscape = "";

            if (outputFormat == StringOutputType.Colored || outputFormat == StringOutputType.VerboseColored)
            {
                color       = Color;
                colorEscape = AnsiEscapeSequences.Reset;
            }

            if (outputFormat == StringOutputType.Normal || outputFormat == StringOutputType.Colored)
            {
                // build the output string
                buffer.AppendFormat("{0}[IGMPv2Packet: Type={2}, MaxResponseTime={3}, GroupAddress={4}]{1}",
                                    color,
                                    colorEscape,
                                    Type,
                                    String.Format("{0:0.0}", (MaxResponseTime / 10)),
                                    GroupAddress);
            }

            if (outputFormat == StringOutputType.Verbose || outputFormat == StringOutputType.VerboseColored)
            {
                // collect the properties and their value
                Dictionary <string, string> properties = new Dictionary <string, string>();
                properties.Add("type", Type + " (0x" + Type.ToString("x") + ")");
                properties.Add("max response time", String.Format("{0:0.0}", MaxResponseTime / 10) + " sec (0x" + MaxResponseTime.ToString("x") + ")");
                // TODO: Implement checksum validation for IGMPv2
                properties.Add("header checksum", "0x" + Checksum.ToString("x"));
                properties.Add("group address", GroupAddress.ToString());

                // calculate the padding needed to right-justify the property names
                int padLength = Utils.RandomUtils.LongestStringLength(new List <string>(properties.Keys));

                // build the output string
                buffer.AppendLine("IGMP:  ******* IGMPv2 - \"Internet Group Management Protocol (Version 2)\" - offset=? length=" + TotalPacketLength);
                buffer.AppendLine("IGMP:");
                foreach (var property in properties)
                {
                    buffer.AppendLine("IGMP: " + property.Key.PadLeft(padLength) + " = " + property.Value);
                }
                buffer.AppendLine("IGMP:");
            }

            // append the base string output
            buffer.Append(base.ToString(outputFormat));

            return(buffer.ToString());
        }
        public override void Snapshot(string id, System.Xml.XmlTextWriter writer)
        {
            writer.WriteStartElement(id + "_Statistics");
            writer.WriteAttributeString("ID", ID.ToString());
            writer.WriteAttributeString("ReceivedRequestCount", ReceivedRequestCount.ToString());
            writer.WriteAttributeString("ReceivedReadRequestCount", ReceivedReadRequestCount.ToString());
            writer.WriteAttributeString("ReceivedWriteRequestCount", ReceivedWriteRequestCount.ToString());
            writer.WriteAttributeString("HandledRequestsCount", HandledRequestsCount.ToString());
            writer.WriteAttributeString("HandledReadRequestsCount", HandledReadRequestsCount.ToString());
            writer.WriteAttributeString("HandledWriteRequestsCount", HandledWriteRequestsCount.ToString());
            writer.WriteAttributeString("AvgResponseTime_us", AvgResponseTime.ToString());
            writer.WriteAttributeString("MinResponseTime_us", MinResponseTime.ToString());
            writer.WriteAttributeString("MaxResponseTime_us", MaxResponseTime.ToString());
            writer.WriteAttributeString("AvgResponseTimeRead_us", AvgResponseTimeR.ToString());
            writer.WriteAttributeString("MinResponseTimeRead_us", MinResponseTimeR.ToString());
            writer.WriteAttributeString("MaxResponseTimeRead_us", MaxResponseTimeR.ToString());
            writer.WriteAttributeString("AvgResponseTimeWrite_us", AvgResponseTimeW.ToString());
            writer.WriteAttributeString("MinResponseTimeWrite_us", MinResponseTimeW.ToString());
            writer.WriteAttributeString("MaxResponseTimeWrite_us", MaxResponseTimeW.ToString());

            writer.WriteAttributeString("AverageCMDLifeTime_ms", AverageCMDLifeTime.ToString());
            writer.WriteAttributeString("AverageCMDExecutionTime_ms", AverageCMDExecutionTime.ToString());
            writer.WriteAttributeString("AverageCMDTransferTime_ms", AverageCMDTransferTime.ToString());
            writer.WriteAttributeString("AverageCMDWaitingTime_ms", AverageCMDWaitingTime.ToString());

            writer.WriteAttributeString("AverageReadCMDLifeTime_ms", AverageReadCMDLifeTime.ToString());
            writer.WriteAttributeString("AverageReadCMDExecutionTime_ms", AverageReadCMDExecutionTime.ToString());
            writer.WriteAttributeString("AverageReadCMDTransferTime_ms", AverageReadCMDTransferTime.ToString());
            writer.WriteAttributeString("AverageReadCMDWaitingTime_ms", AverageReadCMDWaitingTime.ToString());

            writer.WriteAttributeString("AverageProgramCMDLifeTime_ms", AverageProgramCMDLifeTime.ToString());
            writer.WriteAttributeString("AverageProgramCMDExecutionTime_ms", AverageProgramCMDExecutionTime.ToString());
            writer.WriteAttributeString("AverageProgramCMDTransferTime_ms", AverageProgramCMDTransferTime.ToString());
            writer.WriteAttributeString("AverageProgramCMDWaitingTime_ms", AverageProgramCMDWaitingTime.ToString());

            writer.WriteAttributeString("IOPS", IOPS.ToString());
            writer.WriteAttributeString("IOPSRead", IOPSReads.ToString());
            writer.WriteAttributeString("IOPSWrite", IOPSWrites.ToString());
            writer.WriteAttributeString("AggregateBandWidth_MB", AggregateBandWidth.ToString());
            writer.WriteAttributeString("AggregateBandWidthRead_MB", AggregateBandWidthReads.ToString());
            writer.WriteAttributeString("AggregateBandWidthWrites_MB", AggregateBandWidthWrites.ToString());
            writer.WriteEndElement();


            writer.WriteStartElement(id + "_Statistics_AfterGCStart");
            writer.WriteAttributeString("ID", ID.ToString());
            writer.WriteAttributeString("HandledRequestsCount", HandledRequestsCount_AGC.ToString());
            writer.WriteAttributeString("HandledReadRequestsCount", HandledReadRequestsCount_AGC.ToString());
            writer.WriteAttributeString("HandledWriteRequestsCount", HandledWriteRequestsCount_AGC.ToString());
            writer.WriteAttributeString("AvgResponseTime_us", AvgResponseTime_AGC.ToString());
            writer.WriteAttributeString("MinResponseTime_us", MinResponseTime_AGC.ToString());
            writer.WriteAttributeString("MaxResponseTime_us", MaxResponseTime_AGC.ToString());
            writer.WriteAttributeString("AvgResponseTimeRead_us", AvgResponseTimeR_AGC.ToString());
            writer.WriteAttributeString("MinResponseTimeRead_us", MinResponseTimeR_AGC.ToString());
            writer.WriteAttributeString("MaxResponseTimeRead_us", MaxResponseTimeR_AGC.ToString());
            writer.WriteAttributeString("AvgResponseTimeWrite_us", AvgResponseTimeW_AGC.ToString());
            writer.WriteAttributeString("MinResponseTimeWrite_us", MinResponseTimeW_AGC.ToString());
            writer.WriteAttributeString("MaxResponseTimeWrite_us", MaxResponseTimeW_AGC.ToString());

            writer.WriteAttributeString("AverageCMDLifeTime_ms", AverageCMDLifeTime_AGC.ToString());
            writer.WriteAttributeString("AverageCMDExecutionTime_ms", AverageCMDExecutionTime_AGC.ToString());
            writer.WriteAttributeString("AverageCMDTransferTime_ms", AverageCMDTransferTime_AGC.ToString());
            writer.WriteAttributeString("AverageCMDWaitingTime_ms", AverageCMDWaitingTime_AGC.ToString());

            writer.WriteAttributeString("AverageReadCMDLifeTime_ms", AverageReadCMDLifeTime_AGC.ToString());
            writer.WriteAttributeString("AverageReadCMDExecutionTime_ms", AverageReadCMDExecutionTime_AGC.ToString());
            writer.WriteAttributeString("AverageReadCMDTransferTime_ms", AverageReadCMDTransferTime_AGC.ToString());
            writer.WriteAttributeString("AverageReadCMDWaitingTime_ms", AverageReadCMDWaitingTime_AGC.ToString());

            writer.WriteAttributeString("AverageProgramCMDLifeTime_ms", AverageProgramCMDLifeTime_AGC.ToString());
            writer.WriteAttributeString("AverageProgramCMDExecutionTime_ms", AverageProgramCMDExecutionTime_AGC.ToString());
            writer.WriteAttributeString("AverageProgramCMDTransferTime_ms", AverageProgramCMDTransferTime_AGC.ToString());
            writer.WriteAttributeString("AverageProgramCMDWaitingTime_ms", AverageProgramCMDWaitingTime_AGC.ToString());

            writer.WriteAttributeString("IOPS", IOPS_AGC.ToString());
            writer.WriteAttributeString("IOPSRead", IOPSReads_AGC.ToString());
            writer.WriteAttributeString("IOPSWrite", IOPSWrites_AGC.ToString());
            writer.WriteAttributeString("AggregateBandWidth_MB", AggregateBandWidth_AGC.ToString());
            writer.WriteAttributeString("AggregateBandWidthRead_MB", AggregateBandWidthReads_AGC.ToString());
            writer.WriteAttributeString("AggregateBandWidthWrites_MB", AggregateBandWidthWrites_AGC.ToString());
            writer.WriteEndElement();

            writer.WriteStartElement(id + "_Statistics" + "_BeforeGCStart");
            writer.WriteAttributeString("ID", ID.ToString());
            writer.WriteAttributeString("HandledRequestsCount", HandledRequestsCount_BGC.ToString());
            writer.WriteAttributeString("HandledReadRequestsCount", HandledReadRequestsCount_BGC.ToString());
            writer.WriteAttributeString("HandledWriteRequestsCount", HandledWriteRequestsCount_BGC.ToString());
            writer.WriteAttributeString("AvgResponseTime_us", AvgResponseTime_BGC.ToString());
            writer.WriteAttributeString("MinResponseTime_us", MinResponseTime_BGC.ToString());
            writer.WriteAttributeString("MaxResponseTime_us", MaxResponseTime_BGC.ToString());
            writer.WriteAttributeString("AvgResponseTimeRead_us", AvgResponseTimeR_BGC.ToString());
            writer.WriteAttributeString("MinResponseTimeRead_us", MinResponseTimeR_BGC.ToString());
            writer.WriteAttributeString("MaxResponseTimeRead_us", MaxResponseTimeR_BGC.ToString());
            writer.WriteAttributeString("AvgResponseTimeWrite_us", AvgResponseTimeW_BGC.ToString());
            writer.WriteAttributeString("MinResponseTimeWrite_us", MinResponseTimeW_BGC.ToString());
            writer.WriteAttributeString("MaxResponseTimeWrite_us", MaxResponseTimeW_BGC.ToString());

            writer.WriteAttributeString("AverageCMDLifeTime_ms", AverageCMDLifeTime_BGC.ToString());
            writer.WriteAttributeString("AverageCMDExecutionTime_ms", AverageCMDExecutionTime_BGC.ToString());
            writer.WriteAttributeString("AverageCMDTransferTime_ms", AverageCMDTransferTime_BGC.ToString());
            writer.WriteAttributeString("AverageCMDWaitingTime_ms", AverageCMDWaitingTime_BGC.ToString());
            writer.WriteAttributeString("AverageReadCMDLifeTime_ms", AverageReadCMDLifeTime_BGC.ToString());
            writer.WriteAttributeString("AverageReadCMDExecutionTime_ms", AverageReadCMDExecutionTime_BGC.ToString());
            writer.WriteAttributeString("AverageReadCMDTransferTime_ms", AverageReadCMDTransferTime_BGC.ToString());
            writer.WriteAttributeString("AverageReadCMDWaitingTime_ms", AverageReadCMDWaitingTime_BGC.ToString());
            writer.WriteAttributeString("AverageProgramCMDLifeTime_ms", AverageProgramCMDLifeTime_BGC.ToString());
            writer.WriteAttributeString("AverageProgramCMDExecutionTime_ms", AverageProgramCMDExecutionTime_BGC.ToString());
            writer.WriteAttributeString("AverageProgramCMDTransferTime_ms", AverageProgramCMDTransferTime_BGC.ToString());
            writer.WriteAttributeString("AverageProgramCMDWaitingTime_ms", AverageProgramCMDWaitingTime_BGC.ToString());

            writer.WriteAttributeString("IOPS", IOPS_BGC.ToString());
            writer.WriteAttributeString("IOPSRead", IOPSReads_BGC.ToString());
            writer.WriteAttributeString("IOPSWrite", IOPSWrites_BGC.ToString());
            writer.WriteAttributeString("AggregateBandWidth_MB", AggregateBandWidth_BGC.ToString());
            writer.WriteAttributeString("AggregateBandWidthRead_MB", AggregateBandWidthReads_BGC.ToString());
            writer.WriteAttributeString("AggregateBandWidthWrites_MB", AggregateBandWidthWrites_BGC.ToString());
            writer.WriteEndElement();


            if (RTLoggingEnabled)
            {
                RTLogFile.Close();
                RTLogFileR.Close();
                RTLogFileW.Close();
            }
        }