1
0

FAQ.tex 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355
  1. %% LyX 1.3 created this file. For more info, see http://www.lyx.org/.
  2. %% Do not edit unless you really know what you are doing.
  3. \documentclass[english]{article}
  4. \usepackage{times}
  5. \usepackage[T1]{fontenc}
  6. \usepackage[latin1]{inputenc}
  7. \usepackage{geometry}
  8. \geometry{verbose,letterpaper,tmargin=10mm,bmargin=15mm,lmargin=10mm,rmargin=10mm}
  9. \setcounter{secnumdepth}{4}
  10. \setlength\parskip{\medskipamount}
  11. \setlength\parindent{0pt}
  12. \usepackage{verbatim}
  13. \IfFileExists{url.sty}{\usepackage{url}}
  14. {\newcommand{\url}{\texttt}}
  15. \makeatletter
  16. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
  17. \newcommand{\noun}[1]{\textsc{#1}}
  18. %% Because html converters don't know tabularnewline
  19. \providecommand{\tabularnewline}{\\}
  20. \usepackage{babel}
  21. \makeatother
  22. \begin{document}
  23. \title{Tcpreplay 2.x FAQ}
  24. \author{Aaron Turner <aturner\_AT\_pobox.com> \\
  25. http://tcpreplay.sourceforge.net/}
  26. \date{Last Edited:\\
  27. Sept 6, 2004}
  28. \maketitle
  29. \newpage
  30. \tableofcontents{}
  31. \newpage
  32. \part{Before You Start}
  33. \section{General Info}
  34. \subsection{What is this FAQ for?}
  35. Tcpreplay is a suite of powerful tools, but with that power comes
  36. complexity. While I have done my best to write good man pages for
  37. tcpreplay and it's associated utilities, I understand that many people
  38. may want more information then I can provide in the man pages. Additionally,
  39. this FAQ attempts to cover material which I feel will be of use to
  40. people using tcpreplay, as well as common questions that occur on
  41. the Tcpreplay-Users <tcpreplay-users@lists.sourceforge.net> mailing
  42. list.
  43. \subsection{What tools come with tcpreplay?}
  44. \begin{itemize}
  45. \item tcpreplay - replay ethernet packets stored in a pcap file as they
  46. were captured
  47. \item tcpprep - a pcap pre-processor for tcpreplay
  48. \item flowreplay%
  49. \footnote{Flowreplay is still {}``alpha'' quality and is not usable for most
  50. situations. Anyone interested in helping me develop flowreplay is
  51. encouraged to contact me.%
  52. } - connects to a server(s) and replays the client side of the connection
  53. stored in a pcap file
  54. \item pcapmerge - merges two or more pcap files into one
  55. \item capinfo - displays basic information about a pcap file
  56. \end{itemize}
  57. \subsection{How can I get tcpreplay's source?}
  58. The source code is available in tarball format on the tcpreplay homepage:
  59. \url{http://tcpreplay.sourceforge.net/} I also encourage users familiar
  60. with CVS to try checking out the latest code as it often has additional
  61. features and bugfixes not found in the tarballs.
  62. cvs -d:pserver:anonymous@cvs.sf.net:/cvsroot/tcpreplay login\\
  63. Pass: \emph{<Enter>}\\
  64. cvs -z3 -d:pserver:anonymous@cvs.sf.net:/cvsroot/tcpreplay co tcpreplay
  65. \subsection{What requirements does tcpreplay have?}
  66. \begin{enumerate}
  67. \item You'll need the libnet and libpcap libraries.
  68. \item To support the jump to offset feature, you'll need the libpcapnav%
  69. \footnote{http://netdude.sourceforge.net/%
  70. } library.
  71. \item To support the packet decoding feature you'll need tcpdump%
  72. \footnote{http://www.tcpdump.org/%
  73. } installed.
  74. \item You'll also need a compatible operating system. Basically, any UNIX-like
  75. or UNIX-based operating system should work. Linux, {*}BSD, Solaris,
  76. OS X and others should all work. If you find any compatibility issues
  77. with any UNIX-like/based OS, please let me know.
  78. \end{enumerate}
  79. \subsection{How do I compile tcpreplay?}
  80. Two easy steps:
  81. \begin{enumerate}
  82. \item As a normal user: \emph{./configure \&\& make}
  83. \item As root: \emph{make test -i \&\& make install}
  84. \end{enumerate}
  85. There are some optional arguments which can be passed to the configure
  86. script which may help in cases where your libnet, libpcap, libpcapnav
  87. or tcpdump installation is not standard or if it can't determine the
  88. correct network interface card to use for testing. If you find that
  89. configure isn't completing correctly, run: \emph{./configure --help}
  90. for more information.
  91. A few comments about 'make test':
  92. \begin{itemize}
  93. \item make test is just a series of sanity checks which try to find serious
  94. bugs (crashes) in tcpprep and tcpreplay.
  95. \item make test requires at least one properly configured network interface.
  96. If the configure script can't guess what a valid interface is you
  97. can specify it with the --with-testnic and --with-testnic2 arguments.
  98. \item If make test fails, often you can find details in test/test.log.
  99. \item OpenBSD's make has a bug where it ignores the MAKEFLAGS variable in
  100. the Makefile, hence you'll probably want to run: \emph{make -is test}
  101. instead.
  102. \end{itemize}
  103. \subsection{Are there binaries available?}
  104. Occasionally. And even when we do, generally only for one or two operating
  105. systems. Generally speaking, we assume people who want to use a tool
  106. like this can figure out how to compile it.
  107. \subsection{Is there a Microsoft Windows port?}
  108. Not really. We had one user port the code over for a slightly old
  109. version of tcpreplay to Windows. Now we're looking for someone to
  110. help merge and maintain the code in to the main development tree.
  111. If you're interested in helping with this please contact Aaron Turner
  112. or the tcpreplay-users list.
  113. \subsection{How is tcpreplay licensed?}
  114. Tcpreplay is licensed under a BSD-style license. For details, see
  115. Appendix A.
  116. \subsection{What is tcpreplay?}
  117. In the simplest terms, tcpreplay is a tool to send network traffic
  118. stored in pcap format back onto the network; basically the exact opposite
  119. of tcpdump. Tcpreplay also has the ability to edit various packet
  120. headers as the packets are sent. Tcpreplay is also a suite of tools:
  121. tcpreplay, tcpprep, pcapmerge, capinfo and flowreplay.
  122. \subsection{What isn't tcpreplay?}
  123. Tcpreplay is \emph{not} a tool to replay captured traffic to a server
  124. or client. Specifically, tcpreplay does not have the ability to rewrite
  125. IP addresses to a user-specified value or synchronize TCP sequence
  126. and acknowledgment numbers. In other words, tcpreplay can't {}``connect''
  127. to a server or be used to emulate a server and have clients connect
  128. to it. If you're looking for that, check out flowreplay.
  129. \subsection{What are some uses for tcpreplay?}
  130. Originally, tcpreplay was written to test network intrusion detection
  131. systems (NIDS), however tcpreplay has been used to test firewalls,
  132. routers, and other network devices.
  133. \subsection{What are some uses for flowreplay?}
  134. A lot of people wanted a tool like tcpreplay, but wanted to be able
  135. to replay traffic \emph{to} a server. Since tcpreplay was unable to
  136. do this, I developed flowreplay which replays the data portion of
  137. the flow, but recreates the connection to the specified server(s).
  138. This makes flowreplay an ideal tool to test host intrusion detection
  139. systems (HIDS) as well as captured exploits and security patches when
  140. the actual exploit code is not available. Please note that flowreplay
  141. is still alpha quality code and is currently missing some important
  142. features.
  143. \subsection{What happened to version 1.5?}
  144. After looking at all the changes that have happened over the last
  145. year or so, I decided that it was finally time to graduate tcpreplay
  146. to 2.0 status. Hence the 1.5 branch was renamed 2.0.
  147. \subsection{What is the history of tcpreplay?}
  148. Tcpreplay has had quite a few authors over the past five or so years.
  149. One of the advantages of the BSD and GPL licenses is that if someone
  150. becomes unable or unwilling to continue development, anyone else can
  151. take over.
  152. Originally, Matt Undy of Anzen Computing wrote tcpreplay. Matt released
  153. version 1.0.1 sometime in 1999. Sometime after that, Anzen Computing
  154. was (at least partially) purchased by NFR and development ceased.
  155. Then in 2001, two people independently started work on tcpreplay:
  156. Matt Bing of NFR and Aaron Turner. After developing a series of patches
  157. (the -adt branch), Aaron attempted to send the patches in to be included
  158. in the main development tree.
  159. After some discussion between Aaron and Matt Bing, they decided to
  160. continue development together. Since then, over a dozen stable releases
  161. have been made and more then twenty new features have been added,
  162. including the addition of a number of accessory tools.
  163. Today, Aaron continues active development of the code.
  164. \section{Bugs, Feature Requests, and Patches}
  165. \subsection{Where can I get help, report bugs or contact the developers?}
  166. The best place to get help or report a bug is the Tcpreplay-Users
  167. mailing list: \\
  168. \url{http://lists.sourceforge.net/lists/listinfo/tcpreplay-users}
  169. \subsection{What information should I provide when I report a bug?}
  170. One of the most frustrating things for any developer trying to help
  171. a user with a problem is not enough information. Please be sure to
  172. include \emph{at minimum} the following information, however any additional
  173. information you feel may be helpful will be appreciated.
  174. \begin{itemize}
  175. \item Version information (output of -V)
  176. \item Command line used (options and arguments)
  177. \item Platform (Red Hat Linux 9 on Intel, Solaris 7 on SPARC, etc)
  178. \item Error message (if available) and/or description of problem
  179. \item If possible, attach the pcap file used (compressed with bzip2 or gzip
  180. preferred)
  181. \end{itemize}
  182. \subsection{I have a feature request, what should I do?}
  183. Let us know! Many of the features exist today because users like you
  184. asked for them. To make a feature request, you can either email the
  185. tcpreplay-users mailing list (see above) or fill out the feature request
  186. form on the tcpreplay SourceForge website.
  187. \subsection{I've written a patch for tcpreplay, how can I submit it?}
  188. I'm always willing to include new features or bug fixes submitted
  189. by users. You may email me directly or the tcpreplay-users mailing
  190. list. Please \emph{do not} use the Patch Tracker on the tcpreplay
  191. SourceForge web site.
  192. \subsection{Patch requirements}
  193. \begin{itemize}
  194. \item Be aware that submitting a patch, \emph{you are licensing it under
  195. the BSD License} as written in Appendix A. If this is not acceptable
  196. to you, then \emph{do not} send me the patch!
  197. \item If you wish to maintain the copyright over your code, be sure that
  198. your patch contains the appropriate information.
  199. \item Please provide a description of what your patch does!
  200. \item Comment your code! I won't use code I can't understand.
  201. \item Make sure you are patching a branch that is still being maintained.
  202. Generally that means that most recent stable and development branches
  203. (1.4 and 2.0 at the time of this writing).
  204. \item Make sure you are patching against the most recent release for that
  205. branch.
  206. \item Please submit your patch in the unified diff format so I can better
  207. understand what you're changing.
  208. \item Please provide any relevant personal information you'd like listed
  209. in the CREDITS file.
  210. \end{itemize}
  211. Please note that while I'm always interested in patches, I may rewrite
  212. some or all of your submission to maintain a consistent coding style.
  213. \part{Basics}
  214. \section{Basic Tcpreplay Usage}
  215. \subsection{Replaying the traffic}
  216. To replay a given pcap as it was captured all you need to do is specify
  217. the pcap file and the interface to send the traffic out of:
  218. \emph{tcpreplay -i eth0 sample.pcap}
  219. \subsection{Replaying at different speeds}
  220. You can also replay the traffic at different speeds then it was originally
  221. captured%
  222. \footnote{Tcpreplay makes a \char`\"{}best\char`\"{} effort to replay traffic
  223. at the given rate, but due to limitations in hardware or the pcap
  224. file itself, it may not be possible. Capture files with only a few
  225. packets in them are especially susceptible to this.%
  226. }. To support this, tcpreplay supports four different flags: -R, -r,
  227. -m, and -p
  228. Some examples:
  229. \begin{itemize}
  230. \item To replay traffic as fast as possible:\\
  231. \emph{tcpreplay -R -i eth0 sample.pcap}
  232. \item To replay traffic at 10Mbps:\\
  233. \emph{tcpreplay -r 10.0 -i eth0 sample.pcap}
  234. \item To replay traffic 7.3 times as fast as it was captured:\\
  235. \emph{tcpreplay -m 7.3 -i eth0 sample.pcap}
  236. \item To replay traffic at half-speed:\\
  237. \emph{tcpreplay -m 0.5 -i eth0 sample.pcap}
  238. \item To replay at 25.5 packets per second:\\
  239. \emph{tcpreplay -p 25.5 -i eth0 sample.pcap}
  240. \end{itemize}
  241. \subsection{Replaying the same file over and over again}
  242. Using the loop flag (-l) you can specify that a pcap file will be
  243. sent two or more times%
  244. \footnote{Looping files resets internal counters which control the speed that
  245. the file is replayed. Also because the file has to be closed and re-opened,
  246. an added delay between the last and first packet may occur.%
  247. }:
  248. \begin{itemize}
  249. \item To replay the sample.pcap file 10 times:\\
  250. \emph{tcpreplay -l 10 -i eth0 sample.pcap}
  251. \item To replay the sample.pcap an infinitely or until CTRL-C is pressed:\\
  252. \emph{tcpreplay -l 0 -i eth0 sample.pcap}
  253. \end{itemize}
  254. \subsection{Using Configuration Files}
  255. Tcpreplay offers the options of specifying configuration options in
  256. a config file in addition to the traditional command line. Each configuration
  257. option has an equivalent config file option which is listed in the
  258. tcpreplay man page. To specify the configuration file you'd like to
  259. use, use the -f <filename> option.
  260. Configuration files have one option per line, and lines beginning
  261. with the pound sign (\#) are considered comments and ignored. An example
  262. config file follows:
  263. \# send traffic out 'eth0'\\
  264. intf eth0\\
  265. \\
  266. \# loop 5 times\\
  267. loop 5\\
  268. \\
  269. \# send traffic 2x as fast\\
  270. multiplier 2\\
  271. \\
  272. \# pad any packets out to their original size if they were truncated
  273. during capture\\
  274. untruncate pad\\
  275. \\
  276. \\
  277. You would then execute:\\
  278. \emph{tcpreplay -f myconfigfile sample.pcap}
  279. \part{Advanced Usage}
  280. \section{Output: Interfaces, Packets \& Files}
  281. \subsection{Replaying on multiple interfaces}
  282. Tcpreplay can also split traffic so that each side of a connection
  283. is sent out a different interface%
  284. \footnote{Note that you can also use the following options to split traffic
  285. into two files using -w and -W which are described later on in this
  286. FAQ.%
  287. }. In order to do this, tcpreplay needs the name of the second interface
  288. (-j) and a way to split the traffic. Currently, there are two ways
  289. to split traffic:
  290. \begin{enumerate}
  291. \item -C = split traffic by source IP address which is specified in CIDR
  292. notation
  293. \item -c = split traffic according to a tcpprep cachefile%
  294. \footnote{For information on generating tcpprep cache files, see the section
  295. on tcpprep.%
  296. }
  297. \end{enumerate}
  298. When splitting traffic, it is important to remember that traffic that
  299. matches the filter is sent out the primary interface (-i). In this
  300. case, when splitting traffic by source IP address, you provide a list
  301. of networks in CIDR notation. For example:
  302. \begin{itemize}
  303. \item To send traffic from 10.0.0.0/8 out eth0 and everything else out eth1:\\
  304. \emph{tcpreplay -C 10.0.0.0/8 -i eth0 -j eth1 sample.pcap}
  305. \item To send traffic from 10.1.0.0/24 and 10.2.0.0/20 out eth0 and everything
  306. else out eth1:\\
  307. \emph{tcpreplay -C 10.1.0.0/24,10.2.0.0/20 -i eth0 -j eth1 sample.pcap}
  308. \item After using tcpprep to generate a cache file, you can use it to split
  309. traffic between two interfaces like this:\\
  310. \emph{tcpreplay -c sample.cache -i eth0 -j eth1 sample.pcap}
  311. \end{itemize}
  312. \subsection{Selectively sending or dropping packets}
  313. Sometimes, you want to do some post-capture filtering of packets.
  314. Tcpreplay let's you have some control over which packets get sent.
  315. \begin{enumerate}
  316. \item -M = disables sending of martian packets. By definition, martian packets
  317. have a source IP of 0.x.x.x, 127.x.x.x, or 255.x.x.x
  318. \item -x = send packets which match a specific pattern
  319. \item -X = send packets which do not match a specific pattern
  320. \end{enumerate}
  321. Both -x and -X support a variety of pattern matching types. These
  322. types are specified by a single character, followed by a colon, followed
  323. by the pattern. The following pattern matching types are available:
  324. \begin{enumerate}
  325. \item S - Source IP\\
  326. Pattern is a comma delimited CIDR notation
  327. \item D - Destination IP\\
  328. Pattern is a comma delimited CIDR notation
  329. \item B - Both source and destination IP must match\\
  330. Pattern is a comma delimited CIDR notation
  331. \item E - Either source or destination IP must match\\
  332. Pattern is a comma delimited CIDR notation
  333. \item P - A list of packet numbers from the pcap file.\\
  334. Pattern is a series of numbers, separated by commas or dashes.
  335. \item F - BPF syntax (same as used in tcpdump).\\
  336. Filter must be quoted and is only supported with -x%
  337. \footnote{Note that if you want to send all the packets which do not match a
  338. bpf filter, all you have to do is negate the bpf filter. See the tcpdump(1)
  339. man page for more info.%
  340. }.
  341. \end{enumerate}
  342. Examples:
  343. \begin{itemize}
  344. \item To only send traffic that is too and from a host in 10.0.0.0/8:\\
  345. \emph{tcpreplay -x B:10.0.0.0/8 -i eth0 sample.pcap}
  346. \item To not send traffic that is too or from a host in 10.0.0.0/8:\\
  347. \emph{tcpreplay -X E:10.0.0.0/8 -i eth0 sample.pcap}
  348. \item To send every packet except the first 10 packets:\\
  349. \emph{tcpreplay -X P:1-10 -i eth0 sample.pcap}
  350. \item To only send the first 50 packets followed by packets: 100, 150, 200
  351. and 250:\\
  352. \emph{tcpreplay -x P:1-50,100,150,200,250 -i eth0 sample.pcap}
  353. \item To only send TCP packets from 10.0.0.1:\\
  354. tcpreplay -x F:'tcp and host 10.0.0.1' -i eth0 sample.pcap
  355. \end{itemize}
  356. \subsection{Replaying only a few packets}
  357. Using the limit packets flag (-L) you can specify that tcpreplay will
  358. only send at most a specified number of packets.
  359. \begin{itemize}
  360. \item To send at most 100 packets:\\
  361. \emph{tcpreplay -i eth0 -L 100 sample.pcap}
  362. \end{itemize}
  363. \subsection{Skipping the first bytes in a pcap file}
  364. If you want to skip the beginning of a pcap file, you can use the
  365. offset flag (-o) to skip a specified number of bytes and start sending
  366. on the next packet.
  367. \begin{itemize}
  368. \item To skip 15Kb into the pcap file and start sending packets from there:\\
  369. \emph{tcpreplay -i eth0 -o 15000 sample.pcap}
  370. \end{itemize}
  371. \subsection{Replaying packets which are bigger then the MTU}
  372. Occasionally, you might find yourself trying to replay a pcap file
  373. which contains packets which are larger then the MTU for the sending
  374. interface. This might be due to the packets being captured on the
  375. loopback interface or on a 1000Mbps ethernet interface supporting
  376. {}``jumbo frames''. I've even seen packets which are 1500 bytes
  377. but contain both an ethernet header and trailer which bumps the total
  378. frame size to 1518 which is 4 bytes too large.
  379. By default, tcpreplay will skip these packets and not send them. Alternatively,
  380. you can specify the -T flag to truncate these packets to the MTU and
  381. then send them. Of course this may invalidate your testing, but it
  382. has proven useful in certain situations. Also, when this feature is
  383. enabled, tcpreplay will automatically recalculate the IP and TCP,
  384. UDP or ICMP checksums as needed. Example:
  385. \emph{tcpreplay -i eth0 -T sample.pcap}
  386. \subsection{Writing packets to a file}
  387. It's not always necessary to write packets to the network. Since tcpreplay
  388. has so many features which modify and select which packets are sent,
  389. it is occasionally useful to save these changes to another pcap file
  390. for comparison. Rather then running a separate tcpdump process to
  391. capture the packets, tcpreplay now supports output directly to a file.
  392. Example:
  393. \emph{tcpreplay -i eth0 -w output.pcap -F -u pad -x E:10.0.0.0/8 input1.pcap
  394. input2.pcap input3.pcap}
  395. Notice that specifying an interface is still required (required for
  396. various internal functions), but all the packets will be written to
  397. \emph{output.pcap}.
  398. You can also split traffic into two files by using -W <2nd output
  399. file>.
  400. \subsection{Extracting Application Data (Layer 7)}
  401. New to version 2.0 is the ability to extract the application layer
  402. data from the packets and write them to a file. In the man page, we
  403. call this {}``data dump mode'' which is enabled with -D. It's important
  404. to specify -D before -w (and -W if you're splitting data into two
  405. files). Example:
  406. \emph{tcpreplay -D -i eth0 -j eth0 -w clientdata -W serverdata -C
  407. 10.0.0.0/24 sample.pcap}
  408. \subsection{Replaying Live Traffic}
  409. You can now replay live traffic sniffed on one network interface and
  410. replay it on another interface using the -S flag to indicate sniff
  411. mode and the appropriate snaplen in bytes (0 denotes the entire packet).
  412. You can also enabling bi-directional traffic using the bridge mode
  413. flag: -b.
  414. N\noun{ote:} It is critical for your sanity (and to prevent your
  415. murder by your network administrators) that the input interface and
  416. the output interface be on separate networks and additionally that
  417. no other network devices (such as bridges, switches, routers, etc)
  418. be connecting the two networks, else you will surely get a networkstorm
  419. the likes that have not been seen for years.
  420. \begin{itemize}
  421. \item Send packets sniffed on eth0 out eth1:\\
  422. \emph{tcpreplay -i eth1 -S 0 eth0}
  423. \item Bridge two subnets connected to eth0 and eth1:\\
  424. \emph{tcpreplay -i eth0 -j eth1 -b -S 0}
  425. \end{itemize}
  426. By default, tcpreplay listens in promiscuous mode on the specified
  427. interface, however if you only want to send unicasts directed for
  428. the local system and broadcasts, you can specify the {}``not\_nosy''
  429. option in the configuration file or -n on the command line. Note that
  430. if another program has already placed the interface in promiscuous
  431. mode, the -n flag will have no effect, so you may want to use the
  432. -x or -X argument to limit packets.
  433. \subsection{Replaying Packet Capture Formats Other Than Libpcap}
  434. There are about as many different capture file formats as there are
  435. sniffers. In the interest of simplicity, tcpreplay only supports libpcap%
  436. \footnote{Note that some versions of tcpreplay prior to 1.4 also supported the
  437. Solaris snoop format.%
  438. }. If you would like to replay a file in one of these multitude of
  439. formats, the excellent open source tool Ethereal easily allows you
  440. to convert it to libpcap. For instance, to convert a file in Sun's
  441. snoop format to libpcap, issue the command:
  442. \emph{tethereal -r blah.snoop -w blah.pcap}
  443. and replay the resulting file.
  444. \subsection{Replaying Client Traffic to a Server}
  445. A common question on the tcpreplay-users list is how does one replay
  446. the client side of a connection back to a server. Unfortunately, tcpreplay
  447. doesn't support this right now. The major problem concerns syncing
  448. up TCP Seq/Ack numbers which will be different. ICMP also often contains
  449. IP header information which would need to be adjusted. About the only
  450. thing that could be easy to do is UDP, which isn't usually requested.
  451. This is however a feature that we're looking into implementing in
  452. the flowreplay utility. If you're interested in helping work on this
  453. feature, please contact us and we'd be more then happy to work with
  454. you. At this time however, we don't have an ETA when this will be
  455. implemented, so don't bother asking.
  456. \subsection{Decoding Packets}
  457. If the tcpdump binary is installed on your system when tcpreplay is
  458. compiled, it will allow you to decode packets as they are sent without
  459. running tcpdump in a separate window or worrying about it capturing
  460. packets which weren't sent by tcpreplay.
  461. \begin{itemize}
  462. \item Decode packets as they are sent:\\
  463. \emph{tcpreplay -i eth0 -v sample.pcap}
  464. \item Decode packets with the link level header:\\
  465. \emph{tcpreplay -i eth0 -v -A {}``-e'' sample.pcap}
  466. \item Fully decode and send one packet at a time:\\
  467. \emph{tcpreplay -i eth0 -v -1 -A {}``-s0 -evvvxX'' sample.pcap}
  468. \end{itemize}
  469. Note that tcpreplay automatically applies the -n flag to disable DNS
  470. lookups which would slow down tcpdump too much to make it effective.
  471. \section{Packet Editing}
  472. \subsection{Rewriting MAC addresses}
  473. If you ever want to send traffic to another device on a switched LAN,
  474. you may need to change the destination MAC address of the packets.
  475. Tcpreplay allows you to set the destination MAC for each interface
  476. independently using the -I and -J switches. As of version 2.1.0, you
  477. can also specify the source MAC via -k and -K. Example:
  478. \begin{itemize}
  479. \item To send traffic out eth0 with a destination MAC of your router (00:00:01:02:03:04)
  480. and the source MAC of the server (00:20:30:40:50:60):\\
  481. \emph{tcpreplay -i eth0 -I 00:00:01:02:03:04 -k 00:20:30:40:50:60
  482. sample.pcap}
  483. \item To split traffic between internal (10.0.0.0/24) and external addresses
  484. and to send that traffic to the two interfaces of a firewall:\\
  485. \emph{tcpreplay -i eth0 -j eth1 -I 00:01:00:00:AA:01 -J 00:01:00:00:AA:02
  486. -C 10.0.0.0/24 sample.pcap}
  487. \end{itemize}
  488. \subsection{Randomizing IP addresses}
  489. Occasionally, it is necessary to have tcpreplay rewrite the source
  490. and destination IP addresses, yet maintain the client/server relationship.
  491. Such a case might be having multiple copies of tcpreplay running at
  492. the same time using the same pcap file while trying to stress test
  493. firewall, IDS or other stateful device. If you didn't change the source
  494. and destination IP addresses, the device under test would get confused
  495. since it would see multiple copies of the same connection occurring
  496. at the same time. In order to accomplish this, tcpreplay accepts a
  497. user specified seed which is used to generate pseudo-random IP addresses.
  498. Also, when this feature is enabled, tcpreplay will automatically recalculate
  499. the IP and TCP, UDP or ICMP checksums as needed. Example:
  500. \emph{tcpreplay -i eth0 -s 1239 sample.pcap \&}\\
  501. \emph{tcpreplay -i eth0 -s 76 sample.pcap \&}\\
  502. \emph{tcpreplay -i eth0 -s 239 sample.pcap \&}\\
  503. \emph{tcpreplay -i eth0 sample.pcap}
  504. \subsection{Replaying (de)truncated packets}
  505. Occasionally, it is necessary to replay traffic which has been truncated
  506. by tcpdump. This occurs when the tcpdump snaplen is smaller then the
  507. actual packet size. Since this will create problems for devices which
  508. are expecting a full-sized packet or attempting checksum calculations,
  509. tcpreplay allows you to either pad the packet with zeros or reset
  510. the packet length in the headers to the actual packet size. In either
  511. case, the IP and TCP, UDP or ICMP checksums are recalculated. Examples:
  512. \begin{itemize}
  513. \item Pad truncated packets:\\
  514. \emph{tcpreplay -i eth0 -u pad sample.pcap}
  515. \item Rewrite packet header lengths to the actual packet size:\\
  516. \emph{tcpreplay -i eth0 -u trunc sample.pcap}
  517. \end{itemize}
  518. \subsection{Rewriting Layer 2 with -2}
  519. Starting in the 2.0.x branch, tcpreplay can replace the existing layer
  520. 2 header with one of your choosing. This is useful for when you want
  521. to change the layer 2 header type or add a header for pcap files without
  522. one. Each pcap file tells the type of frame. Currently tcpreplay knows
  523. how to deal with the following pcap(3) frame types:
  524. \begin{itemize}
  525. \item DLT\_EN10MB\\
  526. Replace existing 802.3/Ethernet II header
  527. \item DLT\_RAW\\
  528. Frame has no Layer 2 header, so we can add one.
  529. \item DLT\_LINUX\_SLL\\
  530. Frame uses the Linux Cooked Socket header which is most commonly created
  531. with \emph{tcpdump -i any} on a Linux system.
  532. \end{itemize}
  533. Tcpreplay accepts the new Layer 2 header as a string of comma separated
  534. hex values such as: 0xff,0xac,0x00,0x01,0xc0,0x64. Note that the leading
  535. '0x' is \emph{not} required.
  536. Potential uses for this are to add a layer 2 header for DLT\_RAW captures
  537. or add/remove ethernet tags or QoS features.
  538. \subsection{Rewriting DLT\_LINUX\_SLL (Linux Cooked Socket) captures}
  539. Tcpdump uses a special frame type to store captures created with the
  540. {}``-i any'' argument. This frame type uses a custom 16 byte layer
  541. 2 header which tracks which interface captured the packet and often
  542. the source MAC address of the original ethernet frame. Unfortunately,
  543. it never stores the destination MAC address and it doesn't store a
  544. source MAC when the packet is captured on the loopback interface.
  545. Normally, tcpreplay can't replay these pcap files because there isn't
  546. enough information in the LINUX\_SLL header to do so; however two
  547. options do exist:
  548. \begin{enumerate}
  549. \item You can send these packets with -2 which will replace the LINUX\_SLL
  550. header with an ethernet header of your choosing.
  551. \item You can specify a destination MAC via -I and -J in which case tcpreplay
  552. will use the stored source MAC and create a new 802.3 Ethernet header.
  553. Note that if the pcap contains loopback packets, you will also need
  554. to specify -k and/or -K to specify the source MAC as well or they
  555. will be skipped.
  556. \end{enumerate}
  557. \subsection{Rewriting IP Addresses (pseudo-NAT)}
  558. Pseudo-NAT allows the mapping of IP addresses in IPv4 and ARP packets
  559. from one subnet to another subnet of the same or different size. This
  560. allows some or all the traffic sent to appear to come from a different
  561. IP subnet then it actually was captured on.
  562. The mapping is done through a user specified translation table comprised
  563. of one or more source and destination network(s) in the format of
  564. <srcnet>/<masklen>:<dstnet>/<masklen> deliminated by a comma. Mapping
  565. is done by matching IP addresses to the source subnet and rewriting
  566. the most significant bits with the destination subnet. For example:
  567. \emph{tcpreplay -i eth0 -N 10.100.0.0/16:172.16.10.0/24 sample.pcap}
  568. would match any IP in the 10.100.0.0/16 subnet and rewrite it as if
  569. it came from or sent to the 172.16.10.0/24 subnet. Ie: 10.100.5.88
  570. would become 172.16.10.88 and 10.100.99.45 would become 172.16.10.45.
  571. But 10.150.7.44 would not be rewritten.
  572. For any given IP address, the translation table is applied in order
  573. (so if there are multiple mappings, earlier maps take precedence)
  574. and occurs only once per IP (no risk of an address getting rewritten
  575. a second time).
  576. \subsection{Advanced pseudo-NAT}
  577. Pseudo-NAT also works with traffic splitting (using two interfaces
  578. or output files) but with a few important differences. First you have
  579. the option of specifying one or two pseudo-NAT tables. Using a single
  580. pseudo-NAT table means that the source and destination IP addresses
  581. of both interfaces are rewritten using the same rules. Using two pseudo-NAT
  582. tables (specifying -N <Table1> -N <Table2>) will cause the source
  583. and destination IP addresses to be rewritten differently for each
  584. interface using the following matrix:
  585. \begin{center}\begin{tabular}{|c|c|c|}
  586. \hline
  587. &
  588. Out Primary Interface&
  589. Out Secondary Interface\tabularnewline
  590. \hline
  591. \hline
  592. Src IP&
  593. Table 1&
  594. Table 2\tabularnewline
  595. \hline
  596. Dest IP&
  597. Table 2&
  598. Table 1\tabularnewline
  599. \hline
  600. \end{tabular}\end{center}
  601. While seemingly a bit confusing, this feature provides a number of
  602. interesting possibilities such as the ability to rewrite the IP headers
  603. of packets in the case where traffic is captured on the loopback interface
  604. (and the source and destination address is always 127.0.0.1) so that
  605. tcpreplay can make it look like two different systems are talking
  606. to each other (you'll probably also need to specify the source and
  607. destination MAC addresses via -I, -J, -k and -K).
  608. \subsection{IP Endpoints}
  609. While pseudo-NAT provides a great deal of flexibility, it is often
  610. more complicated then is necessary for testing of inline devices.
  611. As a simplier alternative, tcpreplay supports the concept of rewriting
  612. all traffic to so that it appears to be between two IP addresses:
  613. \emph{tcpreplay -i eth0 -j eth1 -c sample.cache -e 10.0.0.1:10.1.1.1
  614. sample.pcap}
  615. Will rewrite all the traffic so that it is between 10.0.0.1 and 10.1.1.1.
  616. The equivalent command using -N would be:
  617. \emph{tcpreplay -i eth0 -j eth1 -c sample.cache -N 0.0.0.0/0:10.0.0.1
  618. -N 0.0.0.0/0:10.1.1.1 sample.pcap}
  619. \subsection{Unifying Dual-Outputs}
  620. Since a number of tcpreplay's packet editing functions require splitting
  621. traffic between client and servers, one problem that may arrise is
  622. needing to edit packets but still output to a single interface or
  623. file. The solution to this is to use the one output option -O which
  624. causes packets to be processed as if they will be split between the
  625. interfaces/files, but then always go out the primary interface or
  626. file. Note that even though only one interface/file will be written
  627. to, both -i and -j must be specified; although they can be the same
  628. physical interface.
  629. \emph{tcpreplay -i eth0 -j eth0 -O -c sample.cache -e 10.0.0.1:10.1.1.1
  630. sample.pcap}
  631. Merging the output to a single file:
  632. \emph{tcpreplay -i eth0 -j eth0 -w rewrite.pcap -c sample.cache -e
  633. 10.0.0.1:10.1.1.1 sample.pcap}
  634. \section{Tcpprep Usage}
  635. \subsection{What is tcpprep?}
  636. Tcpreplay can send traffic out two network cards, however it requires
  637. the calculations be done in real-time. These calculations can be expensive
  638. and can significantly reduce the throughput of tcpreplay.
  639. Tcpprep is a libpcap pre-processor for tcpreplay which enables using
  640. two network cards to send traffic without the performance hit of doing
  641. the calculations in real-time.
  642. \subsection{How does tcpprep work? }
  643. Tcpprep reads in a libpcap (tcpdump) formatted capture file and does
  644. some processing to generate a tcpreplay cache file. This cache file
  645. tells tcpreplay which interface a given packet should be sent out
  646. of.
  647. \subsection{Does tcpprep modify my libpcap file?}
  648. No.
  649. \subsection{Why use tcpprep?}
  650. There are three major reasons to use tcpprep:
  651. \begin{enumerate}
  652. \item Tcpprep can split traffic based upon more methods and criteria then
  653. tcpreplay.
  654. \item By pre-processing the pcap, tcpreplay has a higher theoretical maximum
  655. throughput.
  656. \item By pre-processing the pcap, tcpreplay can be more accurate in timing
  657. when replaying traffic at normal speed.
  658. \end{enumerate}
  659. \subsection{Can a cache file be used for multiple (different) libpcap files? }
  660. Cache files have nothing linking them to a given libpcap file, so
  661. there is nothing to stop you from doing this. However running tcpreplay
  662. with a cache file from a different libpcap source file is likely to
  663. cause a lot of problems and is not supported.
  664. \subsection{Why would I want to use tcpreplay with two network cards? }
  665. Tcpreplay traditionally is good for putting traffic on a given network,
  666. often used to test a network intrusion detection system (NIDS). However,
  667. there are cases where putting traffic onto a subnet in this manner
  668. is not good enough- you have to be able to send traffic {*}through{*}
  669. a device such as a router, firewall, or bridge.
  670. In these cases, being able to use a single source file (libpcap) for
  671. both ends of the connection solves this problem.
  672. \subsection{How big are the cache files?}
  673. Very small. Actual size depends on the number of packets in the dump
  674. file. Two bits of data is stored for each packet. On a test using
  675. a 900MB dump file containing over 500,000 packets, the cache file
  676. was only 150K.
  677. \subsection{What are these 'modes' tcpprep has? }
  678. Tcpprep has three basic modes which require the user to specify how
  679. to split traffic.
  680. \begin{itemize}
  681. \item CIDR (-c) mode requires the user to provide a list of networks. Any
  682. packet with a source IP in one of these networks gets sent out the
  683. primary interface.
  684. \item Regex (-r) mode requires the user to provide a regular expression.
  685. Any packet with a source IP matching the regex gets sent out the primary
  686. interface.
  687. \item Port (-p) mode splits TCP/UDP traffic based on the destination port
  688. in the header. Normally, ports 0-1023 are considered {}``server''
  689. ports and everything else a client port. You can create your own custom
  690. mapping file in the same format as /etc/services (see the services(5)
  691. man page for details) by specifying -s <file>.
  692. \end{itemize}
  693. And four auto modes in which tcpprep decides how to split traffic.
  694. Auto modes are useful for when you don't know much about the contents
  695. of the dump file in question and you want to split traffic up based
  696. upon servers and clients.
  697. \begin{itemize}
  698. \item Auto/Router (-a -n router) mode trys to find the largest network(s)
  699. that contain all the servers and no clients. Any unknown system is
  700. automatically re-classified as servers if it's inside the server network(s),
  701. otherwise it is classified as a client.
  702. \item Auto/Bridge (-a -n bridge) mode makes the assumption that the clients
  703. and servers are horribly intermixed on the network and there's no
  704. way to subnet them. While this takes less processing time to create
  705. the cache file it is unable to deal with unknown systems.
  706. \item Auto/Client (-a -n client) mode which works just like Auto/Bridge
  707. mode, except that any system it can't figure out is treated like a
  708. client.
  709. \item Auto/Server (-a -n server) mode which works just like Auto/Bridge
  710. mode, except that any system it can't figure out is treated like a
  711. server.
  712. \end{itemize}
  713. \subsection{Splitting traffic based upon IP address}
  714. Tcpprep supports the same CIDR mode that tcpreplay supports using
  715. the -c flag (tcpreplay uses -C). Additionally, tcpprep also supports
  716. regex(7) regular expressions to match source IP addresses using the
  717. -r flag.
  718. \subsection{Auto Mode}
  719. \subsubsection{How does Auto/Bridge mode work? }
  720. Tcpprep does an initial pass over the libpcap file to build a binary
  721. tree (one node per IP). For each IP, it keeps track of how many times
  722. it was a client or server. It then does a second pass of the file
  723. using the data in the tree and the ratio to determine if an IP is
  724. a client or server. If tcpprep is unable to determine the type (client
  725. or server) for each and every packet, then auto/bridge mode will fail.
  726. In these cases, it is best to use a different auto mode.
  727. \subsubsection{How does Auto/Router mode work? }
  728. Tcpprep does the same first pass as Auto/Bridge mode. It then trys
  729. to convert the binary tree into a list of networks containing the
  730. servers. Finally it uses the CIDR mode with the list of server networks
  731. in a second pass of the libpcap file. Unlike auto/bridge mode, auto/router
  732. mode can always successfully split IP addresses into clients and servers.
  733. \subsubsection{Determining Clients and Servers}
  734. Tcpprep uses the following methods in auto/router and auto/bridge
  735. mode to determine if an IP address is a client or server:
  736. \begin{itemize}
  737. \item Client:
  738. \begin{itemize}
  739. \item TCP with Syn flag set
  740. \item UDP source/destination port 53 (DNS) without query flag set
  741. \item ICMP port unreachable (destination IP of packet)
  742. \end{itemize}
  743. \item Server:
  744. \begin{itemize}
  745. \item TCP with Syn/Ack flag set
  746. \item UDP source/destination port 53 (DNS) with query flag set
  747. \item ICMP port unreachable (source IP of packet)
  748. \end{itemize}
  749. \end{itemize}
  750. \subsubsection{Client/Server ratio}
  751. Since a system may send traffic which would classify it as both a
  752. client and server, it's necessary to be able to weigh the traffic.
  753. This is done by specifying the client/server ratio (-R) which is by
  754. default set to 2.0. The ratio is the modifier to the number of client
  755. connections. Hence, by default, client connections are valued twice
  756. as high as server connections.
  757. \subsection{Selectively sending/dropping packets}
  758. Tcpprep supports the same -x and -X options to selectively send or
  759. drop packets.
  760. \subsection{Using tcpprep cache files with tcpreplay}
  761. Just run:
  762. \emph{tcpreplay -c sample.cache -i eth0 -j eth1 sample.pcap}
  763. \subsection{Commenting tcpprep cache files}
  764. In versions of tcpprep >= 2.1.0, you can specify a comment to be embeded
  765. in the tcpprep cache file. Comments are user specified and automatically
  766. include the command line arguments passed to tcpprep.
  767. \emph{tcpprep -C {}``this is my comment'' -i sample.pcap -o sample.cache
  768. <other args>}
  769. Or for no user comment, but still embed the command arguments:
  770. \emph{tcpprep -C {}``'' -i sample.pcap -o sample.cache <other args>}
  771. You can then later on print out the comments by running:
  772. \emph{tcpprep -P sample.cache}
  773. \section{Flowreplay Usage}
  774. While tcpreplay is a great way to test NIDS and firewalls, it can't
  775. be used to test servers or HIDS since tcpreplay can't connect to a
  776. service running on a device. The solution to this problem is flowreplay
  777. which instead of sending packets at Layer 2 (ethernet header and up),
  778. it can actually connect via TCP or UDP to server and then sends and
  779. receives data based upon a pcap capture file created with a tool like
  780. Ethereal or tcpdump.
  781. Please note that flowreplay is currently alpha quality and is missing
  782. a number of key features.
  783. \subsection{How flowreplay works}
  784. Put simply, flowreplay opens a socket connection to a service on a
  785. target system(s) and sends data over that socket based on the packet
  786. capture. Flowreplay has no understanding of the application protocol
  787. (like HTTP or FTP) so it is somewhat limited in how it can deal with
  788. complicated exchanges between client and server.
  789. Some of these limitations are:
  790. \begin{itemize}
  791. \item Flowreplay only plays the client side%
  792. \footnote{Flowreplay assumes the first UDP packet on a given 4-tuple is the
  793. client%
  794. } of the connection.
  795. \item Flowreplay doesn't understand the application protocols. Hence it
  796. can't always deal with the case when the server sends a different
  797. response then what was originally captured in the pcap file.
  798. \item Flowreplay only sends TCP and UDP traffic.
  799. \item Flowreplay doesn't know about multi-flow protocols like FTP.
  800. \item Flowreplay can't listen on a port and wait for a client to connect
  801. to it.
  802. \end{itemize}
  803. \subsection{Running flowreplay}
  804. See the flowreplay(8) man page for details.
  805. \section{Tuning OS's for high performance}
  806. Regardless of the size of physical memory, UNIX kernels will only
  807. allocate a static amount for network buffers. This includes packets
  808. sent via the \char`\"{}raw\char`\"{} interface, like with tcpreplay.
  809. Most kernels will allow you to tweak the size of these buffers, drastically
  810. increasing performance and accuracy.
  811. N\noun{ote:} The following information is provided based upon our
  812. own experiences or the reported experiences of others. Depending on
  813. your hardware and specific hardware, it may or may not work for you.
  814. It may even make your system horribly unstable, corrupt your harddrive,
  815. or worse.
  816. \noun{Note}: Different operating systems, network card drivers,
  817. and even hardware can have an effect on the accuracy of packet timestamps
  818. that tcpdump or other capture utilities generate. And as you know:
  819. garbage in, garbage out.
  820. \noun{Note:} If you have information on tuning the kernel of an
  821. operating system not listed here, please send it to me so I can include
  822. it.
  823. \subsection{Linux 2.4.x}
  824. The following is known to apply to the 2.4.x series of kernels. If
  825. anyone has any information regarding other kernel versions, please
  826. let us know. By default Linux's tcpreplay performance isn't all that
  827. stellar. However, with a simple tweak, relatively decent performance
  828. can be had on the right hardware. By default, Linux specifies a 64K
  829. buffer for sending packets. Increasing this buffer to about half a
  830. megabyte does a good job:
  831. \emph{echo 524287 >/proc/sys/net/core/wmem\_default }\\
  832. \emph{echo 524287 >/proc/sys/net/core/wmem\_max }\\
  833. \emph{echo 524287 >/proc/sys/net/core/rmem\_max }\\
  834. \emph{echo 524287 >/proc/sys/net/core/rmem\_default }
  835. On one system, we've seen a jump from 23.02 megabits/sec (5560 packets/sec)
  836. to 220.30 megabits/sec (53212 packets/sec) which is nearly a 10x increase
  837. in performance. Depending on your system and capture file, different
  838. numbers may provide different results.
  839. \subsection{{*}BSD}
  840. {*}BSD systems typically allow you to specify the size of network
  841. buffers with the NMBCLUSTERS option in the kernel config file. Experiment
  842. with different sizes to see which yields the best performance. See
  843. the options(4) man page for more details.
  844. \section{Understanding Common Error and Warning Messages}
  845. \subsection{Can't open eth0: libnet\_select\_device(): Can't find interface eth0}
  846. Generally this occurs when the interface (eth0 in this example) is
  847. not up or doesn't have an IP address assigned to it.
  848. \subsection{Can't open lo: libnet\_select\_device(): Can't find interface lo}
  849. Version 1.1.0 of Libnet is unable to send traffic on the loopback
  850. device. Upgrade to a later release of the Libnet library to solve
  851. this problem.
  852. \subsection{Can't open eth0: UID != 0}
  853. Tcpreplay requires that you run it as root.
  854. \subsection{100000 write attempts failed from full buffers and were repeated}
  855. When tcpreplay displays a message like \char`\"{}100000 write attempts
  856. failed from full buffers and were repeated\char`\"{}, this usually
  857. means the kernel buffers were full and it had to wait until memory
  858. was available. This is quite common when replaying files as fast as
  859. possible with the \char`\"{}-R\char`\"{} option. See the tuning OS
  860. section in this document for suggestions on solving this problem.
  861. \subsection{Invalid mac address: 00:00:00:00:00:00}
  862. Currently tcpreplay reserves the MAC address of 00:00:00:00:00:00
  863. as reserved for internal use. Hence you can't rewrite the MAC address
  864. of packets to be all zeros. While we intend to fix this someday it's
  865. not currently high on our priority list, so let us know if we should
  866. re-prioritize things.
  867. \subsection{Unable to process test.cache: cache file version missmatch}
  868. Cache files generated by tcpprep and read by tcpreplay are versioned
  869. to allow enhancements to the cache file format. Anytime the cache
  870. file format changes, the version is incremented. Since this occurs
  871. on a very rare basis, this is generally not an issue; however anytime
  872. there is a change, it breaks compatibility with previously created
  873. cache files. The solution for this problem is to use the same version
  874. of tcpreplay and tcpprep to read/write the cache files. Cache file
  875. versions match the following versions of tcpprep/tcpreplay:
  876. \begin{itemize}
  877. \item Version 1:\\
  878. Prior to 1.3.beta1
  879. \item Version 2:\\
  880. 1.3.beta2 to 1.3.1/1.4.beta1
  881. \item Version 3:\\
  882. 1.3.2/1.4.beta2 to 2.0.3
  883. \item Version 4:\\
  884. 2.1.0 and above. Note that prior to version 2.3.0, tcpprep had a bug
  885. which broke cache file compatibility between big and little endian
  886. systems.
  887. \end{itemize}
  888. \subsection{Skipping SLL loopback packet.}
  889. Your capture file was created on Linux with the 'any' parameter which
  890. then captured a packet on the loopback interface. However, tcpreplay
  891. doesn't have enough information to actual send the packet, so it skips
  892. it. Specifying a source and destination MAC address (-I, -k, -J, -K)
  893. will allow tcpreplay to send these packets.
  894. \subsection{Packet length (8892) is greater then MTU; skipping packet.}
  895. The packet length (in this case 8892 bytes) is greater then the maximum
  896. transmition unit (MTU) on the outgoing interface. Tcpreplay must skip
  897. the packet. Alternatively, you can specify the -T option and tcpreplay
  898. will truncate the packet to the MTU size, fix the checksums and send
  899. it.
  900. \subsection{Why is tcpreplay not sending all the packets?}
  901. Every now and then, someone emails the tcpreplay-users list, asking
  902. if there is a bug in tcpreplay which causes it not to send all the
  903. packets. This usually happens when the user uses the -R flag or is
  904. replaying a high-speed pcap file (> 50Mbps, although this number is
  905. dependant on the hardware in use).
  906. The short version of the answer is: no, we are not aware of any bugs
  907. which might cause a few packets to not be sent.
  908. The longer version goes something like this:
  909. If you are running tcpreplay multiple times and are using tcpdump
  910. or other packet sniffer to count the number packets sent and are getting
  911. different numbers, it's not tcpreplay's fault. The problem lies in
  912. one of two places:
  913. \begin{enumerate}
  914. \item It is well known that tcpdump and other sniffers have a problem keeping
  915. up with high-speed traffic. Furthermore, the OS in many cases \emph{lies}
  916. about how many packets were dropped. Tcpdump will repeat this lie
  917. to you. In other words, tcpdump isn't seeing all the packets. Usually
  918. this is a problem with the network card or driver which may or may
  919. not be fixable. Try another network card/driver.
  920. \item When tcpreplay sends a packet, it actually gets copied to a send buffer
  921. in the kernel. If this buffer is full, the kernel is supposed to tell
  922. tcpreplay that it didn't copy the packet to this buffer. If the kernel
  923. has a bug which squelches this error, tcpreplay will not keep trying
  924. to send the packet and will move on to the next one. Currently I am
  925. not aware of any OS kernels with this bug, but it is possible that
  926. it exists. If you find out that your OS has this problem, please let
  927. me know so I can list it here.
  928. \end{enumerate}
  929. If for some reason, you still think its a bug in tcpreplay, by all
  930. means read the code and tell me how stupid I am. The do\_packets()
  931. function in do\_packets.c is where tcpreplay processes the pcap file
  932. and sends all of the packets.
  933. \section{Required Libraries and Tools}
  934. \subsection{Libpcap}
  935. As of tcpreplay v1.4, you'll need to have libpcap installed on your
  936. system. As of v2.0, you'll need at least version 0.6.0 or better,
  937. but I only test our code with the latest version. Libpcap can be obtained
  938. on the tcpdump homepage%
  939. \footnote{\url{http://www.tcpdump.org/}%
  940. }.
  941. \subsection{Libnet}
  942. Tcpreplay v1.3 is the last version to support the old libnet API (everything
  943. before 1.1.x). As of v1.4 you will need to use Libnet 1.1.0 or better
  944. which can be obtained from the Libnet homepage%
  945. \footnote{\url{http://www.packetfactory.net/Projects/Libnet/}%
  946. }.
  947. \subsection{Libpcapnav}
  948. Starting with v2.0, tcpreplay can use libpcapnav to support the jump
  949. offset feature. If libpcapnav is not found on the system, that feature
  950. will be disabled. Libpcapnav can be found on the NetDude homepage%
  951. \footnote{\url{http://netdude.sourceforge.net/}%
  952. }.
  953. \subsection{Tcpdump}
  954. As of 2.0, tcpreplay uses tcpdump (the binary, not code) to decode
  955. packets to STDOUT in a human readable (with practice) format as it
  956. sends them. If you would like this feature, tcpdump must be installed
  957. on your system.
  958. \noun{Note:} The location of the tcpdump binary is hardcoded in
  959. tcpreplay at compile time. If tcpdump gets renamed or moved, the feature
  960. will become disabled.
  961. \part{Other Resources}
  962. \section{Other pcap tools available}
  963. \subsection{Tools to capture network traffic or decode pcap files}
  964. \begin{itemize}
  965. \item tcpdump\\
  966. \url{http://www.tcpdump.org/}
  967. \item ethereal\\
  968. \url{http://www.ethereal.com/}
  969. \item ettercap\\
  970. \url{http://ettercap.sourceforge.net/}
  971. \end{itemize}
  972. \subsection{Tools to edit pcap files}
  973. \begin{itemize}
  974. \item tcpslice\\
  975. Splits pcap files into smaller files\\
  976. \url{http://www.tcpdump.org/}
  977. \item mergecap\\
  978. Merges two pcap capture files into one\\
  979. \url{http://www.ethreal.com/}
  980. \item pcapmerge\\
  981. Merges two or more pcap capture files into one\\
  982. \url{http://tcpreplay.sourceforge.net/}
  983. \item editcap\\
  984. Converts capture file formats (pcap, snoop, etc)\\
  985. \url{http://www.ethreal.com/}
  986. \item netdude\\
  987. GTK based pcap capture file editor. Allows editing most anything in
  988. the packet.\\
  989. \url{http://netdude.sourceforge.net/}
  990. \end{itemize}
  991. \subsection{Other useful tools}
  992. \begin{itemize}
  993. \item capinfo\\
  994. Prints statistics and basic information about a pcap file\\
  995. \url{http://tcpreplay.sourceforge.net/}
  996. \item text2pcap\\
  997. Generates a pcap capture file from a hex dump\\
  998. \url{http://www.ethreal.com/}
  999. \item tcpflow\\
  1000. Extracts and reassembles the data portion on a per-flow basis on live
  1001. traffic or pcap capture files\\
  1002. \url{http://www.circlemud.org/~jelson/software/tcpflow/}
  1003. \end{itemize}
  1004. \appendix
  1005. \newpage
  1006. \part*{Appendix}
  1007. \section{BSD License}
  1008. \verbatiminput{LICENSE}
  1009. \end{document}