private PcapRecord GetNext() { long ticks; int sec, usec; PcapRecord record; pcap_record.ts_sec = reader.ReadUInt32(); pcap_record.ts_usec = reader.ReadUInt32(); pcap_record.incl_len = reader.ReadUInt32(); pcap_record.orig_len = reader.ReadUInt32(); pcap_record.buffer = reader.ReadBytes((int)pcap_record.incl_len); sec = (int)pcap_record.ts_sec; usec = (int)pcap_record.ts_usec; if (seconds_offset < 0) { seconds_offset = sec; } sec -= seconds_offset; ticks = sec * TimeSpan.TicksPerSecond; ticks += (usec / 1000) * TimeSpan.TicksPerMillisecond; record = new PcapRecord(pcap_record.buffer, new TimeSpan(ticks)); return(record); }
private PcapRecord GetNext() { long ticks; int sec, usec; PcapRecord record; pcap_record.ts_sec = reader.ReadUInt32(); pcap_record.ts_usec = reader.ReadUInt32(); pcap_record.incl_len = reader.ReadUInt32(); pcap_record.orig_len = reader.ReadUInt32(); pcap_record.buffer = reader.ReadBytes((int) pcap_record.incl_len); sec = (int) pcap_record.ts_sec; usec = (int) pcap_record.ts_usec; if (seconds_offset < 0) seconds_offset = sec; sec -= seconds_offset; ticks = sec * TimeSpan.TicksPerSecond; ticks += (usec / 1000) * TimeSpan.TicksPerMillisecond; record = new PcapRecord(pcap_record.buffer, new TimeSpan(ticks)); return record; }
public void AddRecord(PcapRecord pcapRecord) { TimeSpan timeSpan = pcapRecord.Time; UInt32 ticks = (UInt32)timeSpan.Ticks; UInt32 ticksPerSecond = (UInt32)TimeSpan.TicksPerSecond; UInt32 ticksPerMilisecond = (UInt32)TimeSpan.TicksPerMillisecond; pcap_record.ts_sec = ticks / ticksPerSecond; pcap_record.ts_usec = (ticks % ticksPerSecond) * (1000 / ticksPerMilisecond); pcap_record.incl_len = (UInt32)pcapRecord.Length; pcap_record.orig_len = (UInt32)pcapRecord.Length; pcap_record.buffer = pcapRecord.Buffer; WriteRecord(pcap_record); }