$wgDBname<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.cablefree.net/support/radio/software/index.php?action=history&amp;feed=atom&amp;title=PCC</id>
	<title>PCC - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.cablefree.net/support/radio/software/index.php?action=history&amp;feed=atom&amp;title=PCC"/>
	<link rel="alternate" type="text/html" href="https://www.cablefree.net/support/radio/software/index.php?title=PCC&amp;action=history"/>
	<updated>2026-05-09T10:28:53Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.37.3</generator>
	<entry>
		<id>https://www.cablefree.net/support/radio/software/index.php?title=PCC&amp;diff=433&amp;oldid=prev</id>
		<title>Administrator: Created page with &quot;{{Versions|v3, v4}}  == Introduction ==   PCC matcher will allow you to divide traffic into equal streams with ability to keep packets with specific set of options in one part...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.cablefree.net/support/radio/software/index.php?title=PCC&amp;diff=433&amp;oldid=prev"/>
		<updated>2015-01-29T19:21:27Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Versions|v3, v4}}  == Introduction ==   PCC matcher will allow you to divide traffic into equal streams with ability to keep packets with specific set of options in one part...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Versions|v3, v4}}&lt;br /&gt;
&lt;br /&gt;
== Introduction == &lt;br /&gt;
&lt;br /&gt;
PCC matcher will allow you to divide traffic into equal streams with ability to keep packets with specific set of options in one particular stream (you can specify this set of options from src-address, src-port, dst-address, dst-port)  &lt;br /&gt;
&lt;br /&gt;
===Theory===&lt;br /&gt;
PCC takes selected fields from IP header, and with the help of a hashing algorithm converts selected fields into 32-bit value. This value then is divided by a specified &amp;#039;&amp;#039;Denominator&amp;#039;&amp;#039; and the remainder then is compared to a specified &amp;#039;&amp;#039;Remainder&amp;#039;&amp;#039;, if equal then packet will be captured. You can choose from src-address, dst-address, src-port, dst-port from the header to use in this operation.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
per-connection-classifier=&lt;br /&gt;
PerConnectionClassifier ::= [!]ValuesToHash:Denominator/Remainder&lt;br /&gt;
  Remainder ::= 0..4294967295    (integer number)&lt;br /&gt;
  Denominator ::= 1..4294967295    (integer number)&lt;br /&gt;
  ValuesToHash ::= both-addresses|both-ports|dst-address-and-port|&lt;br /&gt;
  src-address|src-port|both-addresses-and-ports|dst-address|dst-port|src-address-and-port &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
This configuration will divide all connections into 3 groups based on source address and port&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/ip firewall mangle add chain=prerouting action=mark-connection \&lt;br /&gt;
 new-connection-mark=1st_conn per-connection-classifier=src-address-and-port:3/0&lt;br /&gt;
/ip firewall mangle add chain=prerouting action=mark-connection \&lt;br /&gt;
  new-connection-mark=2nd_conn per-connection-classifier=src-address-and-port:3/1&lt;br /&gt;
/ip firewall mangle add chain=prerouting action=mark-connection \&lt;br /&gt;
  new-connection-mark=3rd_conn per-connection-classifier=src-address-and-port:3/2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Notes===&lt;br /&gt;
&lt;br /&gt;
PCC is available in RadioOS since v3.24. This option was introduced to address configuration issues with load balancing over multiple gateways with masquerade&lt;br /&gt;
&lt;br /&gt;
Previous configurations:&lt;br /&gt;
* [[ECMP load balancing with masquerade]]&lt;br /&gt;
* [[NTH load balancing with masquerade]]&lt;br /&gt;
* [[NTH load balancing with masquerade (another approach)]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Note | PCC setups is not designed to work if [[Manual:IP/Settings | &amp;#039;&amp;#039;&amp;#039;RP Filter&amp;#039;&amp;#039;&amp;#039;]] is enabled}}&lt;br /&gt;
&lt;br /&gt;
==Application Example - Load Balancing==&lt;br /&gt;
&lt;br /&gt;
Consider the following network layout:&lt;br /&gt;
&lt;br /&gt;
[[Image:LoadBalancing.png]]&lt;br /&gt;
&lt;br /&gt;
====Quick Start for Impatient====&lt;br /&gt;
Configuration export from the gateway router:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/ ip address&lt;br /&gt;
add address=192.168.0.1/24 network=192.168.0.0 broadcast=192.168.0.255 interface=LAN&lt;br /&gt;
add address=10.111.0.2/24 network=10.111.0.0 broadcast=10.111.0.255 interface=ISP1&lt;br /&gt;
add address=10.112.0.2/24 network=10.112.0.0 broadcast=10.112.0.255 interface=ISP2&lt;br /&gt;
&lt;br /&gt;
/ ip firewall mangle&lt;br /&gt;
add chain=prerouting dst-address=10.111.0.0/24  action=accept in-interface=LAN&lt;br /&gt;
add chain=prerouting dst-address=10.112.0.0/24  action=accept in-interface=LAN&lt;br /&gt;
add chain=prerouting in-interface=ISP1 connection-mark=no-mark action=mark-connection \&lt;br /&gt;
    new-connection-mark=ISP1_conn&lt;br /&gt;
add chain=prerouting in-interface=ISP2 connection-mark=no-mark action=mark-connection \ &lt;br /&gt;
    new-connection-mark=ISP2_conn&lt;br /&gt;
add chain=prerouting  in-interface=LAN connection-mark=no-mark dst-address-type=!local \&lt;br /&gt;
    per-connection-classifier=both-addresses:2/0 action=mark-connection new-connection-mark=ISP1_conn &lt;br /&gt;
add chain=prerouting  in-interface=LAN connection-mark=no-mark dst-address-type=!local \ &lt;br /&gt;
    per-connection-classifier=both-addresses:2/1 action=mark-connection new-connection-mark=ISP2_conn&lt;br /&gt;
add chain=prerouting connection-mark=ISP1_conn in-interface=LAN action=mark-routing \ &lt;br /&gt;
    new-routing-mark=to_ISP1&lt;br /&gt;
add chain=prerouting connection-mark=ISP2_conn in-interface=LAN action=mark-routing \&lt;br /&gt;
    new-routing-mark=to_ISP2&lt;br /&gt;
add chain=output connection-mark=ISP1_conn action=mark-routing new-routing-mark=to_ISP1     &lt;br /&gt;
add chain=output connection-mark=ISP2_conn action=mark-routing new-routing-mark=to_ISP2&lt;br /&gt;
&lt;br /&gt;
/ ip route&lt;br /&gt;
add dst-address=0.0.0.0/0 gateway=10.111.0.1 routing-mark=to_ISP1 check-gateway=ping&lt;br /&gt;
add dst-address=0.0.0.0/0 gateway=10.112.0.1 routing-mark=to_ISP2 check-gateway=ping&lt;br /&gt;
add dst-address=0.0.0.0/0 gateway=10.111.0.1 distance=1 check-gateway=ping&lt;br /&gt;
add dst-address=0.0.0.0/0 gateway=10.112.0.1 distance=2 check-gateway=ping&lt;br /&gt;
&lt;br /&gt;
/ ip firewall nat &lt;br /&gt;
add chain=srcnat out-interface=ISP1 action=masquerade&lt;br /&gt;
add chain=srcnat out-interface=ISP2 action=masquerade&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Explanation===&lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s assume this configuration: &lt;br /&gt;
&lt;br /&gt;
====IP Addresses====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/ ip address &lt;br /&gt;
add address=192.168.0.1/24 network=192.168.0.0 broadcast=192.168.0.255 interface=LAN&lt;br /&gt;
add address=10.111.0.2/24 network=10.111.0.0 broadcast=10.111.0.255 interface=ISP1&lt;br /&gt;
add address=10.112.0.2/24 network=10.112.0.0 broadcast=10.112.0.255 interface=ISP2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The router has two upstream (ISP) interfaces with the addresses of 10.111.0.2/24 and 10.112.0.2/24.&lt;br /&gt;
The LAN interface has IP address of 192.168.0.1/24.&lt;br /&gt;
&lt;br /&gt;
====Policy routing====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/ ip firewall mangle&lt;br /&gt;
add chain=prerouting dst-address=10.111.0.0/24  action=accept in-interface=LAN&lt;br /&gt;
add chain=prerouting dst-address=10.112.0.0/24  action=accept in-interface=LAN&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
With policy routing it is possible to force all traffic to the specific gateway, even if traffic is destined to the host (other that gateway) from the connected networks. This way routing loop will be generated and communications with those hosts will be impossible.&lt;br /&gt;
To avoid this situation we need to allow usage of default routing table for traffic to connected networks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
add chain=prerouting in-interface=ISP1 connection-mark=no-mark action=mark-connection \&lt;br /&gt;
    new-connection-mark=ISP1_conn&lt;br /&gt;
add chain=prerouting in-interface=ISP2 connection-mark=no-mark action=mark-connection \ &lt;br /&gt;
    new-connection-mark=ISP2_conn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
First it is necessary to manage connection initiated from outside - replies must leave via same interface (from same Public IP) request came.&lt;br /&gt;
We will mark all new incoming connections, to remember what was the interface.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;     &lt;br /&gt;
add chain=prerouting  in-interface=LAN connection-mark=no-mark dst-address-type=!local \&lt;br /&gt;
    per-connection-classifier=both-addresses:2/0 action=mark-connection new-connection-mark=ISP1_conn &lt;br /&gt;
add chain=prerouting  in-interface=LAN connection-mark=no-mark dst-address-type=!local \ &lt;br /&gt;
    per-connection-classifier=both-addresses:2/1 action=mark-connection new-connection-mark=ISP2_conn&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Action mark-routing can be used only in mangle chain &amp;#039;&amp;#039;&amp;#039;output&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;prerouting&amp;#039;&amp;#039;&amp;#039;, but mangle chain &amp;#039;&amp;#039;&amp;#039;prerouting&amp;#039;&amp;#039;&amp;#039; is capturing all traffic that is going to the router itself.&lt;br /&gt;
To avoid this we will use &amp;#039;&amp;#039;dst-address-type=!local&amp;#039;&amp;#039;. And with the help of the new PCC we will divide traffic into two groups based on source and destination addressees.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
add chain=prerouting connection-mark=ISP1_conn in-interface=LAN action=mark-routing \ &lt;br /&gt;
    new-routing-mark=to_ISP1&lt;br /&gt;
add chain=prerouting connection-mark=ISP2_conn in-interface=LAN action=mark-routing \&lt;br /&gt;
    new-routing-mark=to_ISP2&lt;br /&gt;
add chain=output connection-mark=ISP1_conn action=mark-routing new-routing-mark=to_ISP1     &lt;br /&gt;
add chain=output connection-mark=ISP2_conn action=mark-routing new-routing-mark=to_ISP2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we need to mark all packets from those connections with a proper mark. As policy routing is required only for traffic going to the Internet, do not forget to specify in-interface option.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/ ip route&lt;br /&gt;
add dst-address=0.0.0.0/0 gateway=10.111.0.1 routing-mark=to_ISP1 check-gateway=ping&lt;br /&gt;
add dst-address=0.0.0.0/0 gateway=10.112.0.1 routing-mark=to_ISP2 check-gateway=ping&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a route for each routing-mark&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
add dst-address=0.0.0.0/0 gateway=10.111.0.1 distance=1 check-gateway=ping&lt;br /&gt;
add dst-address=0.0.0.0/0 gateway=10.112.0.1 distance=2 check-gateway=ping&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To enable failover, it is necessary to have routes that will jump in as soon as others will become inactive on gateway failure. (and that will happen only if check-gateway option is active)&lt;br /&gt;
&lt;br /&gt;
====NAT====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/ ip firewall nat &lt;br /&gt;
add chain=srcnat out-interface=ISP1 action=masquerade&lt;br /&gt;
add chain=srcnat out-interface=ISP2 action=masquerade&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As routing decision is already made we just need rules that will fix src-addresses for all outgoing packets. If this packet will leave via wlan1 it will be NATed to 10.112.0.2,&lt;br /&gt;
if via wlan2 then NATed to 10.111.0.2   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Manual|PCC]]&lt;br /&gt;
[[Category: IP|PCC]]&lt;br /&gt;
[[Category: Firewall|PCC]]&lt;br /&gt;
[[Category: Examples|PCC]]&lt;/div&gt;</summary>
		<author><name>Administrator</name></author>
	</entry>
</feed>