diff --git a/packetdumper/src/main/kotlin/com/jasonernst/packetdumper/filedumper/PcapNgFilePacketDumper.kt b/packetdumper/src/main/kotlin/com/jasonernst/packetdumper/filedumper/PcapNgFilePacketDumper.kt index 3a92688..c2dd7e9 100644 --- a/packetdumper/src/main/kotlin/com/jasonernst/packetdumper/filedumper/PcapNgFilePacketDumper.kt +++ b/packetdumper/src/main/kotlin/com/jasonernst/packetdumper/filedumper/PcapNgFilePacketDumper.kt @@ -65,7 +65,9 @@ class PcapNgFilePacketDumper( outputStreamWriter.write(packetBlock.toBytes()) outputStreamWriter.flush() } else { - val timestamp = System.currentTimeMillis() + // convert the nano time to microseconds since that is the default if we don't set + // the if_tsresol in the interface description block + val timestamp = System.nanoTime() / 1000 val packetBlock = PcapNgEnhancedPacketBlock(conversionBuffer.array(), timestamp = timestamp) outputStreamWriter.write(packetBlock.toBytes()) outputStreamWriter.flush() diff --git a/packetdumper/src/main/kotlin/com/jasonernst/packetdumper/serverdumper/PcapNgTcpServerPacketDumper.kt b/packetdumper/src/main/kotlin/com/jasonernst/packetdumper/serverdumper/PcapNgTcpServerPacketDumper.kt index 64caa78..2d61871 100644 --- a/packetdumper/src/main/kotlin/com/jasonernst/packetdumper/serverdumper/PcapNgTcpServerPacketDumper.kt +++ b/packetdumper/src/main/kotlin/com/jasonernst/packetdumper/serverdumper/PcapNgTcpServerPacketDumper.kt @@ -146,7 +146,9 @@ class PcapNgTcpServerPacketDumper( if (isSimple) { PcapNgSimplePacketBlock(conversionBuffer.array()) } else { - val timestamp = System.currentTimeMillis() + // convert the nano time to microseconds since that is the default if we don't set + // the if_tsresol in the interface description block + val timestamp = System.nanoTime() / 1000 PcapNgEnhancedPacketBlock(conversionBuffer.array(), timestamp = timestamp) } buffer.position(startingPosition)