# IPFW - Delay question(getting x2 the delay)



## lovepony (Aug 7, 2010)

Hello.

I just started out trying to build a small wan emulator running freebsd. 

I have a small ALIX box with 3 network interfaces , 1 for management and 2 in bridge mode.
Now my problem is when i add 700 ms delay on my bridge interface i get 1400 ms delay when i ping. 
I'm guessing this is because I'm hitting both the interfaces in the bridge.

so now my question is , how do i fix this?


----------



## DutchDaemon (Aug 7, 2010)

Use half the delay.


----------



## lovepony (Aug 7, 2010)

DutchDaemon said:
			
		

> Use half the delay.



That is and option but really not what I'm hoping for , since i want it to be easy to use for clients.


----------



## DutchDaemon (Aug 7, 2010)

Write a wrapper script that does delay/2 for them.


----------



## aragon (Aug 8, 2010)

What ruleset are you using?


----------



## terminus (Aug 8, 2010)

I guess you do not have layer3/layer2 separation in you ruleset. Then bridging is active and layer2 filtering is active (using sysctl sysctl net.link.ether.ipfw=1) all packets going trough ipfw will have 4 passes now (2 passes on IN and 2 passes on OUT).

In you case this ruleset:

```
ipfw pipe 1 config delay 1400
ipfw add 1000 pipe 1 all from any to any in recv em0
ipfw add 1100 allow all from any to any
```
will pass traffic into rule 1000 two times - first on layer2 pass, and second on layer3 pass.

Use separation in you ruleset or put everywhere where you need to work with ethernet traffic keyword "layer2".

```
ipfw pipe 1 config delay 1400
ipfw add 1000 pipe 1 all from any to any in recv em0 layer2
ipfw add 1100 allow all from any to any
```


----------



## lovepony (Aug 9, 2010)

terminus said:
			
		

> I guess you do not have layer3/layer2 separation in you ruleset. Then bridging is active and layer2 filtering is active (using sysctl sysctl net.link.ether.ipfw=1) all packets going trough ipfw will have 4 passes now (2 passes on IN and 2 passes on OUT).
> 
> In you case this ruleset:
> 
> ...



Thank you very much , this is maybe a stupid question but em0 = my bridge interface?


----------



## terminus (Aug 9, 2010)

> em0 = my bridge interface?



Yes, in this example I assume that you have bridge0 constructed from em0 and em1 interfaces, and need to create 1400ms delay on all traffic that passes through system received from em0 side.

Show current ipfw rules you are using and output from:

```
sysctl -a | grep ether.ipfw
sysctl -a | grep one_pass
```
in case you still have troubles with delays.


----------



## arusan (Aug 24, 2011)

i might be wrong, but ping basically is round-trip-time. which means that you measure the time for the packet going + the response packet back. they will both pass your rules and thus each of them will be delayed, right?
i might be also missing something, in case you use "in recv INTF" this might only match one direction, right? but u don't specify if your rules are built like that.


----------

