While reading http://mum.mikrotik.com/presentations/HR13/valens.pdf page 17:
I suspected following formulas should work when counting mangle packets:
- PREROUTING = FORWARD + INPUT
- FORWARD + OUTPUT = POSTROUTING
So I created following mangle rules based on default interface config on RB750Gr3 to count WAN download traffic:
/ip firewall mangle
add action=mark-packet chain=prerouting in-interface=ether1 new-packet-mark=WAN_IN_prerouting passthrough=yes
add action=mark-packet chain=input in-interface=ether1 new-packet-mark=WAN_IN_input passthrough=yes
add action=mark-packet chain=forward in-interface=ether1 new-packet-mark=WAN_IN_forward passthrough=yes
add action=mark-packet chain=output new-packet-mark=output_TO_LAN out-interface=ether2-master passthrough=yes
add action=mark-packet chain=postrouting new-packet-mark=postrouting_TO_LAN out-interface=ether2-master passthrough=yes
And the result I got was:
[admin@MikroTik] /ip firewall mangle> print stats
Flags: X - disabled, I - invalid, D - dynamic
# CHAIN ACTION BYTES PACKETS
0 D ;;; special dummy rule to show fasttrack counters
prerouting passthrough 2 546 162 852 4 072 518
1 D ;;; special dummy rule to show fasttrack counters
forward passthrough 2 546 162 852 4 072 518
2 D ;;; special dummy rule to show fasttrack counters
postrouting passthrough 2 546 162 852 4 072 518
3 prerouting mark-packet 5 197 305 35 655
4 input mark-packet 678 103 8 855
5 forward mark-packet 2 984 371 18 497
6 output mark-packet 66 288 850 73 511
7 postrouting mark-packet 69 293 559 92 129
postrouting 92 129 packets is quite close to forward+ output (18 497 + 73 511 = ) 92008 packets, with only 1.3 per thousand missing.
But prerouting 35655 packets is far more than input + forward (8 855 + 18 497 =) 27352 packets, which indicates the formula above should be wrong.
Then I started downloading a file, but the Rate and Bytes in firewall also didn’t match the interface Tx rate and actual downloaded Bytes:
Did I create the wrong rules? Where were the missing packets?
I am new to networking and thanks for help in advance.