my $fParse = "$dirCapture"."r.pcap"; # open an existing pcap file to analyze my $pktParse = Net::Frame::Dump::Offline->new(file => $fParse, keepTimestamp => 1); $pktParse->start; my $count = 0; while (my $h = $pktParse->next) { # get each packet in the file my $frmSimple = Net::Frame::Simple->new( raw => $h->{raw}, firstLayer => $h->{firstLayer}, timestamp => $h->{timestamp}, ); my $len = length($h->{raw}); #-----------> until here $len is correct # write this packet to pcap file my $w = Net::Frame::Dump::Writer->new( file => "$dirMerge"."rrr.pcap", firstLayer => 'ETH', overwrite => 1); $w->start; $w->write({ timestamp => $h->{'timestamp'}, raw => $h->{'raw'} }); # --------> but after here, packet length in new writing file is not correct, it's only 1500 bytes, while the correct one is 1514 $w->stop; $count++; } $pktParse->stop;