Community discussions

MikroTik App
 
bootchi
just joined
Topic Author
Posts: 15
Joined: Tue Feb 02, 2010 6:33 pm

Inquire about pcc

Wed Mar 24, 2010 10:48 pm

hi all i have two internet line and make loadbalance with ppc and work very well i use the folowing scipt
/ ip address
add address=192.168.0.1/24 network=192.168.0.0 broadcast=192.168.0.255 interface=Local
add address=10.111.0.2/24 network=10.111.0.0 broadcast=10.111.0.255 interface=wlan1
add address=10.112.0.2/24 network=10.112.0.0 broadcast=10.112.0.255 interface=wlan2

/ ip firewall mangle
add chain=input in-interface=wlan1 action=mark-connection new-connection-mark=wlan1_conn
add chain=input in-interface=wlan2 action=mark-connection new-connection-mark=wlan2_conn
add chain=output connection-mark=wlan1_conn action=mark-routing new-routing-mark=to_wlan1
add chain=output connection-mark=wlan2_conn action=mark-routing new-routing-mark=to_wlan2
add chain=prerouting dst-address=10.111.0.0/24 action=accept in-interface=Local
add chain=prerouting dst-address=10.112.0.0/24 action=accept in-interface=Local
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses:2/0 \
action=mark-connection new-connection-mark=wlan1_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses:2/1 \
action=mark-connection new-connection-mark=wlan2_conn passthrough=yes
add chain=prerouting connection-mark=wlan1_conn in-interface=Local action=mark-routing new-routing-mark=to_wlan1
add chain=prerouting connection-mark=wlan2_conn in-interface=Local action=mark-routing new-routing-mark=to_wlan2

/ ip route
add dst-address=0.0.0.0/0 gateway=10.111.0.1 routing-mark=to_wlan1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=10.112.0.1 routing-mark=to_wlan2 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=10.111.0.1 distance=1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=10.112.0.1 distance=2 check-gateway=ping

/ ip firewall nat
add chain=srcnat out-interface=wlan1 action=masquerade
add chain=srcnat out-interface=wlan2 action=masquerade
i want to know what The difference between
per-connection-classifier=both-addresses
per-connection-classifier=both-addresses and port
per-connection-classifier=src-addresses
per-connection-classifier=src-addresses and port
and which one it better
thanks a lot
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: Inquire about pcc

Wed Mar 24, 2010 11:10 pm

PCC takes certain fields from the IP header (both-addresses|both-ports|dst-address-and-port|src-address|src-port|both-addresses-and-ports|dst-address|dst-port|src-address-and-port) and hashes them. It then divides the hash by the denominator (the first number after the colon) and compares the remainder to the second number after the colon. If they are equal, it matches.

Hashes always generate the same output for the same input. So if you use src-address as the only field to hash, connections from the same source address will always match the same PCC matcher, and in your example will always be assigned the same routing mark and therefore go out the same WAN link. Correspondingly, if you were to use only the dst-address field, all connections from any clients to the same server on the Internet would always go through the same WAN link.

There's no generic answer on which fields are 'better', it depends on what you're trying to do. If you're trying to spread load as evenly as possible across the links 'both-addresses-and-ports' is probably the best option as it would pick a WAN link very randomly since you're hashing across fields that change even for consecutive (but new) connections between the same two endpoints.
 
bootchi
just joined
Topic Author
Posts: 15
Joined: Tue Feb 02, 2010 6:33 pm

Re: Inquire about pcc

Thu Mar 25, 2010 8:02 am

thanks for reply I want to know the explanation of
per-connection-classifier=src-addresses and port
per-connection-classifier=both-addresses and port
to use one of them
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8712
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Inquire about pcc

Fri Mar 26, 2010 1:44 am

So if you use src-address as the only field to hash, connections from the same source address will always match the same PCC matcher, and in your example will always be assigned the same routing mark and therefore go out the same WAN link. Correspondingly, if you were to use only the dst-address field, all connections from any clients to the same server on the Internet would always go through the same WAN link.
so, if you use 'both-addresses' classifier, each connection from the same source address to the same destination address will use the same gateway
 
bootchi
just joined
Topic Author
Posts: 15
Joined: Tue Feb 02, 2010 6:33 pm

Re: Inquire about pcc

Fri Mar 26, 2010 9:43 am

Thank you for the clarification I want to be equal to distribute the load on both lines
when i use "src-addresses and port" What happens
when i use "both-addresses and port" What happens
when i use "dst-addresses and port" What happens
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8712
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Inquire about pcc

Fri Mar 26, 2010 12:41 pm

the same. please read above, fewi's post
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: Inquire about pcc

Fri Mar 26, 2010 5:25 pm

Alright, here's more detail, put it on the wiki because I don't want to have to type that much more than once.

http://wiki.mikrotik.com/wiki/How_PCC_w ... eginner%29

I can't explain it better than that.