FAQ.txt 51 KB

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