|
I have a strange (imo) requirement for a client:
I need to read pcap files and write the packets into a database (specifically a mongo collection).
The Packet type is not serializable so (obviously) there is no easy way to do this and I thought it was worth the time to ask if anyone else has done something similar?
What I am doing now is populating a simple DTO class from a Packet data:
public class DTO
{
public Byte[] Data { get; set; }
public DateTime TimeStamp { get; set; }
public DataLinkKind DataLink { get; set; }
}
like so:
DTO dto = new DTO()
{
Data = packet.Buffer,
TimeStamp = packet.Timestamp,
DataLink = packet.DataLink.Kind
};
I am not an expert with this particular domain (pcap) but the DTO allows me to serialize to disk w/o a non trivial amount of custom serializaton logic and later reconstitute via this code:
Packet testPacket = new Packet(dto.Data, dto.TimeStamp, dto.DataLink);
Doing this seems to work as:
Boolean result = packet.Equals(testPacket);
evaluates to true for my tests...
My primary concern at this point is if I am losing any data?
Thank you for your valuable time.
Chris
|