editcap.html 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <meta name="generator" content="Asciidoctor 2.0.17">
  8. <title>editcap(1)</title>
  9. <link rel="stylesheet" href="./ws.css">
  10. </head>
  11. <body class="manpage">
  12. <div id="header">
  13. <h1>editcap(1) Manual Page</h1>
  14. <h2 id="_name">NAME</h2>
  15. <div class="sectionbody">
  16. <p>editcap - Edit and/or translate the format of capture files</p>
  17. </div>
  18. </div>
  19. <div id="content">
  20. <div class="sect1">
  21. <h2 id="_synopsis">SYNOPSIS</h2>
  22. <div class="sectionbody">
  23. <div class="paragraph">
  24. <p><span class="nowrap"><strong>editcap</strong></span>
  25. <span class="nowrap">[ <strong>-a</strong> &lt;frame:comment&gt; ]</span>
  26. <span class="nowrap">[ <strong>-A</strong> &lt;start time&gt; ]</span>
  27. <span class="nowrap">[ <strong>-B</strong> &lt;stop time&gt; ]</span>
  28. <span class="nowrap">[ <strong>-c</strong> &lt;packets per file&gt; ]</span>
  29. <span class="nowrap">[ <strong>-C</strong> [offset:]&lt;choplen&gt; ]</span>
  30. <span class="nowrap">[ <strong>-E</strong> &lt;error probability&gt; ]</span>
  31. <span class="nowrap">[ <strong>-F</strong> &lt;file format&gt; ]</span>
  32. <span class="nowrap">[ <strong>-i</strong> &lt;seconds per file&gt; ]</span>
  33. <span class="nowrap">[ <strong>-o</strong> &lt;change offset&gt; ]</span>
  34. <span class="nowrap">[ <strong>-L</strong> ]</span>
  35. <span class="nowrap">[ <strong>-r</strong> ]</span>
  36. <span class="nowrap">[ <strong>-s</strong> &lt;snaplen&gt; ]</span>
  37. <span class="nowrap">[ <strong>-S</strong> &lt;strict time adjustment&gt; ]</span>
  38. <span class="nowrap">[ <strong>-t</strong> &lt;time adjustment&gt; ]</span>
  39. <span class="nowrap">[ <strong>-T</strong> &lt;encapsulation type&gt; ]</span>
  40. <span class="nowrap">[ <strong>-V</strong> ]</span>
  41. <span class="nowrap">[ <strong>--inject-secrets</strong> &lt;secrets type&gt;,&lt;file&gt; ]</span>
  42. <span class="nowrap">[ <strong>--discard-all-secrets</strong> ]</span>
  43. <span class="nowrap">[ <strong>--capture-comment</strong> &lt;comment&gt; ]</span>
  44. <span class="nowrap">[ <strong>--discard-capture-comment</strong> ]</span>
  45. <span class="nowrap"><em>infile</em></span>
  46. <span class="nowrap"><em>outfile</em></span>
  47. <span class="nowrap">[ <em>packet#</em>[-<em>packet#</em>] &#8230;&#8203; ]</span></p>
  48. </div>
  49. <div class="paragraph">
  50. <p><span class="nowrap"><strong>editcap</strong></span>
  51. <span class="nowrap"><strong>-d</strong></span>
  52. <span class="nowrap"><strong>-D</strong> &lt;dup window&gt;</span>
  53. <span class="nowrap"><strong>-w</strong> &lt;dup time window&gt;</span>
  54. <span class="nowrap">[ <strong>-V</strong> ]</span>
  55. <span class="nowrap">[ <strong>-I</strong> &lt;bytes to ignore&gt; ]</span>
  56. <span class="nowrap">[ <strong>--skip-radiotap-header</strong> ]</span>
  57. <span class="nowrap"><em>infile</em></span>
  58. <span class="nowrap"><em>outfile</em></span></p>
  59. </div>
  60. <div class="paragraph">
  61. <p><span class="nowrap"><strong>editcap</strong></span>
  62. <span class="nowrap"><strong>-h|--help</strong></span></p>
  63. </div>
  64. <div class="paragraph">
  65. <p><span class="nowrap"><strong>editcap</strong></span>
  66. <span class="nowrap"><strong>-v|--version</strong></span></p>
  67. </div>
  68. </div>
  69. </div>
  70. <div class="sect1">
  71. <h2 id="_description">DESCRIPTION</h2>
  72. <div class="sectionbody">
  73. <div class="paragraph">
  74. <p><strong>Editcap</strong> is a program that reads some or all of the captured packets from the
  75. <em>infile</em>, optionally converts them in various ways and writes the
  76. resulting packets to the capture <em>outfile</em> (or outfiles).</p>
  77. </div>
  78. <div class="paragraph">
  79. <p>By default, it reads all packets from the <em>infile</em> and writes them to the
  80. <em>outfile</em> in pcapng file format. Use '-' for <em>infile</em> or <em>outfile</em>
  81. to read from standard input or write to standard output, respectively.</p>
  82. </div>
  83. <div class="paragraph">
  84. <p>The <strong>-A</strong> and <strong>-B</strong> option allow you to limit the time range from which packets
  85. are read from the <em>infile</em>.</p>
  86. </div>
  87. <div class="paragraph">
  88. <p>An optional list of packet numbers can be specified on the command tail;
  89. individual packet numbers separated by whitespace and/or ranges of packet
  90. numbers can be specified as <em>start</em>-<em>end</em>, referring to all packets from
  91. <em>start</em> to <em>end</em>. By default the selected packets with those numbers will
  92. <em>not</em> be written to the capture file. If the <strong>-r</strong> flag is specified, the
  93. whole packet selection is reversed; in that case <em>only</em> the selected packets
  94. will be written to the capture file.</p>
  95. </div>
  96. <div class="paragraph">
  97. <p><strong>Editcap</strong> can also be used to remove duplicate packets. Several different
  98. options (<strong>-d</strong>, <strong>-D</strong> and <strong>-w</strong>) are used to control the packet window
  99. or relative time window to be used for duplicate comparison.</p>
  100. </div>
  101. <div class="paragraph">
  102. <p><strong>Editcap</strong> can be used to assign comment strings to frame numbers.</p>
  103. </div>
  104. <div class="paragraph">
  105. <p><strong>Editcap</strong> is able to detect, read and write the same capture files that
  106. are supported by <strong>Wireshark</strong>.
  107. The input file doesn&#8217;t need a specific filename extension; the file
  108. format and an optional gzip, zstd or lz4 compression will be automatically detected.
  109. Near the beginning of the DESCRIPTION section of <a href="wireshark.html">wireshark</a>(1) or
  110. <a href="https://www.wireshark.org/docs/man-pages/wireshark.html" class="bare">https://www.wireshark.org/docs/man-pages/wireshark.html</a>
  111. is a detailed description of the way <strong>Wireshark</strong> handles this, which is
  112. the same way <strong>Editcap</strong> handles this.</p>
  113. </div>
  114. <div class="paragraph">
  115. <p><strong>Editcap</strong> can write the file in several output formats. The <strong>-F</strong>
  116. flag can be used to specify the format in which to write the capture
  117. file; <strong>editcap -F</strong> provides a list of the available output formats.</p>
  118. </div>
  119. </div>
  120. </div>
  121. <div class="sect1">
  122. <h2 id="_options">OPTIONS</h2>
  123. <div class="sectionbody">
  124. <div class="dlist">
  125. <dl>
  126. <dt class="hdlist1">-a &lt;framenum:comment&gt;</dt>
  127. <dd>
  128. <div class="openblock">
  129. <div class="content">
  130. <div class="paragraph">
  131. <p>For the specified frame number, assign the given comment string.
  132. Can be repeated for multiple frames. Quotes should be used with comment
  133. strings that include spaces.</p>
  134. </div>
  135. </div>
  136. </div>
  137. </dd>
  138. <dt class="hdlist1">-A &lt;start time&gt;</dt>
  139. <dd>
  140. <div class="openblock">
  141. <div class="content">
  142. <div class="paragraph">
  143. <p>Reads only the packets whose timestamp is on or after start time.
  144. The time is given in ISO 8601 format, either
  145. YYYY-MM-DD HH:MM:SS[.nnnnnnnnn][Z|±hh:mm] or
  146. YYYY-MM-DDTHH:MM:SS[.nnnnnnnnn][Z|±hh:mm] .
  147. The fractional seconds are optional, as is the time zone offset from UTC
  148. (in which case local time is assumed). Unix epoch timestamps
  149. (floating point format) are also accepted.</p>
  150. </div>
  151. </div>
  152. </div>
  153. </dd>
  154. <dt class="hdlist1">-B &lt;stop time&gt;</dt>
  155. <dd>
  156. <div class="openblock">
  157. <div class="content">
  158. <div class="paragraph">
  159. <p>Reads only the packets whose timestamp is before stop time.
  160. The time is given in ISO 8601 format, either
  161. YYYY-MM-DD HH:MM:SS[.nnnnnnnnn][Z|±hh:mm] or
  162. YYYY-MM-DDTHH:MM:SS[.nnnnnnnnn][Z|±hh:mm] .
  163. The fractional seconds are optional, as is the time zone offset from UTC
  164. (in which case local time is assumed). Unix epoch timestamps
  165. (floating point format) are also accepted.</p>
  166. </div>
  167. </div>
  168. </div>
  169. </dd>
  170. <dt class="hdlist1">-c &lt;packets per file&gt;</dt>
  171. <dd>
  172. <div class="openblock">
  173. <div class="content">
  174. <div class="paragraph">
  175. <p>Splits the packet output to different files based on uniform packet counts
  176. with a maximum of &lt;packets per file&gt; each.</p>
  177. </div>
  178. <div class="paragraph">
  179. <p>Each output file will be created with an infix _nnnnn[_YYYYmmddHHMMSS] inserted
  180. before the file extension (which may be null) of <em>outfile</em>. The infix
  181. consists of the ordinal number of the output file, starting with 00000,
  182. followed by the timestamp of its first packet. The timestamp is omitted if
  183. the input file does not contain timestamp information.</p>
  184. </div>
  185. <div class="paragraph">
  186. <p>After the specified number of packets is written to the output file, the next
  187. output file is opened. The default is to use a single output file.
  188. This option conflicts with <strong>-i</strong>.</p>
  189. </div>
  190. </div>
  191. </div>
  192. </dd>
  193. <dt class="hdlist1">-C [offset:]&lt;choplen&gt;</dt>
  194. <dd>
  195. <div class="openblock">
  196. <div class="content">
  197. <div class="paragraph">
  198. <p>Sets the chop length to use when writing the packet data. Each packet is
  199. chopped by &lt;choplen&gt; bytes of data. Positive values chop at the packet
  200. beginning while negative values chop at the packet end.</p>
  201. </div>
  202. <div class="paragraph">
  203. <p>If an optional offset precedes the &lt;choplen&gt;, then the bytes chopped will be
  204. offset from that value. Positive offsets are from the packet beginning, while
  205. negative offsets are from the packet end.</p>
  206. </div>
  207. <div class="paragraph">
  208. <p>This is useful for chopping headers for decapsulation of an entire capture,
  209. removing tunneling headers, or in the rare case that the conversion between two
  210. file formats leaves some random bytes at the end of each packet. Another use is
  211. for removing vlan tags.</p>
  212. </div>
  213. <div class="admonitionblock note">
  214. <table>
  215. <tr>
  216. <td class="icon">
  217. <div class="title">Note</div>
  218. </td>
  219. <td class="content">
  220. This option can be used more than once, effectively allowing you to chop
  221. bytes from up to two different areas of a packet in a single pass provided that
  222. you specify at least one chop length as a positive value and at least one as a
  223. negative value. All positive chop lengths are added together as are all
  224. negative chop lengths.
  225. </td>
  226. </tr>
  227. </table>
  228. </div>
  229. </div>
  230. </div>
  231. </dd>
  232. <dt class="hdlist1">-d</dt>
  233. <dd>
  234. <div class="openblock">
  235. <div class="content">
  236. <div class="paragraph">
  237. <p>Attempts to remove duplicate packets. The length and MD5 hash of the
  238. current packet are compared to the previous four (4) packets. If a
  239. match is found, the current packet is skipped. This option is equivalent
  240. to using the option <strong>-D 5</strong>.</p>
  241. </div>
  242. </div>
  243. </div>
  244. </dd>
  245. <dt class="hdlist1">-D &lt;dup window&gt;</dt>
  246. <dd>
  247. <div class="openblock">
  248. <div class="content">
  249. <div class="paragraph">
  250. <p>Attempts to remove duplicate packets. The length and MD5 hash of the
  251. current packet are compared to the previous &lt;dup window&gt; - 1 packets.
  252. If a match is found, the current packet is skipped.</p>
  253. </div>
  254. <div class="paragraph">
  255. <p>The use of the option <strong>-D 0</strong> combined with the <strong>-V</strong> option is useful
  256. in that each packet&#8217;s Packet number, Len and MD5 Hash will be printed
  257. to standard error. This verbose output (specifically the MD5 hash strings)
  258. can be useful in scripts to identify duplicate packets across trace
  259. files.</p>
  260. </div>
  261. <div class="paragraph">
  262. <p>The &lt;dup window&gt; is specified as an integer value between 0 and 1000000 (inclusive).</p>
  263. </div>
  264. <div class="admonitionblock note">
  265. <table>
  266. <tr>
  267. <td class="icon">
  268. <div class="title">Note</div>
  269. </td>
  270. <td class="content">
  271. Specifying large &lt;dup window&gt; values with large tracefiles can
  272. result in very long processing times for <strong>editcap</strong>.
  273. </td>
  274. </tr>
  275. </table>
  276. </div>
  277. </div>
  278. </div>
  279. </dd>
  280. <dt class="hdlist1">-E &lt;error probability&gt;</dt>
  281. <dd>
  282. <div class="openblock">
  283. <div class="content">
  284. <div class="paragraph">
  285. <p>Sets the probability that bytes in the output file are randomly changed.
  286. <strong>Editcap</strong> uses that probability (between 0.0 and 1.0 inclusive)
  287. to apply errors to each data byte in the file. For instance, a
  288. probability of 0.02 means that each byte has a 2% chance of having an error.</p>
  289. </div>
  290. <div class="paragraph">
  291. <p>This option is meant to be used for fuzz-testing protocol dissectors.</p>
  292. </div>
  293. </div>
  294. </div>
  295. </dd>
  296. <dt class="hdlist1">-F &lt;file format&gt;</dt>
  297. <dd>
  298. <div class="openblock">
  299. <div class="content">
  300. <div class="paragraph">
  301. <p>Sets the file format of the output capture file.
  302. <strong>Editcap</strong> can write the file in several formats, <strong>editcap -F</strong>
  303. provides a list of the available output formats. The default
  304. is the <strong>pcapng</strong> format.</p>
  305. </div>
  306. </div>
  307. </div>
  308. </dd>
  309. <dt class="hdlist1">-h|--help</dt>
  310. <dd>
  311. <div class="openblock">
  312. <div class="content">
  313. <div class="paragraph">
  314. <p>Prints the version and options and exits.</p>
  315. </div>
  316. </div>
  317. </div>
  318. </dd>
  319. <dt class="hdlist1">-i &lt;seconds per file&gt;</dt>
  320. <dd>
  321. <div class="openblock">
  322. <div class="content">
  323. <div class="paragraph">
  324. <p>Splits the packet output to different files based on uniform time
  325. intervals using a maximum interval of &lt;seconds per file&gt; each. Floating
  326. point values (e.g. 0.5) are allowed.</p>
  327. </div>
  328. <div class="paragraph">
  329. <p>Each output file will be created with an infix _nnnnn[_YYYYmmddHHMMSS] inserted
  330. before the file extension (which may be null) of <em>outfile</em>. The infix
  331. consists of the ordinal number of the output file, starting with 00000,
  332. followed by the timestamp of its first packet. The timestamp is omitted if
  333. the input file does not contain timestamp information.</p>
  334. </div>
  335. <div class="paragraph">
  336. <p>After packets for the specified time interval are written to the output file,
  337. the next output file is opened. The default is to use a single output file.
  338. This option conflicts with <strong>-c</strong>.</p>
  339. </div>
  340. </div>
  341. </div>
  342. </dd>
  343. <dt class="hdlist1">-I &lt;bytes to ignore&gt;</dt>
  344. <dd>
  345. <div class="openblock">
  346. <div class="content">
  347. <div class="paragraph">
  348. <p>Ignore the specified number of bytes at the beginning of the frame during MD5 hash calculation,
  349. unless the frame is too short, then the full frame is used.
  350. Useful to remove duplicated packets taken on several routers (different mac addresses for example)
  351. e.g. -I 26 in case of Ether/IP will ignore ether(14) and IP header(20 - 4(src ip) - 4(dst ip)).
  352. The default value is 0.</p>
  353. </div>
  354. </div>
  355. </div>
  356. </dd>
  357. <dt class="hdlist1">-L</dt>
  358. <dd>
  359. <div class="openblock">
  360. <div class="content">
  361. <div class="paragraph">
  362. <p>Adjust the original frame length accordingly when chopping and/or snapping
  363. (in addition to the captured length, which is always adjusted regardless of
  364. whether <strong>-L</strong> is specified or not). See also <strong>-C &lt;choplen</strong>&gt; and <strong>-s &lt;snaplen</strong>&gt;.</p>
  365. </div>
  366. </div>
  367. </div>
  368. </dd>
  369. <dt class="hdlist1">-o &lt;change offset&gt;</dt>
  370. <dd>
  371. <div class="openblock">
  372. <div class="content">
  373. <div class="paragraph">
  374. <p>When used in conjunction with -E, skip some bytes from the beginning of the packet
  375. from being changed. In this way some headers don&#8217;t get changed, and the fuzzer is
  376. more focused on a smaller part of the packet. Keeping a part of the packet fixed
  377. the same dissector is triggered, that make the fuzzing more precise.</p>
  378. </div>
  379. </div>
  380. </div>
  381. </dd>
  382. <dt class="hdlist1">-r</dt>
  383. <dd>
  384. <div class="openblock">
  385. <div class="content">
  386. <div class="paragraph">
  387. <p>Reverse the packet selection.
  388. Causes the packets whose packet numbers are specified on the command
  389. line to be written to the output capture file, instead of discarding them.</p>
  390. </div>
  391. </div>
  392. </div>
  393. </dd>
  394. <dt class="hdlist1">-s &lt;snaplen&gt;</dt>
  395. <dd>
  396. <div class="openblock">
  397. <div class="content">
  398. <div class="paragraph">
  399. <p>Sets the snapshot length to use when writing the data.
  400. If the <strong>-s</strong> flag is used to specify a snapshot length, packets in the
  401. input file with more captured data than the specified snapshot length
  402. will have only the amount of data specified by the snapshot length
  403. written to the output file.</p>
  404. </div>
  405. <div class="paragraph">
  406. <p>This may be useful if the program that is
  407. to read the output file cannot handle packets larger than a certain size
  408. (for example, the versions of snoop in Solaris 2.5.1 and Solaris 2.6
  409. appear to reject Ethernet packets larger than the standard Ethernet MTU,
  410. making them incapable of handling gigabit Ethernet captures if jumbo
  411. packets were used).</p>
  412. </div>
  413. </div>
  414. </div>
  415. </dd>
  416. <dt class="hdlist1">--seed &lt;seed&gt;</dt>
  417. <dd>
  418. <div class="openblock">
  419. <div class="content">
  420. <div class="paragraph">
  421. <p>When used in conjunction with -E, set the seed for the pseudo-random number generator.
  422. This is useful for recreating a particular sequence of errors.</p>
  423. </div>
  424. </div>
  425. </div>
  426. </dd>
  427. <dt class="hdlist1">--skip-radiotap-header</dt>
  428. <dd>
  429. <div class="openblock">
  430. <div class="content">
  431. <div class="paragraph">
  432. <p>Skip the radiotap header of each frame when checking for packet duplicates. This is useful
  433. when processing a capture created by combining outputs of multiple capture devices on the same
  434. channel in the vicinity of each other.</p>
  435. </div>
  436. </div>
  437. </div>
  438. </dd>
  439. <dt class="hdlist1">-S &lt;strict time adjustment&gt;</dt>
  440. <dd>
  441. <div class="openblock">
  442. <div class="content">
  443. <div class="paragraph">
  444. <p>Time adjust selected packets to ensure strict chronological order.</p>
  445. </div>
  446. <div class="paragraph">
  447. <p>The &lt;strict time adjustment&gt; value represents relative seconds
  448. specified as <em class="-">seconds</em>[<em>.fractional seconds</em>].</p>
  449. </div>
  450. <div class="paragraph">
  451. <p>As the capture file is processed each packet&#8217;s absolute time is
  452. <em>possibly</em> adjusted to be equal to or greater than the previous
  453. packet&#8217;s absolute timestamp depending on the &lt;strict time
  454. adjustment&gt; value.</p>
  455. </div>
  456. <div class="paragraph">
  457. <p>If &lt;strict time adjustment&gt; value is 0 or greater (e.g. 0.000001)
  458. then <strong>only</strong> packets with a timestamp less than the previous packet
  459. will adjusted. The adjusted timestamp value will be set to be
  460. equal to the timestamp value of the previous packet plus the value
  461. of the &lt;strict time adjustment&gt; value. A &lt;strict time adjustment&gt;
  462. value of 0 will adjust the minimum number of timestamp values
  463. necessary to ensure that the resulting capture file is in
  464. strict chronological order.</p>
  465. </div>
  466. <div class="paragraph">
  467. <p>If &lt;strict time adjustment&gt; value is specified as a
  468. negative value, then the timestamp values of <strong>all</strong>
  469. packets will be adjusted to be equal to the timestamp value
  470. of the previous packet plus the absolute value of the
  471. &lt;strict time adjustment&gt; value. A &lt;strict time
  472. adjustment&gt; value of -0 will result in all packets
  473. having the timestamp value of the first packet.</p>
  474. </div>
  475. <div class="paragraph">
  476. <p>This feature is useful when the trace file has an occasional
  477. packet with a negative delta time relative to the previous
  478. packet.</p>
  479. </div>
  480. </div>
  481. </div>
  482. </dd>
  483. <dt class="hdlist1">-t &lt;time adjustment&gt;</dt>
  484. <dd>
  485. <div class="openblock">
  486. <div class="content">
  487. <div class="paragraph">
  488. <p>Sets the time adjustment to use on selected packets.
  489. If the <strong>-t</strong> flag is used to specify a time adjustment, the specified
  490. adjustment will be applied to all selected packets in the capture file.
  491. The adjustment is specified as <em class="-">seconds</em>[<em>.fractional seconds</em>].
  492. For example, <strong>-t</strong> 3600 advances the timestamp on selected packets by one
  493. hour while <strong>-t</strong> -0.5 reduces the timestamp on selected packets by
  494. one-half second.</p>
  495. </div>
  496. <div class="paragraph">
  497. <p>This feature is useful when synchronizing dumps
  498. collected on different machines where the time difference between the
  499. two machines is known or can be estimated.</p>
  500. </div>
  501. </div>
  502. </div>
  503. </dd>
  504. <dt class="hdlist1">-T &lt;encapsulation type&gt;</dt>
  505. <dd>
  506. <div class="openblock">
  507. <div class="content">
  508. <div class="paragraph">
  509. <p>Sets the packet encapsulation type of the output capture file.
  510. If the <strong>-T</strong> flag is used to specify an encapsulation type, the
  511. encapsulation type of the output capture file will be forced to the
  512. specified type.
  513. <strong>editcap -T</strong> provides a list of the available types. The default
  514. type is the one appropriate to the encapsulation type of the input
  515. capture file.</p>
  516. </div>
  517. <div class="paragraph">
  518. <p>Note: this merely
  519. forces the encapsulation type of the output file to be the specified
  520. type; the packet headers of the packets will not be translated from the
  521. encapsulation type of the input capture file to the specified
  522. encapsulation type (for example, it will not translate an Ethernet
  523. capture to an FDDI capture if an Ethernet capture is read and '<strong>-T
  524. fddi</strong>' is specified). If you need to remove/add headers from/to a
  525. packet, you will need od(1)/<a href="text2pcap.html">text2pcap</a>(1).</p>
  526. </div>
  527. </div>
  528. </div>
  529. </dd>
  530. <dt class="hdlist1">-v|--version</dt>
  531. <dd>
  532. <div class="openblock">
  533. <div class="content">
  534. <div class="paragraph">
  535. <p>Print the version and exit.</p>
  536. </div>
  537. </div>
  538. </div>
  539. </dd>
  540. <dt class="hdlist1">-V</dt>
  541. <dd>
  542. <div class="openblock">
  543. <div class="content">
  544. <div class="paragraph">
  545. <p>Causes <strong>editcap</strong> to print verbose messages while it&#8217;s working.</p>
  546. </div>
  547. <div class="paragraph">
  548. <p>Use of <strong>-V</strong> with the de-duplication switches of <strong>-d</strong>, <strong>-D</strong> or <strong>-w</strong>
  549. will cause all MD5 hashes to be printed whether the packet is skipped
  550. or not.</p>
  551. </div>
  552. </div>
  553. </div>
  554. </dd>
  555. <dt class="hdlist1">-w &lt;dup time window&gt;</dt>
  556. <dd>
  557. <div class="openblock">
  558. <div class="content">
  559. <div class="paragraph">
  560. <p>Attempts to remove duplicate packets. The current packet&#8217;s arrival time
  561. is compared with up to 1000000 previous packets. If the packet&#8217;s relative
  562. arrival time is <em>less than or equal to</em> the &lt;dup time window&gt; of a previous packet
  563. and the packet length and MD5 hash of the current packet are the same then
  564. the packet to skipped. The duplicate comparison test stops when
  565. the current packet&#8217;s relative arrival time is greater than &lt;dup time window&gt;.</p>
  566. </div>
  567. <div class="paragraph">
  568. <p>The &lt;dup time window&gt; is specified as <em>seconds</em>[<em>.fractional seconds</em>].</p>
  569. </div>
  570. <div class="paragraph">
  571. <p>The [.fractional seconds] component can be specified to nine (9) decimal
  572. places (billionths of a second) but most typical trace files have resolution
  573. to six (6) decimal places (millionths of a second).</p>
  574. </div>
  575. <div class="admonitionblock note">
  576. <table>
  577. <tr>
  578. <td class="icon">
  579. <div class="title">Note</div>
  580. </td>
  581. <td class="content">
  582. Specifying large &lt;dup time window&gt; values with large tracefiles can
  583. result in very long processing times for <strong>editcap</strong>.
  584. </td>
  585. </tr>
  586. </table>
  587. </div>
  588. <div class="admonitionblock note">
  589. <table>
  590. <tr>
  591. <td class="icon">
  592. <div class="title">Note</div>
  593. </td>
  594. <td class="content">
  595. The <strong>-w</strong> option assumes that the packets are in chronological order.
  596. If the packets are NOT in chronological order then the <strong>-w</strong> duplication
  597. removal option may not identify some duplicates.
  598. </td>
  599. </tr>
  600. </table>
  601. </div>
  602. </div>
  603. </div>
  604. </dd>
  605. <dt class="hdlist1">--inject-secrets &lt;secrets type&gt;,&lt;file&gt;</dt>
  606. <dd>
  607. <div class="openblock">
  608. <div class="content">
  609. <div class="paragraph">
  610. <p>Inserts the contents of &lt;file&gt; into a Decryption Secrets Block (DSB)
  611. within the pcapng output file. This enables decryption without requiring
  612. additional configuration in protocol preferences.</p>
  613. </div>
  614. <div class="paragraph">
  615. <p>The file format is described by &lt;secrets type&gt; which can be one of:</p>
  616. </div>
  617. <div class="paragraph">
  618. <p><em>tls</em> TLS Key Log as described at <a href="https://developer.mozilla.org/NSS_Key_Log_Format" class="bare">https://developer.mozilla.org/NSS_Key_Log_Format</a>
  619. <em>wg</em> WireGuard Key Log, see <a href="https://gitlab.com/wireshark/wireshark/-/wikis/WireGuard#key-log-format" class="bare">https://gitlab.com/wireshark/wireshark/-/wikis/WireGuard#key-log-format</a></p>
  620. </div>
  621. <div class="paragraph">
  622. <p>This option may be specified multiple times. The available options for
  623. &lt;secrets type&gt; can be listed with <strong>--inject-secrets help</strong>.</p>
  624. </div>
  625. </div>
  626. </div>
  627. </dd>
  628. <dt class="hdlist1">--discard-all-secrets</dt>
  629. <dd>
  630. <div class="openblock">
  631. <div class="content">
  632. <div class="paragraph">
  633. <p>Discard all decryption secrets from the input file when writing the
  634. output file. Does not discard secrets added by <strong>--inject-secrets</strong> in
  635. the same command line.</p>
  636. </div>
  637. </div>
  638. </div>
  639. </dd>
  640. <dt class="hdlist1">--capture-comment &lt;comment&gt;</dt>
  641. <dd>
  642. <div class="openblock">
  643. <div class="content">
  644. <div class="paragraph">
  645. <p>Adds the given comment to the output file, if supported by the output
  646. file format. New comments will be added <em>after</em> any comments present
  647. in the input file unless <strong>--discard-capture-comment</strong> is also specified.</p>
  648. </div>
  649. <div class="paragraph">
  650. <p>This option may be specified multiple times. Note that Wireshark
  651. currently only displays the first comment of a capture file.</p>
  652. </div>
  653. </div>
  654. </div>
  655. </dd>
  656. <dt class="hdlist1">--discard-capture-comment</dt>
  657. <dd>
  658. <div class="openblock">
  659. <div class="content">
  660. <div class="paragraph">
  661. <p>Discard all capture file comments from the input file when writing the output
  662. file. Does not discard comments added by <strong>--capture-comment</strong> in the same
  663. command line.</p>
  664. </div>
  665. </div>
  666. </div>
  667. </dd>
  668. </dl>
  669. </div>
  670. </div>
  671. </div>
  672. <div class="sect1">
  673. <h2 id="_diagnostic_options">DIAGNOSTIC OPTIONS</h2>
  674. <div class="sectionbody">
  675. <div class="dlist">
  676. <dl>
  677. <dt class="hdlist1">--log-level &lt;level&gt;</dt>
  678. <dd>
  679. <p>Set the active log level.
  680. Supported levels in lowest to highest order are "noisy", "debug", "info", "message", "warning", "critical", and "error".
  681. Messages at each level and higher will be printed, for example "warning" prints "warning", "critical", and "error" messages and "noisy" prints all messages.
  682. Levels are case insensitive.</p>
  683. </dd>
  684. <dt class="hdlist1">--log-fatal &lt;level&gt;</dt>
  685. <dd>
  686. <p>Abort the program if any messages are logged at the specified level or higher.
  687. For example, "warning" aborts on any "warning", "critical", or "error" messages.</p>
  688. </dd>
  689. </dl>
  690. </div>
  691. <div class="dlist">
  692. <dl>
  693. <dt class="hdlist1">--log-domains &lt;list&gt;</dt>
  694. <dd>
  695. <p>Only print messages for the specified log domains, e.g. "GUI,Epan,sshdump".
  696. List of domains must be comma-separated.</p>
  697. </dd>
  698. <dt class="hdlist1">--log-debug &lt;list&gt;</dt>
  699. <dd>
  700. <p>Force the specified domains to log at the "debug" level.
  701. List of domains must be comma-separated.</p>
  702. </dd>
  703. <dt class="hdlist1">--log-noisy &lt;list&gt;</dt>
  704. <dd>
  705. <p>Force the specified domains to log at the "noisy" level.
  706. List of domains must be comma-separated.</p>
  707. </dd>
  708. <dt class="hdlist1">--log-file &lt;path&gt;</dt>
  709. <dd>
  710. <p>Write log messages and stderr output to the specified file.</p>
  711. </dd>
  712. </dl>
  713. </div>
  714. </div>
  715. </div>
  716. <div class="sect1">
  717. <h2 id="_examples">EXAMPLES</h2>
  718. <div class="sectionbody">
  719. <div class="paragraph">
  720. <p>To see more detailed description of the options use:</p>
  721. </div>
  722. <div class="literalblock">
  723. <div class="content">
  724. <pre>editcap -h</pre>
  725. </div>
  726. </div>
  727. <div class="paragraph">
  728. <p>To shrink the capture file by truncating the packets at 64 bytes and writing it as Sun snoop file use:</p>
  729. </div>
  730. <div class="literalblock">
  731. <div class="content">
  732. <pre>editcap -s 64 -F snoop capture.pcapng shortcapture.snoop</pre>
  733. </div>
  734. </div>
  735. <div class="paragraph">
  736. <p>To delete packet 1000 from the capture file use:</p>
  737. </div>
  738. <div class="literalblock">
  739. <div class="content">
  740. <pre>editcap capture.pcapng sans1000.pcapng 1000</pre>
  741. </div>
  742. </div>
  743. <div class="paragraph">
  744. <p>To limit a capture file to packets from number 200 to 750 (inclusive) use:</p>
  745. </div>
  746. <div class="literalblock">
  747. <div class="content">
  748. <pre>editcap -r capture.pcapng small.pcapng 200-750</pre>
  749. </div>
  750. </div>
  751. <div class="paragraph">
  752. <p>To get all packets from number 1-500 (inclusive) use:</p>
  753. </div>
  754. <div class="literalblock">
  755. <div class="content">
  756. <pre>editcap -r capture.pcapng first500.pcapng 1-500</pre>
  757. </div>
  758. </div>
  759. <div class="paragraph">
  760. <p>or</p>
  761. </div>
  762. <div class="literalblock">
  763. <div class="content">
  764. <pre>editcap capture.pcapng first500.pcapng 501-9999999</pre>
  765. </div>
  766. </div>
  767. <div class="paragraph">
  768. <p>To exclude packets 1, 5, 10 to 20 and 30 to 40 from the new file use:</p>
  769. </div>
  770. <div class="literalblock">
  771. <div class="content">
  772. <pre>editcap capture.pcapng exclude.pcapng 1 5 10-20 30-40</pre>
  773. </div>
  774. </div>
  775. <div class="paragraph">
  776. <p>To select just packets 1, 5, 10 to 20 and 30 to 40 for the new file use:</p>
  777. </div>
  778. <div class="literalblock">
  779. <div class="content">
  780. <pre>editcap -r capture.pcapng select.pcapng 1 5 10-20 30-40</pre>
  781. </div>
  782. </div>
  783. <div class="paragraph">
  784. <p>To remove duplicate packets seen within the prior four frames use:</p>
  785. </div>
  786. <div class="literalblock">
  787. <div class="content">
  788. <pre>editcap -d capture.pcapng dedup.pcapng</pre>
  789. </div>
  790. </div>
  791. <div class="paragraph">
  792. <p>To remove duplicate packets seen within the prior four frames while skipping radiotap headers use:</p>
  793. </div>
  794. <div class="literalblock">
  795. <div class="content">
  796. <pre>editcap -d --skip-radiotap-header capture.pcapng dedup.pcapng</pre>
  797. </div>
  798. </div>
  799. <div class="paragraph">
  800. <p>To remove duplicate packets seen within the prior 100 frames use:</p>
  801. </div>
  802. <div class="literalblock">
  803. <div class="content">
  804. <pre>editcap -D 101 capture.pcapng dedup.pcapng</pre>
  805. </div>
  806. </div>
  807. <div class="paragraph">
  808. <p>To remove duplicate packets seen <em>equal to or less than</em> 1/10th of a second:</p>
  809. </div>
  810. <div class="literalblock">
  811. <div class="content">
  812. <pre>editcap -w 0.1 capture.pcapng dedup.pcapng</pre>
  813. </div>
  814. </div>
  815. <div class="paragraph">
  816. <p>To display the MD5 hash for all of the packets (and NOT generate any
  817. real output file):</p>
  818. </div>
  819. <div class="literalblock">
  820. <div class="content">
  821. <pre>editcap -V -D 0 capture.pcapng /dev/null</pre>
  822. </div>
  823. </div>
  824. <div class="paragraph">
  825. <p>or on Windows systems</p>
  826. </div>
  827. <div class="literalblock">
  828. <div class="content">
  829. <pre>editcap -V -D 0 capture.pcapng NUL</pre>
  830. </div>
  831. </div>
  832. <div class="paragraph">
  833. <p>To advance the timestamps of each packet forward by 3.0827 seconds:</p>
  834. </div>
  835. <div class="literalblock">
  836. <div class="content">
  837. <pre>editcap -t 3.0827 capture.pcapng adjusted.pcapng</pre>
  838. </div>
  839. </div>
  840. <div class="paragraph">
  841. <p>To ensure all timestamps are in strict chronological order:</p>
  842. </div>
  843. <div class="literalblock">
  844. <div class="content">
  845. <pre>editcap -S 0 capture.pcapng adjusted.pcapng</pre>
  846. </div>
  847. </div>
  848. <div class="paragraph">
  849. <p>To introduce 5% random errors in a capture file use:</p>
  850. </div>
  851. <div class="literalblock">
  852. <div class="content">
  853. <pre>editcap -E 0.05 capture.pcapng capture_error.pcapng</pre>
  854. </div>
  855. </div>
  856. <div class="paragraph">
  857. <p>To remove vlan tags from all packets within an Ethernet-encapsulated capture
  858. file, use:</p>
  859. </div>
  860. <div class="literalblock">
  861. <div class="content">
  862. <pre>editcap -L -C 12:4 capture_vlan.pcapng capture_no_vlan.pcapng</pre>
  863. </div>
  864. </div>
  865. <div class="paragraph">
  866. <p>To chop both the 10 byte and 20 byte regions from the following 75 byte packet
  867. in a single pass, use any of the 8 possible methods provided below:</p>
  868. </div>
  869. <div class="literalblock">
  870. <div class="content">
  871. <pre>&lt;--------------------------- 75 ----------------------------&gt;</pre>
  872. </div>
  873. </div>
  874. <div class="literalblock">
  875. <div class="content">
  876. <pre>+---+-------+-----------+---------------+-------------------+
  877. | 5 | 10 | 15 | 20 | 25 |
  878. +---+-------+-----------+---------------+-------------------+</pre>
  879. </div>
  880. </div>
  881. <div class="literalblock">
  882. <div class="content">
  883. <pre>1) editcap -C 5:10 -C -25:-20 capture.pcapng chopped.pcapng
  884. 2) editcap -C 5:10 -C 50:-20 capture.pcapng chopped.pcapng
  885. 3) editcap -C -70:10 -C -25:-20 capture.pcapng chopped.pcapng
  886. 4) editcap -C -70:10 -C 50:-20 capture.pcapng chopped.pcapng
  887. 5) editcap -C 30:20 -C -60:-10 capture.pcapng chopped.pcapng
  888. 6) editcap -C 30:20 -C 15:-10 capture.pcapng chopped.pcapng
  889. 7) editcap -C -45:20 -C -60:-10 capture.pcapng chopped.pcapng
  890. 8) editcap -C -45:20 -C 15:-10 capture.pcapng chopped.pcapng</pre>
  891. </div>
  892. </div>
  893. <div class="paragraph">
  894. <p>To add comment strings to the first 2 input frames, use:</p>
  895. </div>
  896. <div class="literalblock">
  897. <div class="content">
  898. <pre>editcap -a "1:1st frame" -a 2:Second capture.pcapng capture-comments.pcapng</pre>
  899. </div>
  900. </div>
  901. </div>
  902. </div>
  903. <div class="sect1">
  904. <h2 id="_see_also">SEE ALSO</h2>
  905. <div class="sectionbody">
  906. <div class="paragraph">
  907. <p><a href="https://www.tcpdump.org/manpages/pcap.3pcap.html">pcap</a>(3), <a href="wireshark.html">wireshark</a>(1), <a href="tshark.html">tshark</a>(1), <a href="mergecap.html">mergecap</a>(1), <a href="dumpcap.html">dumpcap</a>(1), <a href="capinfos.html">capinfos</a>(1),
  908. <a href="text2pcap.html">text2pcap</a>(1), <a href="reordercap.html">reordercap</a>(1), od(1), <a href="https://www.tcpdump.org/manpages/pcap-filter.7.html">pcap-filter</a>(7) or <a href="https://www.tcpdump.org/manpages/tcpdump.1.html">tcpdump</a>(8)</p>
  909. </div>
  910. </div>
  911. </div>
  912. <div class="sect1">
  913. <h2 id="_notes">NOTES</h2>
  914. <div class="sectionbody">
  915. <div class="paragraph">
  916. <p>This is the manual page for <strong>Editcap</strong> 4.0.5.
  917. <strong>Editcap</strong> is part of the <strong>Wireshark</strong> distribution.
  918. The latest version of <strong>Wireshark</strong> can be found at <a href="https://www.wireshark.org" class="bare">https://www.wireshark.org</a>.</p>
  919. </div>
  920. <div class="paragraph">
  921. <p>HTML versions of the Wireshark project man pages are available at
  922. <a href="https://www.wireshark.org/docs/man-pages" class="bare">https://www.wireshark.org/docs/man-pages</a>.</p>
  923. </div>
  924. </div>
  925. </div>
  926. <div class="sect1">
  927. <h2 id="_authors">AUTHORS</h2>
  928. <div class="sectionbody">
  929. <div class="paragraph">
  930. <div class="title">Original Author</div>
  931. <p>Richard Sharpe &lt;sharpe[AT]ns.aus.com&gt;</p>
  932. </div>
  933. <div class="paragraph">
  934. <div class="title">Contributors</div>
  935. <p>Guy Harris &lt;guy[AT]alum.mit.edu&gt;<br>
  936. Ulf Lamping &lt;ulf.lamping[AT]web.de&gt;</p>
  937. </div>
  938. </div>
  939. </div>
  940. </div>
  941. </body>
  942. </html>