Beispiel #1
0
/*
 *      /// <summary>
 *      /// Generate next frame offset via equation = offset + 16B + included frame length, this variant includes binary reading operation
 *      /// </summary>
 *      /// <param name="offset">Starting offset of target frame in TCPD PCAP file</param>
 *      /// <returns></returns>
 *      private UInt32 CountTCPDNextFrameOffset(UInt32 offset)
 *      {
 *          return offset + 16 + GetTCPDPckIncludedLength(offset);
 *      }
 */

        /// <summary>
        ///     Parses frame table of TCPD PCAP file and more importantly it initialize TCPFrameTable variable where are stored all
        ///     frame offsets
        /// </summary>
        private async Task ParseTcpdFrameTable()
        {
            if (!PmSupportedTypes.IsSupportedLinkType(this._pmLinkType))
            {
                return;
            }

            //sfs.RealFrames.Clear();
            /* First frame starts always on 24th byte of TCPD PCAP file. Just after Globap CaptureProcessor Header */
            //sfs.TCPDFrameTable = new List<uint> {24};
            Int64 last     = 24;
            var   velikost = this.BinReader.BaseStream.Length;
            Int64 index    = 0;

            do
            {
                var len = this.GetTcpdPckIncludedLength(last);
                await this.PmMetaFramesBufferBlock.SendAsync(new PmFramePcap(this.PmCapture, index, last, this._pmLinkType,
                                                                             ConvertUnixTimeToDate(ConvertTcpdToUnixTime((int)(this.GetTcpdPckTimestampSeconds(last) + this._tcpdTimeZoneOffset),
                                                                                                                         (int)this.GetTcpdPckTimestampUseconds(last))), this.GetTcpdPckOriginalLength(last), len));

                last = this.CountTcpdNextFrameOffset(last, len);
                index++;
            } while(last != velikost);

            /* Remove last record because it is unparsable EOF */
            //sfs.TCPDFrameTable.Remove(sfs.TCPDFrameTable.Last());
            //PrintError(sfs.TCPDFrameTable.Count.ToString());
            //PrintError("xxx"+sfs.RealFrames.Count.ToString());
        }
Beispiel #2
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="linkLayer"></param>
 /// <param name="packetData"></param>
 public PmPacket(PmLinkType linkLayer, Byte[] packetData)
 {
     this.PacketInfo = Packet.ParsePacket(PmSupportedTypes.ConvertLinkTypeToPacketdotNet(linkLayer), packetData);
     this.UpdateCalculatedOffsets();
 }