# Removing all traffic from a network device?

## justXi

Hi,

I have four PCs, each of them have two network cards built-in.

One is connected to a router to access the internet.

The second network card of each PC is connected to a switch and should be used only by one program. 

I use these two programs to send an receive raw ethernet frames:

https://gist.github.com/austinmarton/1922600

https://gist.github.com/austinmarton/2862515

However, I receive other frames, which are not send by the above program. 

I tried to configure the interface with and without an IP address and tried to switch off ARP.

But it seems that I get other packets nevertheless.

Is it possible to remove alle traffic from a network device aceept packets that are send by the above program?

Would it be possible to achive this with iptables?

Or is it possible to unregister a network device and send data "by hand" by using ioctl-commands?

(It should be possible because the RTNet project is doing it, but I think they are modifying the network drivers, which I think should be the last option.)

Thanks for any hints.

regards

  Wilfried

----------

## memph

how many of these other packets are you getting? 

if not many, you may be best to add a header to your packets and have your programs ignore everything else.

those other packets could be from the ethernet layer or hardware itself (cards or switch), and be part of dealing with ethernet.

memph

----------

## justXi

Sporadic a few packets... but I want to measure what could be the maximum transfer for my application. So I think I will use a modified driver.

Thanks for your reply.

----------

## szatox

You can block all traffic but explicitly allowed using iptables (on layer3) or ebtables (layer2).

However, if there are so few of those packets, why won't you simply ignore them? Their impact on performance won't even be measurable.

----------

## justXi

If there is a working tool, I don't have to implement it on my own  :Wink: .

Do you know a good tutorial/howto to learn how to use iptables and ebtalbes for this purpose?

Thanks.

----------

