NTH Load balancing

 NTH is a method to select the item at position n in a sequence. For example we has the following sequence number

1 , 2, 3, 4, 5, 6, 7, 8, 9

If NTH is 3,1 it mean every 3 take index number 1. So the value 1, 4, 7 is selected
If NTH is 3,2 it mean every 3 take index number 2 so the value 2,  5, 8 is selected

Since router OS version 3.0, there is no counter value anymore. So the NTH has two value  Every, Packet. Every rule has its own counter. When rule receives packet counter for current rule is increased by one.  If counter matches value of 'every' packet will be matched and counter will be set to zero.

Example: 

/ip firewall mangle 
add action=mark-packet chain=prerouting new-packet-mark=AAA nth=3,1 passthrough=no;

The rule divide all packets into groups of three, this rule will match the first packet in each group. And the counter is increased by one. When the counter equal 3 then counter will be reset.

NOTE: For the packet index, I see some document start from index 0. But for easy understanding I start from 1. If you have any idea, or feedback please let's me know by commet below

Leave a Reply

Your email address will not be published. Required fields are marked *