Skip to content

Commit

Permalink
use the correct time units for the enhanced packet blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
compscidr committed Sep 23, 2024
1 parent 55f185d commit 050bc58
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 050bc58

Please sign in to comment.