tcprewrite.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <!--#exec cmd="header tcprewrite" -->
  2. <ul>
  3. </ul><H2>NAME </H2><ul>
  4. tcprewrite - Rewrite the packets in a pcap file.
  5. </ul><H2>SYNOPSIS </H2><ul>
  6. <b>tcprewrite</b>
  7. [<b>-<i>flag</i></b> [<i>value</i>]]... [<b>--<i>opt-name</i></b> [[=| ]<i>value</i>]]...
  8. <p>
  9. All arguments must be options.
  10. </ul><H2>DESCRIPTION </H2><ul>
  11. This manual page documents, briefly, the <b>tcprewrite</b> command.
  12. Tcprewrite is a tool to rewrite packets stored in <i>pcap(3)</i> file format,
  13. such as crated by tools such as <i>tcpdump(1)</i> and <i>ethereal(1)</i>.
  14. Once a pcap file has had it's packets rewritten, they can be replayed back
  15. out on the network using <i>tcpreplay(1)</i>.
  16. <p>tcprewrite currently supports the following DLT types:
  17. * DLT_C_HDLC
  18. * DLT_EN10MB
  19. * DLT_LINUX_SSL
  20. * DLT_RAW
  21. <p>The packet editing features of tcprewrite which distinguish between "client"
  22. and "server" traffic requires a tcpprep(1) cache file.
  23. </ul><H2>OPTIONS </H2><ul>
  24. <p><dl compact><dt><b>-D</b> <i>string</i>, <b>--dmac</b>=<b><i>string</i></b>
  25. <dd>Rewrite destination MAC addresses.
  26. This option may appear up to 1 times.
  27. </dl>
  28. <p>
  29. Takes a pair of comma deliminated ethernet MAC addresses which
  30. will replace the destination MAC address of outbound packets.
  31. The first MAC address will be used for the server traffic
  32. and the optional second MAC address will be used for the client
  33. traffic.
  34. <p>Example:
  35. <pre>
  36. --dmac 00:12:13:14:15:16,00:22:33:44:55:66
  37. <br></pre>
  38. <p><dl compact><dt><b>-S</b> <i>string</i>, <b>--smac</b>=<b><i>string</i></b>
  39. <dd>Rewrite source MAC addresses.
  40. This option may appear up to 1 times.
  41. </dl>
  42. <p>
  43. Takes a pair of comma deliminated ethernet MAC addresses which
  44. will replace the source MAC address of outbound packets.
  45. The first MAC address will be used for the server traffic
  46. and the optional second MAC address will be used for the client traffic.
  47. <p>Example:
  48. <pre>
  49. --smac 00:12:13:14:15:16,00:22:33:44:55:66
  50. <br></pre>
  51. <p><dl compact><dt><b>-P</b> <i>number</i>, <b>--proto</b>=<b><i>number</i></b>
  52. <dd>Override L2 protocol type for DLT_RAW.
  53. This option may appear up to 1 times.
  54. This option takes an integer number as its argument.
  55. The value of <i>number</i> is constrained to being:
  56. <pre>
  57. in the range 0 through 65535
  58. <br></pre>
  59. </dl>
  60. <p>
  61. By default, pcap files encapsulated using DLT_RAW will have their protocol
  62. set to ETHERTYPE_IP (0x0800).
  63. <p><dl compact><dt><b>-l</b> <i>string</i>, <b>--dlink</b>=<b><i>string</i></b>
  64. <dd>Rewrite Data-Link layer with specified data.
  65. This option may appear up to 2 times.
  66. </dl>
  67. <p>
  68. Provide a series of comma deliminated hex values which will be
  69. used to rewrite or create the Layer 2 header of the packets.
  70. The first instance of this argument will rewrite both server
  71. and client traffic, but if this argument is specified a second
  72. time, it will be used for the client traffic.
  73. <p>Example:
  74. <pre>
  75. --dlink=01,02,03,04,05,06,00,1A,2B,3C,4D,5E,6F,08,00
  76. <br></pre>
  77. <p><dl compact><dt><b>-r</b> <i>string</i>, <b>--portmap</b>=<b><i>string</i></b>
  78. <dd>Rewrite TCP/UDP ports.
  79. This option may appear up to 1 times.
  80. </dl>
  81. <p>
  82. Specify a list of comma delimited port mappingings consisting of
  83. colon delimited port number pairs. Each colon delimited port pair
  84. consists of the port to match followed by the port number to rewrite.
  85. <p>Example:
  86. <pre>
  87. --portmap=80:8000,8080:80
  88. <br></pre>
  89. <p><dl compact><dt><b>-s</b> <i>number</i>, <b>--seed</b>=<b><i>number</i></b>
  90. <dd>Randomize src/dst IP addresses w/ given seed.
  91. This option may appear up to 1 times.
  92. This option takes an integer number as its argument.
  93. </dl>
  94. <p>
  95. Causes the source and destination IP addresses to be pseudo
  96. randomized but still maintain client/server relationships.
  97. Since the randomization is deterministic based on the seed,
  98. you can reuse the same seed value to recreate the traffic.
  99. <p><dl compact><dt><b>-N</b> <i>string</i>, <b>--pnat</b>=<b><i>string</i></b>
  100. <dd>Rewrite IP addresses using pseudo-NAT.
  101. This option may appear up to 2 times.
  102. </dl>
  103. <p>
  104. Takes a comma delimited series of colon delimited CIDR
  105. netblock pairs. Each netblock pair is evaluated in order against
  106. the IP addresses. If the IP address in the packet matches the
  107. first netblock, it is rewriten using the second netblock as a
  108. mask against the high order bits.
  109. <p>Example:
  110. <pre>
  111. --pnat=192.168.0.0/16:10.77.0.0/16,172.16.0.0/12:10.1.0.0/24
  112. <br></pre>
  113. <p><dl compact><dt><b>-e</b> <i>string</i>, <b>--endpoints</b>=<b><i>string</i></b>
  114. <dd>Rewrite IP addresses to be between two endpoints.
  115. This option may appear up to 1 times.
  116. </dl>
  117. <p>
  118. Takes a pair of colon delimited IP addresses which will be used to rewrite
  119. all traffic to appear to be between the two IP's.
  120. <p>Example:
  121. <pre>
  122. --endpoints=172.16.0.1:172.16.0.2
  123. <br></pre>
  124. <p><dl compact><dt><b>-C</b>, <b>--fixcsum</b>
  125. <dd>Force recalculation of IP/TCP/UDP checksums.
  126. </dl>
  127. <p>
  128. Causes each IP packet to have it's checksums recalcualted and
  129. fixed. Automatically enabled for packets modified with <b>--seed</b>,
  130. <b>--pnat</b>, <b>--endpoints</b> or <b>--fixlen</b>.
  131. <p><dl compact><dt><b>-m</b> <i>number</i>, <b>--mtu</b>=<b><i>number</i></b>
  132. <dd>Override default MTU length (1500 bytes).
  133. This option may appear up to 1 times.
  134. This option takes an integer number as its argument.
  135. The value of <i>number</i> is constrained to being:
  136. <pre>
  137. in the range 1 through MAXPACKET
  138. <br></pre>
  139. </dl>
  140. <p>
  141. Override the default 1500 byte MTU size for determining the maximum padding length.
  142. <p><dl compact><dt><b>-E</b>, <b>--efcs</b>
  143. <dd>Remove Ethernet checksums (FCS) from end of frames.
  144. </dl>
  145. <p>
  146. <p><p><dl compact><dt><b>-F</b> <i>string</i>, <b>--fixlen</b>=<b><i>string</i></b>
  147. <dd>Pad or truncate packet data to match header length.
  148. This option may appear up to 1 times.
  149. </dl>
  150. <p>
  151. Packets may be truncated during capture if the snaplen is smaller then the
  152. packet. This option allows you to modify the packet to pad the packet back
  153. out to the size stored in the IPv4 header or rewrite the IP header total length
  154. to reflect the stored packet length.
  155. <p>
  156. <b>pad</b>
  157. Truncated packets will be padded out so that the packet length matches the
  158. IPv4 total length
  159. <p>
  160. <b>trunc</b>
  161. Truncated packets will have their IPv4 total length field rewritten to match
  162. the actual packet length
  163. <p>
  164. <b>del</b>
  165. Delete the packet
  166. <p><dl compact><dt><b>-T</b> <i>string</i>, <b>--vlan</b>=<b><i>string</i></b>
  167. <dd>Specify 802.1q VLAN tag mode.
  168. This option may appear up to 1 times.
  169. </dl>
  170. <p>
  171. Allows you to rewrite ethernet frames to add a 802.1q header to standard 802.3
  172. ethernet headers or remove the 802.1q VLAN tag information.
  173. <p>
  174. <b>add</b>
  175. Rewrites the existing 802.3 ethernet header as an 802.1q VLAN header
  176. <p>
  177. <b>del</b>
  178. Rewrites the existing 802.1q VLAN header as an 802.3 ethernet header
  179. <p><dl compact><dt><b>-t</b> <i>number</i>, <b>--vlan-tag</b>=<b><i>number</i></b>
  180. <dd>Specify the new 802.1q VLAN tag value.
  181. This option may appear up to 1 times.
  182. This option must appear in combination with the following options:
  183. vlan.
  184. This option takes an integer number as its argument.
  185. The value of <i>number</i> is constrained to being:
  186. <pre>
  187. in the range 0 through 4095
  188. <br></pre>
  189. </dl>
  190. <p>
  191. <p><p><dl compact><dt><b>-f</b> <i>number</i>, <b>--vlan-cfi</b>=<b><i>number</i></b>
  192. <dd>Specify the 802.1q VLAN CFI value.
  193. This option may appear up to 1 times.
  194. This option must appear in combination with the following options:
  195. vlan.
  196. This option takes an integer number as its argument.
  197. The value of <i>number</i> is constrained to being:
  198. <pre>
  199. in the range 0 through 1
  200. <br></pre>
  201. </dl>
  202. <p>
  203. <p><p><dl compact><dt><b>-p</b> <i>number</i>, <b>--vlan-pri</b>=<b><i>number</i></b>
  204. <dd>Specify the 802.1q VLAN priority.
  205. This option may appear up to 1 times.
  206. This option must appear in combination with the following options:
  207. vlan.
  208. This option takes an integer number as its argument.
  209. The value of <i>number</i> is constrained to being:
  210. <pre>
  211. in the range 0 through 7
  212. <br></pre>
  213. </dl>
  214. <p>
  215. <p><p><dl compact><dt><b>-d</b> <i>number</i>, <b>--dbug</b>=<b><i>number</i></b>
  216. <dd>Enable debugging output.
  217. This option may appear up to 1 times.
  218. This option takes an integer number as its argument.
  219. The value of <i>number</i> is constrained to being:
  220. <pre>
  221. in the range 0 through 5
  222. <br></pre>
  223. The default <i>number</i> for this option is:
  224. </dl><br>
  225. 0
  226. <p>
  227. If configured with --enable-debug, then you can specify a verbosity
  228. level for debugging output. Higher numbers increase verbosity.
  229. <p><dl compact><dt><b>-i</b> <i>string</i>, <b>--infile</b>=<b><i>string</i></b>
  230. <dd>Input pcap file to be processed.
  231. This option may appear up to 1 times.
  232. </dl>
  233. <p>
  234. <p><p><dl compact><dt><b>-o</b> <i>string</i>, <b>--outfile</b>=<b><i>string</i></b>
  235. <dd>Output pcap file.
  236. This option may appear up to 1 times.
  237. </dl>
  238. <p>
  239. <p><p><dl compact><dt><b>-c</b> <i>string</i>, <b>--cachefile</b>=<b><i>string</i></b>
  240. <dd>Split traffic via tcpprep cache file.
  241. This option may appear up to 1 times.
  242. </dl>
  243. <p>
  244. Use tcpprep cache file to split traffic based upon client/server relationships.
  245. <p><dl compact><dt><b>-v</b>, <b>--verbose</b>
  246. <dd>Print decoded packets via tcpdump to STDOUT.
  247. This option may appear up to 1 times.
  248. </dl>
  249. <p>
  250. <p><p><dl compact><dt><b>-A</b> <i>string</i>, <b>--decode</b>=<b><i>string</i></b>
  251. <dd>Arguments passed to tcpdump decoder.
  252. This option may appear up to 1 times.
  253. This option must appear in combination with the following options:
  254. verbose.
  255. </dl>
  256. <p>
  257. When enabling verbose mode (<b>-v</b>) you may also specify one or
  258. more additional arguments to pass to <b>tcpdump</b> to modify
  259. the way packets are decoded. By default, -n and -l are used.
  260. Be sure to quote the arguments so that they are not interpreted
  261. by tcprewrite. The following arguments are valid:
  262. [ -aAeNqRStuvxX ]
  263. [ -E spi@ipaddr algo:secret,... ]
  264. [ -s snaplen ]
  265. <p><dl compact><dt><b>-V</b>, <b>--version</b>
  266. <dd>Print version information.
  267. </dl>
  268. <p>
  269. <p><p><dl compact><dt><b>-h</b>, <b>--less-help</b>
  270. <dd>Display less usage information and exit.
  271. </dl>
  272. <p>
  273. <p><p><dl compact><dt><b>-H</b>,<b> --help</b>
  274. <dd>Display usage information and exit.
  275. <dt><b>-!</b>,<b> --more-help</b>
  276. <dd>Extended usage information passed thru pager.
  277. <dt><b>-</b> [<i>rcfile</i>],<b> --save-opts</b>[=<i>rcfile</i>]
  278. <dd>Save the option state to <i>rcfile</i>. The default is the <i>last</i>
  279. configuration file listed in the <b>OPTION PRESETS</b> section, below.
  280. <dt><b>-</b> <i>rcfile</i>,<b> --load-opts</b>=<i>rcfile</i>,<b> --no-load-opts</b>
  281. <dd>Load options from <i>rcfile</i>.
  282. The <i>no-load-opts</i> form will disable the loading
  283. of earlier RC/INI files. <i>--no-load-opts</i> is handled early,
  284. out of order.
  285. </dl>
  286. </ul><H2>OPTION PRESETS </H2><ul>
  287. Any option that is not marked as <i>not presettable</i> may be preset
  288. by loading values from configuration ("RC" or ".INI") file(s).
  289. The <i>homerc</i> file is "<i>$$/</i>", unless that is a directory.
  290. In that case, the file "<i>.tcprewriterc</i>"
  291. is searched for within that directory.
  292. </ul><H2>SEE ALSO </H2><ul>
  293. tcpdump(1), tcpprep(1), tcpreplay(1)
  294. </ul><H2>AUTHOR </H2><ul>
  295. Copyright 2004-2005 Aaron Turner
  296. <p>For support please use the tcpreplay-users@lists.sourceforge.net mailing list.
  297. <p>
  298. Released under the Free BSD License.
  299. <p>
  300. This manual page was <i>AutoGen</i>-erated from the <b>tcprewrite</b>
  301. option definitions.
  302. </ul>
  303. <!--#exec cmd="trailer" -->