mergecap.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  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>mergecap(1)</title>
  9. <link rel="stylesheet" href="./ws.css">
  10. </head>
  11. <body class="manpage">
  12. <div id="header">
  13. <h1>mergecap(1) Manual Page</h1>
  14. <h2 id="_name">NAME</h2>
  15. <div class="sectionbody">
  16. <p>mergecap - Merges two or more capture files into one</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>mergecap</strong></span>
  25. <span class="nowrap">[ <strong>-a</strong> ]</span>
  26. <span class="nowrap">[ <strong>-F</strong> &lt;<em>file format</em>&gt; ]</span>
  27. <span class="nowrap">[ <strong>-I</strong> &lt;<em>IDB merge mode</em>&gt; ]</span>
  28. <span class="nowrap">[ <strong>-s</strong> &lt;<em>snaplen</em>&gt; ]</span>
  29. <span class="nowrap">[ <strong>-V</strong> ]</span>
  30. <span class="nowrap"><strong>-w</strong> &lt;<em>outfile</em>&gt;|-</span>
  31. <span class="nowrap">&lt;<em>infile</em>&gt; [&lt;<em>infile</em>&gt; <em>&#8230;&#8203;</em>]</span></p>
  32. </div>
  33. <div class="paragraph">
  34. <p><span class="nowrap"><strong>mergecap</strong></span>
  35. <span class="nowrap"><strong>-h|--help</strong></span></p>
  36. </div>
  37. <div class="paragraph">
  38. <p><span class="nowrap"><strong>mergecap</strong></span>
  39. <span class="nowrap"><strong>-v|--version</strong></span></p>
  40. </div>
  41. </div>
  42. </div>
  43. <div class="sect1">
  44. <h2 id="_description">DESCRIPTION</h2>
  45. <div class="sectionbody">
  46. <div class="paragraph">
  47. <p><strong>Mergecap</strong> is a program that combines multiple saved capture files into
  48. a single output file specified by the <strong>-w</strong> argument. <strong>Mergecap</strong> knows
  49. how to read <strong>pcap</strong> and <strong>pcapng</strong> capture files, including those of
  50. <strong>tcpdump</strong>, <strong>Wireshark</strong> and other tools that write captures in those
  51. formats.</p>
  52. </div>
  53. <div class="paragraph">
  54. <p>By default, <strong>Mergecap</strong> writes the capture file in <strong>pcapng</strong> format, and
  55. writes all of the packets from the input capture files to the output file.</p>
  56. </div>
  57. <div class="paragraph">
  58. <p><strong>Mergecap</strong> is able to detect, read and write the same capture files that
  59. are supported by <strong>Wireshark</strong>.
  60. The input files don&#8217;t need a specific filename extension; the file
  61. format and an optional gzip, zstd or lz4 compression will be automatically detected.
  62. Near the beginning of the DESCRIPTION section of <a href="wireshark.html">wireshark</a>(1) or
  63. <a href="https://www.wireshark.org/docs/man-pages/wireshark.html" class="bare">https://www.wireshark.org/docs/man-pages/wireshark.html</a>
  64. is a detailed description of the way <strong>Wireshark</strong> handles this, which is
  65. the same way <strong>Mergecap</strong> handles this.</p>
  66. </div>
  67. <div class="paragraph">
  68. <p><strong>Mergecap</strong> can write the file in several output formats.
  69. The <strong>-F</strong> flag can be used to specify the format in which to write the
  70. capture file, <strong>mergecap -F</strong> provides a list of the available output
  71. formats.</p>
  72. </div>
  73. <div class="paragraph">
  74. <p>Packets from the input files are merged in chronological order based on
  75. each frame&#8217;s timestamp, unless the <strong>-a</strong> flag is specified. <strong>Mergecap</strong>
  76. assumes that frames within a single capture file are already stored in
  77. chronological order. When the <strong>-a</strong> flag is specified, packets are
  78. copied directly from each input file to the output file, independent of
  79. each frame&#8217;s timestamp.</p>
  80. </div>
  81. <div class="paragraph">
  82. <p>The output file frame encapsulation type is set to the type of the input
  83. files if all input files have the same type. If not all of the input
  84. files have the same frame encapsulation type, the output file type is
  85. set to WTAP_ENCAP_PER_PACKET. Note that some capture file formats, most
  86. notably <strong>pcap</strong>, do not currently support WTAP_ENCAP_PER_PACKET.
  87. This combination will cause the output file creation to fail.</p>
  88. </div>
  89. </div>
  90. </div>
  91. <div class="sect1">
  92. <h2 id="_options">OPTIONS</h2>
  93. <div class="sectionbody">
  94. <div class="dlist">
  95. <dl>
  96. <dt class="hdlist1">-a</dt>
  97. <dd>
  98. <div class="openblock">
  99. <div class="content">
  100. <div class="paragraph">
  101. <p>Causes the frame timestamps to be ignored, writing all packets from the
  102. first input file followed by all packets from the second input file. By
  103. default, when <strong>-a</strong> is not specified, the contents of the input files
  104. are merged in chronological order based on each frame&#8217;s timestamp.</p>
  105. </div>
  106. <div class="paragraph">
  107. <p>Note: when merging, <strong>mergecap</strong> assumes that packets within a capture
  108. file are already in chronological order.</p>
  109. </div>
  110. </div>
  111. </div>
  112. </dd>
  113. <dt class="hdlist1">-F &lt;file format&gt;</dt>
  114. <dd>
  115. <div class="openblock">
  116. <div class="content">
  117. <div class="paragraph">
  118. <p>Sets the file format of the output capture file. <strong>Mergecap</strong> can write
  119. the file in several formats; <strong>mergecap -F</strong> provides a list of the
  120. available output formats. By default this is the <strong>pcapng</strong> format.</p>
  121. </div>
  122. </div>
  123. </div>
  124. </dd>
  125. <dt class="hdlist1">-h|--help</dt>
  126. <dd>
  127. <div class="openblock">
  128. <div class="content">
  129. <div class="paragraph">
  130. <p>Prints the version and options and exits.</p>
  131. </div>
  132. </div>
  133. </div>
  134. </dd>
  135. <dt class="hdlist1">-I &lt;IDB merge mode&gt;</dt>
  136. <dd>
  137. <div class="openblock">
  138. <div class="content">
  139. <div class="paragraph">
  140. <p>Sets the Interface Description Block (IDB) merge mode to use during merging.
  141. <strong>mergecap -I</strong> provides a list of the available IDB merge modes.</p>
  142. </div>
  143. <div class="paragraph">
  144. <p>Every input file has one or more IDBs, which describe the interface(s) the
  145. capture was performed on originally. This includes encapsulation type,
  146. interface name, etc. When mergecap merges multiple input files, it has to
  147. merge these IDBs somehow for the new merged output file. This flag controls
  148. how that is accomplished. The currently available modes are:</p>
  149. </div>
  150. <div class="paragraph">
  151. <p><strong>none</strong>: No merging of IDBs is performed, and instead all IDBs are
  152. copied to the merged output file.</p>
  153. </div>
  154. <div class="paragraph">
  155. <p><strong>all</strong>: IDBs are merged only if all input files have the same number
  156. of IDBs, and each IDB matches their respective entry in the
  157. other files. (Only the IDBs that occur at the beginning of the files,
  158. before any packet blocks, are compared. IDBs that occur later in the
  159. files are merged with duplicates iff the initial IDBs were merged.)
  160. This is the default mode.</p>
  161. </div>
  162. <div class="paragraph">
  163. <p><strong>any</strong>: Any and all duplicate IDBs are merged into one IDB, regardless
  164. of what file they are in.</p>
  165. </div>
  166. <div class="paragraph">
  167. <p>Note that an IDB is only considered a matching duplicate if it has the same
  168. encapsulation type, name, speed, time precision, comments, description, etc.</p>
  169. </div>
  170. </div>
  171. </div>
  172. </dd>
  173. <dt class="hdlist1">-s &lt;snaplen&gt;</dt>
  174. <dd>
  175. <div class="openblock">
  176. <div class="content">
  177. <div class="paragraph">
  178. <p>Sets the snapshot length to use when writing the data.
  179. If the <strong>-s</strong> flag is used to specify a snapshot length, frames in the
  180. input file with more captured data than the specified snapshot length
  181. will have only the amount of data specified by the snapshot length
  182. written to the output file. This may be useful if the program that is
  183. to read the output file cannot handle packets larger than a certain size
  184. (for example, the versions of snoop in Solaris 2.5.1 and Solaris 2.6
  185. appear to reject Ethernet frames larger than the standard Ethernet MTU,
  186. making them incapable of handling gigabit Ethernet captures if jumbo
  187. frames were used).</p>
  188. </div>
  189. </div>
  190. </div>
  191. </dd>
  192. <dt class="hdlist1">-v|--version</dt>
  193. <dd>
  194. <div class="openblock">
  195. <div class="content">
  196. <div class="paragraph">
  197. <p>Print the version and exit.</p>
  198. </div>
  199. </div>
  200. </div>
  201. </dd>
  202. <dt class="hdlist1">-V</dt>
  203. <dd>
  204. <div class="openblock">
  205. <div class="content">
  206. <div class="paragraph">
  207. <p>Causes <strong>mergecap</strong> to print a number of messages while it&#8217;s working.</p>
  208. </div>
  209. </div>
  210. </div>
  211. </dd>
  212. <dt class="hdlist1">-w &lt;outfile&gt;|-</dt>
  213. <dd>
  214. <div class="openblock">
  215. <div class="content">
  216. <div class="paragraph">
  217. <p>Sets the output filename. If the name is '<strong>-</strong>', stdout will be used.
  218. This setting is mandatory.</p>
  219. </div>
  220. </div>
  221. </div>
  222. </dd>
  223. </dl>
  224. </div>
  225. </div>
  226. </div>
  227. <div class="sect1">
  228. <h2 id="_diagnostic_options">DIAGNOSTIC OPTIONS</h2>
  229. <div class="sectionbody">
  230. <div class="dlist">
  231. <dl>
  232. <dt class="hdlist1">--log-level &lt;level&gt;</dt>
  233. <dd>
  234. <p>Set the active log level.
  235. Supported levels in lowest to highest order are "noisy", "debug", "info", "message", "warning", "critical", and "error".
  236. Messages at each level and higher will be printed, for example "warning" prints "warning", "critical", and "error" messages and "noisy" prints all messages.
  237. Levels are case insensitive.</p>
  238. </dd>
  239. <dt class="hdlist1">--log-fatal &lt;level&gt;</dt>
  240. <dd>
  241. <p>Abort the program if any messages are logged at the specified level or higher.
  242. For example, "warning" aborts on any "warning", "critical", or "error" messages.</p>
  243. </dd>
  244. </dl>
  245. </div>
  246. <div class="dlist">
  247. <dl>
  248. <dt class="hdlist1">--log-domains &lt;list&gt;</dt>
  249. <dd>
  250. <p>Only print messages for the specified log domains, e.g. "GUI,Epan,sshdump".
  251. List of domains must be comma-separated.</p>
  252. </dd>
  253. <dt class="hdlist1">--log-debug &lt;list&gt;</dt>
  254. <dd>
  255. <p>Force the specified domains to log at the "debug" level.
  256. List of domains must be comma-separated.</p>
  257. </dd>
  258. <dt class="hdlist1">--log-noisy &lt;list&gt;</dt>
  259. <dd>
  260. <p>Force the specified domains to log at the "noisy" level.
  261. List of domains must be comma-separated.</p>
  262. </dd>
  263. <dt class="hdlist1">--log-file &lt;path&gt;</dt>
  264. <dd>
  265. <p>Write log messages and stderr output to the specified file.</p>
  266. </dd>
  267. </dl>
  268. </div>
  269. </div>
  270. </div>
  271. <div class="sect1">
  272. <h2 id="_examples">EXAMPLES</h2>
  273. <div class="sectionbody">
  274. <div class="paragraph">
  275. <p>To merge two capture files together into a third capture file, in which
  276. the last packet of one file arrives 100 seconds before the first packet
  277. of another file, use the following sequence of commands.</p>
  278. </div>
  279. <div class="paragraph">
  280. <p>First, use:</p>
  281. </div>
  282. <div class="literalblock">
  283. <div class="content">
  284. <pre>capinfos -aeS a.pcap b.pcap</pre>
  285. </div>
  286. </div>
  287. <div class="paragraph">
  288. <p>to determine the start and end times of the two capture files, as
  289. seconds since January 1, 1970, 00:00:00 UTC.</p>
  290. </div>
  291. <div class="paragraph">
  292. <p>If a.pcap starts at 1009932757 and b.pcap ends at 873660281, then the
  293. time adjustment to b.pcap that would make it end 100 seconds before
  294. a.pcap begins would be 1009932757 - 873660281 - 100 = 136272376 seconds.</p>
  295. </div>
  296. <div class="paragraph">
  297. <p>Thus, the next step would be to use:</p>
  298. </div>
  299. <div class="literalblock">
  300. <div class="content">
  301. <pre>editcap -t 136272376 b.pcap b-shifted.pcap</pre>
  302. </div>
  303. </div>
  304. <div class="paragraph">
  305. <p>to generate a version of b.pcap with its time stamps shifted 136272376
  306. ahead.</p>
  307. </div>
  308. <div class="paragraph">
  309. <p>Then the final step would be to use :</p>
  310. </div>
  311. <div class="literalblock">
  312. <div class="content">
  313. <pre>mergecap -w compare.pcap a.pcap b-shifted.pcap</pre>
  314. </div>
  315. </div>
  316. <div class="paragraph">
  317. <p>to merge a.pcap and the shifted b.pcap into compare.pcap.</p>
  318. </div>
  319. </div>
  320. </div>
  321. <div class="sect1">
  322. <h2 id="_see_also">SEE ALSO</h2>
  323. <div class="sectionbody">
  324. <div class="paragraph">
  325. <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="dumpcap.html">dumpcap</a>(1), <a href="editcap.html">editcap</a>(1), <a href="text2pcap.html">text2pcap</a>(1),
  326. <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>
  327. </div>
  328. </div>
  329. </div>
  330. <div class="sect1">
  331. <h2 id="_notes">NOTES</h2>
  332. <div class="sectionbody">
  333. <div class="paragraph">
  334. <p><strong>Mergecap</strong> is based heavily upon <strong>editcap</strong> by Richard Sharpe
  335. &lt;sharpe[AT]ns.aus.com&gt; and Guy Harris &lt;guy[AT]alum.mit.edu&gt;.</p>
  336. </div>
  337. <div class="paragraph">
  338. <p>This is the manual page for <strong>Mergecap</strong> 4.0.5.
  339. <strong>Mergecap</strong> is part of the <strong>Wireshark</strong> distribution.
  340. 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>
  341. </div>
  342. <div class="paragraph">
  343. <p>HTML versions of the Wireshark project man pages are available at
  344. <a href="https://www.wireshark.org/docs/man-pages" class="bare">https://www.wireshark.org/docs/man-pages</a>.</p>
  345. </div>
  346. </div>
  347. </div>
  348. <div class="sect1">
  349. <h2 id="_authors">AUTHORS</h2>
  350. <div class="sectionbody">
  351. <div class="paragraph">
  352. <div class="title">Original Author</div>
  353. <p>Scott Renfro &lt;scott[AT]renfro.org&gt;</p>
  354. </div>
  355. <div class="paragraph">
  356. <div class="title">Contributors</div>
  357. <p>Bill Guyton &lt;guyton[AT]bguyton.com&gt;</p>
  358. </div>
  359. </div>
  360. </div>
  361. </div>
  362. </body>
  363. </html>