This repository has been archived by the owner on Jun 12, 2021. It is now read-only.
forked from IETF-OPSAWG-WG/draft-ietf-opsawg-pcap
-
Notifications
You must be signed in to change notification settings - Fork 4
/
draft-tuexen-opsawg-pcapng.xml
3124 lines (2521 loc) · 140 KB
/
draft-tuexen-opsawg-pcapng.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd"[]>
<?rfc symrefs='yes' ?>
<?rfc toc='yes' ?>
<?rfc compact='yes' ?>
<?rfc subcompact='no' ?>
<?rfc inline='yes' ?>
<?rfc sortrefs='no' ?>
<?rfc strict='yes' ?>
<rfc category='info'
ipr='trust200902'
docName="draft-tuexen-opsawg-pcapng-02">
<front>
<title abbrev="pcapng">PCAP Next Generation (pcapng) Capture File Format</title>
<author initials='M.' surname='Tuexen' fullname='Michael Tuexen' role='editor'>
<organization abbrev='Muenster Univ. of Appl. Sciences'>
Muenster University of Applied Sciences</organization>
<address>
<postal>
<street>Stegerwaldstrasse 39</street>
<code>48565</code>
<city>Steinfurt</city>
<country>DE</country>
</postal>
<email>tuexen@fh-muenster.de</email>
</address>
</author>
<author initials="F." surname="Risso" fullname="Fulvio Risso">
<organization>Politecnico di Torino</organization>
<address>
<postal>
<street>Corso Duca degli Abruzzi, 24</street>
<city>Torino</city>
<code>10129</code>
<country>IT</country>
</postal>
<email>fulvio.risso@polito.it</email>
</address>
</author>
<author initials='J.' surname='Bongertz' fullname='Jasper Bongertz'>
<organization abbrev='Airbus DS CyberSecurity'>Airbus Defence and Space CyberSecurity</organization>
<address>
<postal>
<street>Kanzlei 63c</street>
<code>40667</code>
<city>Meerbusch</city>
<country>DE</country>
</postal>
<email>jasper@packet-foo.com</email>
</address>
</author>
<author initials='G.' surname='Combs' fullname='Gerald Combs'>
<organization abbrev='Wireshark'>
Wireshark Foundation</organization>
<address>
<postal>
<street>339 Madson Pl</street>
<city>Davis</city>
<region>CA</region>
<code>95618</code>
<country>US</country>
</postal>
<email>gerald@wireshark.org</email>
</address>
</author>
<author initials='G.' surname='Harris' fullname='Guy Harris'>
<address>
<email>gharris@sonic.net</email>
</address>
</author>
<author initials='E.' surname='Chaudron' fullname='Eelco Chaudron'>
<organization abbrev='Red Hat'>Red Hat</organization>
<address>
<postal>
<street>De Entree 238</street>
<code>1101 EE</code>
<city>Amsterdam</city>
<country>NL</country>
</postal>
<email>eelco@redhat.com</email>
</address>
</author>
<author fullname="Michael C. Richardson" initials="M."
surname="Richardson">
<organization abbrev="Sandelman">Sandelman Software Works</organization>
<address>
<email>mcr+ietf@sandelman.ca</email>
<uri>http://www.sandelman.ca/</uri>
</address>
</author>
<date />
<abstract>
<t>This document describes a format to record captured packets to a
file. This format is extensible; Wireshark can currently read and write
it, and libpcap can currently read some pcapng files.</t>
</abstract>
</front>
<!--===========================================================================
MAIN BODY - still within the <rfc> tag
============================================================================-->
<middle>
<section title="Introduction">
<t>The problem of exchanging packet traces becomes more and more
critical every day; unfortunately, no standard solutions exist for
this task right now. One of the most accepted packet interchange
formats is the one defined by libpcap, which is rather old and is
lacking in functionality for more modern applications particularly
from the extensibility point of view.</t>
<t>This document proposes a new format for recording packet traces. The
following goals are being pursued:
<list style='hanging'>
<t hangText='Extensibility:'>
It should be possible to add new standard capabilities to the file
format over time, and third parties should be able to enrich the
information embedded in the file with proprietary extensions, with
tools unaware of newer extensions being able to ignore them.</t>
<t hangText='Portability:'>
A capture trace must contain all the information needed to read data
independently from network, hardware and operating system of the
machine that made the capture.</t>
<t hangText='Merge/Append data:'>
It should be possible to add data at the end of a given file, and
the resulting file must still be readable.</t>
</list>
</t>
</section>
<section title='Terminology'>
<t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in <xref
target='RFC2119'/>.</t>
<section title="Acronyms">
<t>The following acronyms are used throughout this document:
<list style='hanging'>
<t hangText='SHB:'>Section Header Block</t>
<t hangText='IDB:'>Interface Description Block</t>
<t hangText='ISB:'>Interface Statistics Block</t>
<t hangText='EPB:'>Enhanced Packet Block</t>
<t hangText='SPB:'>Simple Packet Block</t>
<t hangText='NRB:'>Name Resolution Block</t>
<t hangText='CB:'>Custom Block</t>
</list>
</t>
</section>
</section>
<section title="General File Structure">
<section anchor="section_block" title="General Block Structure">
<t>A capture file is organized in blocks, that are appended one to
another to form the file. All the blocks share a common format, which
is shown in <xref target="formatblock"/>.</t>
<figure anchor="formatblock" title="Basic block structure." align="center">
<artwork xml:space="preserve" name="" type="" align="center" alt="" width="" height="">
1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 | Block Type |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
4 | Block Total Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
8 / Block Body /
/ variable length, padded to 32 bits /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Block Total Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
</artwork>
</figure>
<t>The fields have the following meaning:
<list style="symbols">
<t>Block Type (32 bits): a unique unsigned value that
identifies the block. Values whose Most Significant Bit
(MSB) is equal to 1 are reserved for local use. They can be
used to make extensions to the file format to save private
data to the file. The list of currently defined types can
be found in <xref target="section_block_code_registry"/>.</t>
<t>Block Total Length (32 bits): an unsigned value giving
the total size of this block, in octets. For instance, the
length of a block that does not have a body is 12 octets: 4
octets for the Block Type, 4 octets for the initial Block
Total Length and 4 octets for the trailing Block Total
Length. This value MUST be a multiple of 4.</t>
<t>Block Body: content of the block.</t>
<t>Block Total Length: total size of this block, in octets. This
field is duplicated to permit backward file navigation.</t>
</list>
</t>
<t>This structure, shared among all blocks, makes it easy to process a
file and to skip unneeded or unknown blocks. Some blocks can contain
other blocks inside (nested blocks). Some of the blocks are mandatory,
i.e. a capture file is not valid if they are not present, other are
optional.</t>
<t>The General Block Structure allows defining other blocks if needed.
A parser that does not understand them can simply ignore their
content.</t>
</section>
<section title="Block Types">
<t>The currently standardized Block Type codes are specified in <xref
target="section_block_code_registry"/>; they have been grouped in the
following four categories:</t>
<t>The following MANDATORY block MUST appear at least once in each file:
<list style="symbols">
<t><xref target="section_shb">Section Header
Block</xref>: it defines the most important characteristics of the
capture file.</t>
</list>
</t>
<t>The following OPTIONAL blocks MAY appear in a file:
<list style="symbols">
<t><xref target="section_idb">Interface Description Block</xref>:
it defines the most important characteristics of the interface(s)
used for capturing traffic. This block is required in certain
cases, as described later.</t>
<t><xref target="section_epb">Enhanced Packet Block</xref>: it
contains a single captured packet, or a portion of it. It
represents an evolution of the original, now obsolete, <xref
target="appendix_pb" >Packet Block</xref>. If this appears in a
file, an Interface Description Block is also required, before this
block.</t>
<t><xref target="section_spb">Simple Packet Block</xref>: it
contains a single captured packet, or a portion of it, with only a
minimal set of information about it. If this appears in a file, an
Interface Description Block is also required, before this
block.</t>
<t><xref target="section_nrb" >Name Resolution Block</xref>: it
defines the mapping from numeric addresses present in the packet
capture and the canonical name counterpart.</t>
<t><xref target="section_isb">Interface Statistics Block</xref>: it
defines how to store some statistical data (e.g. packet dropped,
etc) which can be useful to understand the conditions in which the
capture has been made. If this appears in a file, an Interface
Description Block is also required, before this block.</t>
<t><xref target="section_custom_block">Custom Block</xref>: it
contains vendor-specific data in a portable fashion.</t>
</list>
</t>
<t>The following OBSOLETE block SHOULD NOT appear in newly written
files (but is documented in the Appendix for reference):
<list style="symbols">
<t><xref target="appendix_pb">Packet Block</xref>: it contains a
single captured packet, or a portion of it. It is OBSOLETE, and
superseded by the <xref target="section_epb">Enhanced Packet
Block</xref>.</t>
</list>
</t>
<t>The following EXPERIMENTAL blocks are considered interesting but
the authors believe that they deserve more in-depth discussion before
being defined:
<list style="symbols">
<t>Alternative Packet Blocks</t>
<t>Compression Block</t>
<t>Encryption Block</t>
<t>Fixed Length Block</t>
<t>Directory Block</t>
<t>Traffic Statistics and Monitoring Blocks</t>
<t>Event/Security Blocks</t>
</list>
</t>
<t>Requests for new standardized Block Type codes should be sent
to the <eref
target="https://www.winpcap.org/mailman/listinfo/pcap-ng-format">pcap-ng-format mailing list</eref>.</t>
</section>
<section title="Logical Block Hierarchy">
<t>The blocks build a logical hierarchy as they refer to each other.
<xref target="block-hierarchy"/> shows the logical hierarchy of the
currently defined blocks in the form of a "tree view":</t>
<figure anchor="block-hierarchy" title="Logical Block Hierarchy of a pcapng File">
<artwork xml:space="preserve" name="" type="" align="left" alt="" width="" height="">
Section Header
|
+- Interface Description
| +- Simple Packet
| +- Enhanced Packet
| +- Interface Statistics
|
+- Name Resolution
</artwork>
</figure>
<t>For example: each captured packet refers to a specific capture
interface, the interface itself refers to a specific section.</t>
</section>
<section title="Physical File Layout">
<t>The file MUST begin with a Section Header Block. However, more than
one Section Header Block can be present in the capture file, each one
covering the data following it until the next one (or the end of
file). A Section includes the data delimited by two Section Header
Blocks (or by a Section Header Block and the end of the file),
including the first Section Header Block.</t>
<t>In case an application cannot read a Section because of different
version number, it MUST skip everything until the next Section Header
Block. Note that, in order to properly skip the blocks until the next
section, all blocks MUST have the fields Type and Length at the
beginning. In order to properly skip blocks in the backward direction,
all blocks MUST have the Length repeated at the end of the block.
These are mandatory requirements that MUST be maintained in future
versions of the block format.</t>
<t><xref target="fssample-SHB"/> shows a typical file layout, with a
single Section Header that covers the whole file.</t>
<figure anchor="fssample-SHB" title="File structure example: Typical layout with a single Section Header Block">
<artwork xml:space="preserve" name="" type="" align="left" alt="" width="" height="">
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| SHB v1.0 | Data |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
</artwork>
</figure>
<t><xref target="fssample-SHB3"/>
shows a file that contains three headers, and is normally the result
of file concatenation. An application that understands only version
1.0 of the file format skips the intermediate section and restart
processing the packets after the third Section Header.</t>
<figure anchor="fssample-SHB3" title="File structure example: three Section Header Blocks in a single file">
<artwork xml:space="preserve" name="" type="" align="left" alt="" width="" height="">
|-- 1st Section --|-- 2nd Section --|-- 3rd Section --|
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| SHB v1.0 | Data | SHB V1.1 | Data | SHB V1.0 | Data |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
</artwork>
</figure>
<t><xref target="fssample-minimum"/>
shows a file comparable to a "classic libpcap" file - the minimum for
a useful capture file. It contains a single Section Header Block
(SHB), a single Interface Description Block (IDB) and a few Enhanced
Packet Blocks (EPB).</t>
<figure anchor="fssample-minimum" title="File structure example: a pcapng file similar to a classical libpcap file">
<artwork xml:space="preserve" name="" type="" align="left" alt="" width="" height="">
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| SHB | IDB | EPB | EPB | ... | EPB |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
</artwork>
</figure>
<t><xref target="fssample-full"/>
shows a complex example file. In addition to the minimum file above,
it contains packets captured from three interfaces, capturing on the
third of which begins after packets have arrived on other interfaces,
and also includes some Name Resolution Blocks (NRB) and an Interface
Statistics Block (ISB).</t>
<figure anchor="fssample-full" title="File structure example: complex pcapng file">
<artwork xml:space="preserve" name="" type="" align="left" alt="" width="" height="">
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| SHB | IDB | IDB | EPB | NRB |...| IDB | EPB | ISB | NRB | EPB |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
</artwork>
</figure>
<t>The last example should make it obvious that the block structure
makes the file format very flexible compared to the classical libpcap
format.</t>
</section>
<section anchor="section_opt" title="Options">
<t>All the block bodies MAY embed optional fields.
Optional fields can be used to insert some information that may be
useful when reading data, but that is not really needed for packet
processing. Therefore, each tool can either read the content of the
optional fields (if any), or skip some of them or even all at
once.</t>
<t>A block that may contain options must be structured so that
the number of octets of data in the Block Body that precede the
options can be determined from that data; that allows the
beginning of the options to be found. That is true for all
standard blocks that support options; for Custom Blocks that
support options, the Custom Data must be structured in such a
fashion. This means that the Block Length field (present in
the General Block Structure, see
<xref target="section_block"/>) can be used to determine how
many octets of optional fields, if any, are present in the block.
That number can be used to determine whether the block has
optional fields (if it is zero, there are no optional fields),
to check, when processing optional fields, whether any optional
fields remain, and to skip all the optional fields at once.</t>
<t>Options are a list of Type - Length - Value fields, each one
containing a single value:
<list style="symbols">
<t>Option Type (16 bits): an unsigned value that contains
the code that specifies the type of the current TLV record.
Option types whose Most Significant Bit is equal to one are
reserved for local use; therefore, there is no guarantee
that the code used is unique among all capture files
(generated by other applications), and is most certainly not
portable. For cross-platform globally unique
vendor-specific extensions, the Custom Option MUST be used
instead, as defined in <xref target="section_custom_option"/>).</t>
<t>Option Length (16 bits): an unsigned value that contains
the actual length of the following 'Option Value' field
without the padding octets.</t>
<t>Option Value (variable length): the value of the given
option, padded to a 32-bit boundary. The actual length of
this field (i.e. without the padding octets) is specified
by the Option Length field.</t>
</list>
</t>
<t>Requests for new standardized option codes for a given block
should be sent to the <eref
target="https://www.winpcap.org/mailman/listinfo/pcap-ng-format">pcap-ng-format mailing list</eref>.</t>
<t>A given option may have a fixed length, in which case all
instances of that option have a length that is equal to the
specified fixed length, or a variable length, in which case
the option has a minimum length and all instances of that
option must have a length equal to or greater than the specified
minimum length. The length of fixed-length options, and the
minimum length of variable-length options, is specified in the
description of the option; if the minimum length of a
variable-length option is not specified, a zero-length option is
valid. Software that reads these files SHOULD report options
that have an invalid length as errors; the software MAY stop
processing the file if it sees an option that has invalid
length, or MAY ignore the option and continue processing it.
Software that writes these files MUST NOT write files with
options that have invalid lengths.</t>
<t>If an option's value is a string, the value is not necessarily
zero-terminated. Software that reads these files MUST NOT assume that
strings are zero-terminated, and MUST treat a zero-value octet as a
string terminator.</t>
<t>Some options may be repeated several times; for example, a
block can have multiple comments, and an Interface Description
Block can give multiple IPv4 or IPv6 addresses for the
interface if it has multiple IPv4 or IPv6 addresses assigned to
it. Other options may appear at most once in a given block.</t>
<t>The option list is terminated by a option which uses the
special 'End of Option' code (opt_endofopt). Code that
writes pcapng files MUST put an opt_endofopt option at the end
of an option list. Code that reads pcapng files MUST NOT assume
an option list will have an opt_endofopt option at the end; it
MUST also check for the end of the block, and SHOULD treat
blocks where the option list has no opt_endofopt option as if
the option list had an opt_endofopt option at the end.</t>
<t>The format of the optional fields is shown in <xref
target="formatopt"/>.</t>
<figure anchor="formatopt" title="Options Format">
<artwork xml:space="preserve" name="" type="" align="center" alt="" width="" height="">
1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Option Code | Option Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/ Option Value /
/ variable length, padded to 32 bits /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/ /
/ . . . other options . . . /
/ /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Option Code == opt_endofopt | Option Length == 0 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
</artwork>
</figure>
<t>The following codes can always be present in any optional field:</t>
<texttable anchor="optionsall" title="Common Options">
<ttcol align="left">Name</ttcol>
<ttcol align="left">Code</ttcol>
<ttcol align="left">Length</ttcol>
<ttcol align="left">Multiple allowed?</ttcol>
<c>opt_endofopt</c>
<c>0</c>
<c>0</c>
<c>no</c>
<c>opt_comment</c>
<c>1</c>
<c>variable</c>
<c>yes</c>
<c>opt_custom</c>
<c>2988/2989/19372/19373</c>
<c>variable, minimum 4</c>
<c>yes</c>
</texttable>
<t>
<list hangIndent="8" style="hanging">
<t hangText="opt_endofopt:"><vspace blankLines="0"/>The
opt_endofopt option delimits the end of the optional fields. This
option MUST NOT be repeated within a given list of options.</t>
<t hangText="opt_comment:"><vspace blankLines="0"/>The
opt_comment option is a UTF-8 string containing human-readable
comment text that is associated to the current block. Line
separators SHOULD be a carriage-return + linefeed ('\r\n') or just
linefeed ('\n'); either form may appear and be considered a line
separator. The string is not zero-terminated.</t>
<t>Examples: "This packet is the beginning of all of our
problems", "Packets 17-23 showing a bogus TCP retransmission!\r\n
This is reported in bugzilla entry 1486.\nIt will be fixed in the
future.".</t>
<t hangText="opt_custom:"><vspace blankLines="0"/>This option is
described in detail in <xref target="section_custom_option"/>.</t>
</list>
</t>
<section anchor="section_custom_option" title="Custom Options">
<t>Customs Options are used for portable, vendor-specific data
related to the block they're in. A Custom Option can be in any block
type that can have options, can be repeated any number of times in a
block, and may come before or after other option types - except the
opt_endofopt which is always the last option. Different Custom
Options, of different type codes and/or different Private Enterprise
Numbers, may be used in the same pcapng file. See <xref
target="section_vendor"/> for additional details.</t>
<figure anchor="formatcustomopt" title="Custom Options Format">
<artwork xml:space="preserve" name="" type="" align="center" alt="" width="" height="">
1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Custom Option Code | Option Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Private Enterprise Number (PEN) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/ Custom Data /
/ variable length, padded to 32 bits /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
</artwork>
</figure>
<t>The Custom Option has the following fields:
<list style="symbols">
<t>Custom Option Code: The code number for the Custom Option, which
can be one of the following decimal numbers:
<list hangIndent="8" style="hanging">
<t hangText="2988:"><vspace blankLines="0"/>This option code
identifies a Custom Option containing a UTF-8 string in the
Custom Data portion. The string is not zero-terminated.
This Custom Option can be safely copied to a new file if
the pcapng file is manipulated by an application; otherwise
19372 should be used instead. See <xref
target="section_vendor_copy"/> for details.</t>
<t hangText="2989:"><vspace blankLines="0"/>This option code
identifies a Custom Option containing binary octets in the
Custom Data portion. This Custom Option can be safely copied
to a new file if the pcapng file is manipulated by an
application; otherwise 19372 should be used instead. See <xref
target="section_vendor_copy"/> for details.</t>
<t hangText="19372:"><vspace blankLines="0"/>This option code
identifies a Custom Option containing a UTF-8 string in the
Custom Data portion. The string is not zero-terminated.
This Custom Option should not be copied to a new file if
the pcapng file is manipulated by an application. See <xref
target="section_vendor_copy"/> for details.</t>
<t hangText="19373:"><vspace blankLines="0"/>This option code
identifies a Custom Option containing binary octets in the
Custom Data portion. This Custom Option should not be copied
to a new file if the pcapng file is manipulated by an
application. See <xref target="section_vendor_copy"/> for
details.</t>
</list>
</t>
<t>Option Length: as described in <xref target="section_block"/>,
this contains the length of the option's value, which includes the
4-octet Private Enterprise Number and variable-length Custom Data
fields, without the padding octets.</t>
<t>Private Enterprise Number: An IANA-assigned Private Enterprise
Number identifying the organization which defined the Custom
Option. See <xref target="section_vendor_uses"/> for details. The
PEN number MUST be encoded using the same endianness as the Section
Header Block it is within the scope of.</t>
<t>Custom Data: the custom data, padded to a 32 bit boundary.</t>
</list>
</t>
</section>
</section>
<section title="Data format">
<section title="Endianness">
<t>Data contained in each section will always be saved according to
the characteristics (little endian / big endian) of the capturing
machine. This refers to all the fields that are saved as numbers and
that span over two or more octets.</t>
<t>The approach of having each section saved in the native format of
the generating host is more efficient because it avoids translation
of data when reading / writing on the host itself, which is the most
common case when generating/processing capture captures.</t>
<t>Please note: The endianness is indicated by the <xref
target="section_shb">Section Header Block</xref>. Since this block
can appear several times in a pcapng file, a single file can contain
both endianness variants.</t>
</section>
<section title="Alignment">
<t>All fields of this specification use proper alignment for 16-
and 32-bit values. This makes it easier and faster to read/write
file contents if using techniques like memory mapped files.</t>
<t>The alignment octets (marked in this document e.g. with "padded to
32 bits") MUST be filled with zeroes.</t>
<t>Please note: 64-bit values are not aligned to 64-bit boundaries.
This is because the file is naturally aligned to 32-bit boundaries
only. Special care MUST be taken when reading and writing such
values. (Note also that some 64-bit values are represented as a
64-bit integer in the endianness of the machine that wrote the
file, and others are represented as 2 32-bit values, one
containing the upper 32 bits of the value and one containing
the lower 32 bits of the value, each written as 32-bit
integers in the endianness of the machine that wrote the file.
Neither of these formats guarantee 64-bit alignment.)</t>
</section>
</section>
</section>
<section title="Block Definition">
<t>This section details the format of the blocks currently defined.</t>
<section anchor="section_shb" title="Section Header Block">
<t>The Section Header Block (SHB) is mandatory. It identifies the
beginning of a section of the capture file. The Section Header
Block does not contain data but it rather identifies a list of blocks
(interfaces, packets) that are logically correlated. Its format is
shown in <xref target="format_shb"/>.</t>
<figure anchor="format_shb" title="Section Header Block Format">
<artwork xml:space="preserve" name="" type="" align="center" alt="" width="" height="">
1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 | Block Type = 0x0A0D0D0A |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
4 | Block Total Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
8 | Byte-Order Magic |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
12 | Major Version | Minor Version |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
16 | |
| Section Length |
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
24 / /
/ Options (variable) /
/ /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Block Total Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
</artwork>
</figure>
<t>The meaning of the fields is:
<list style="symbols">
<t>Block Type: The block type of the Section Header Block is the
integer corresponding to the 4-char string "\n\r\r\n"
(0x0A0D0D0A). This particular value is used for 2 reasons:
<list style="numbers">
<t>This number is used to detect if a file has been transferred
via FTP or HTTP from a machine to another with an inappropriate
ASCII conversion. In this case, the value of this field will
differ from the standard one ("\n\r\r\n") and the reader can
detect a possibly corrupted file.</t>
<t>This value is palindromic, so that the reader is able to
recognize the Section Header Block regardless of the endianness
of the section. The endianness is recognized by reading the Byte
Order Magic, that is located 8 octets after the Block Type.</t>
</list>
</t>
<t>Block Total Length: total size of this block, as described in
<xref target="section_block"/>.</t>
<t>Byte-Order Magic (32 bits): an unsigned magic number,
whose value is the hexadecimal number 0x1A2B3C4D. This
number can be used to distinguish sections that have been
saved on little-endian machines from the ones saved on
big-endian machines, and to heuristically identify pcapng
files.</t>
<t>Major Version (16 bits): an unsigned value, giving the
number of the current major version of the format. The
value for the current version of the format is 1. This
value should change if the format changes in such a way that
code that reads the new format could not read the old format
(i.e., code to read both formats would have to check the
version number and use different code paths for the two
formats) and code that reads the old format could not read
the new format. Note that adding a new block type or a new
option is NOT such a change.</t>
<t>Minor Version (16 bits): an unsigned value, giving the
number of the current minor version of the format. The
value is for the current version of the format is 0. This
value should change if the format changes in such a way that
code that reads the new format could read the old format
without checking the version number but code that reads the
old format could not read all files in the new format. Note
that adding a new block type or a new option is NOT such a
change.</t>
<t>Section Length (64 bits): a signed value specifying the
length in octets of the following section, excluding the
Section Header Block itself. This field can be used to skip
the section, for faster navigation inside large files. If
the Section Length is -1 (0xFFFFFFFFFFFFFFFF), this means
that the size of the section is not specified, and the only
way to skip the section is to parse the blocks that it
contains. Please note that if this field is valid (i.e.
not negative), its value is always a multiple of 4, as all
the blocks are aligned to and padded to 32-bit (4 octet)
boundaries. Also, special care should be taken in accessing
this field: since the alignment of all the blocks in the
file is 32-bits, this field is not guaranteed to be aligned
to a 64-bit boundary. This could be a problem on 64-bit
processors.</t>
<t>Options: optionally, a list of options (formatted according to
the rules defined in <xref target="section_opt"/>) can be present.</t>
</list>
</t>
<t>Adding new block types or options would not necessarily require
that either Major or Minor numbers be changed, as code that does not
know about the block type or option should just skip it; only if
skipping a block or option does not work should the minor version
number be changed.</t>
<t>Aside from the options defined in <xref target="section_opt"/>, the
following options are valid within this block:</t>
<texttable anchor="options_shb" title="Section Header Block Options">
<ttcol align="left">Name</ttcol>
<ttcol align="left">Code</ttcol>
<ttcol align="left">Length</ttcol>
<ttcol align="left">Multiple allowed?</ttcol>
<c>shb_hardware</c>
<c>2</c>
<c>variable</c>
<c>no</c>
<c>shb_os</c>
<c>3</c>
<c>variable</c>
<c>no</c>
<c>shb_userappl</c>
<c>4</c>
<c>variable</c>
<c>no</c>
</texttable>
<t>
<list hangIndent="8" style="hanging">
<t hangText="shb_hardware:"><vspace blankLines="0"/>The
shb_hardware option is a UTF-8 string containing the description
of the hardware used to create this section. The string is
not zero-terminated.</t>
<t>Examples: "x86 Personal Computer", "Sun Sparc Workstation".</t>
<t hangText="shb_os:"><vspace blankLines="0"/>The shb_os option
is a UTF-8 string containing the name of the operating system used
to create this section. The string is not zero-terminated.</t>
<t>Examples: "Windows XP SP2", "openSUSE 10.2".</t>
<t hangText="shb_userappl:"><vspace blankLines="0"/>The
shb_userappl option is a UTF-8 string containing the name of the
application used to create this section. The string is not
zero-terminated.</t>
<t>Examples: "dumpcap V0.99.7".</t>
</list>
</t>
<t>[Open issue: does a program which re-writes a capture file change
the original hardware/os/application info?]</t>
</section>
<section anchor="section_idb" title="Interface Description Block">
<t>An Interface Description Block (IDB) is the container for
information describing an interface on which packet data is
captured.</t>
<t>Tools that write / read the capture file associate an incrementing
unsigned 32-bit number (starting from '0') to each Interface
Definition Block, called the Interface ID for the interface in
question. This number is unique within each Section and
identifies the interface to which the IDB refers; it is only
unique inside the current section, so, two Sections can have
different interfaces identified by the same Interface ID values.
This unique identifier is referenced by other blocks, such as
Enhanced Packet Blocks and Interface Statistic Blocks, to
indicate the interface to which the block refers (such the
interface that was used to capture the packet that an Enhanced
Packet Block contains or to which the statistics in an Interface
Statistic Block refer).</t>
<t>There must be an Interface Description Block for each
interface to which another block refers. Blocks such as an Enhanced
Packet Block or an Interface Statistics Block contain an Interface ID
value referring to a particular interface, and a Simple Packet Block
implicitly refers to an interface with an Interface ID of 0. If the
file does not contain any blocks that use an Interface ID, then the
file does not need to have any IDBs.</t>
<t>An Interface Description Block is valid only inside the section
to which it belongs. The structure of a Interface Description Block is
shown in <xref target="format_idb"/>.</t>
<figure anchor="format_idb" title="Interface Description Block Format">
<artwork xml:space="preserve" name="" type="" align="center" alt="" width="" height="">
1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 | Block Type = 0x00000001 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
4 | Block Total Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
8 | LinkType | Reserved |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
12 | SnapLen |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
16 / /
/ Options (variable) /
/ /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Block Total Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
</artwork>
</figure>
<t>The meaning of the fields is:
<list style="symbols">
<t>Block Type: The block type of the Interface Description Block
is 1.</t>
<t>Block Total Length: total size of this block, as described in
<xref target="section_block"/>.</t>
<t>LinkType (16 bits): an unsigned value that defines the
link layer type of this interface. The list of Standardized
Link Layer Type codes is available in <xref
target="LINKTYPES"/>.</t>
<t>Reserved (16 bits): not used - MUST be filled with 0 by
pcapng file writers, and MUST be ignored by pcapng file
readers.</t>
<t>SnapLen (32 bits): an unsigned value indicating the
maximum number of octets captured from each packet. The
portion of each packet that exceeds this value will not be
stored in the file. A value of zero indicates no limit.</t>
<t>Options: optionally, a list of options (formatted according to
the rules defined in <xref target="section_opt"/>) can be present.</t>
</list>
</t>
<t>In addition to the options defined in <xref target="section_opt"/>,
the following options are valid within this block:</t>
<texttable anchor="optionsifb" title="Interface Description Block Options">
<ttcol align="left">Name</ttcol>
<ttcol align="left">Code</ttcol>
<ttcol align="left">Length</ttcol>
<ttcol align="left">Multiple allowed?</ttcol>
<c>if_name</c>
<c>2</c>
<c>variable</c>
<c>no</c>