On Sun, 8 Apr 2001, Guy Harris wrote: > On Fri, Apr 06, 2001 at 05:13:22PM -0700, Zhigang Chen wrote: > > I was wondering if libpcap functions can intercept all the incoming or > > outgoing packets and send them down to NIC > > Libpcap supports reading packets from a network capture; it doesn't > support sending raw packets, if that's what you mean by "send them down > to the NIC". > > > or receive up to the upper layer? > > Libpcap doesn't support, for example, taking a packet received from a > NIC and sending it back down to the networking code on your machine, so > that it can be treated as if it had been received. > > > I need to make a program that behaves like a virtual NIC(with certain > > delay and loss rate). > > I.e., you want to, in effect, insert into your OS's networking stack a > module to artificially delay or drop packets, so that you can simulate > particular delay and loss rates? > > Libpcap won't let you do that; unfortunately, it'd probably require, on > most OSes, the assistance of OS kernel code in the networking stack > other than the code that libpcap uses. > > > Can any other toolkit do this? > > FreeBSD has a mechanism called "dummynet" which, according to the > dummynet man page on FreeBSD 3.4, "permits the control of traffic going > through the various network interfaces, by applying bandwidth and queue > size limitations, and simulating delays and losses." > > I don't know offhand whether any of the other BSDs have this, but they > might. FreeBSD has also nice feature called divert sockets (divert(4)). It should exactly do what you want. I guess you can use Linux firewall REDIRECT rule to simulate that behavior you need. It lets you receive all packets up to socket(PF_INET) and you can write it back to the network too. Sebastian --- "Please stop the earth. Let me off." - This is the TCPDUMP workers list. It is archived at http://www.tcpdump.org/lists/workers/index.html To unsubscribe use mailto:[EMAIL PROTECTED]?body=unsubscribe
