PCQ and memoru usage

Hi,

When I use PCQ queues it is normal PCQ uses RAM memory. Qyestion to support:

is

/sys res pri

shows free memory with PCQ buffers or without?

Second Q:

PCQ creates one sub-stream per IP when classifier is dst-ip. What is lifetime of the sub-stream when the IP stops generate traffic? Is sub-stream die momentarily or not?

Third:

If I set total-limit=2000 and limit=50 in PCQ queue, PCQ can create only 40 sub-streams. Such PCQ queue uses ~4,4MB of RAM. I don’t know all 4,4MB of RAM is allocated for PCQ queue at start usage this queue? Does ROS free memory when PCQ queue is free of traffic or keep RAM allocated?

My questions are pointed to proper tweak limit, total-limit parameters and its memory usage.

  1. ‘free memory’ means ‘not used memory’, free of buffers and any other data
  2. it seems like empty buffers do not occupy router’s memory
  3. ‘If I set total-limit=2000 and limit=50 in PCQ queue, PCQ can create only 40 sub-streams’ - No. It may create 1000 substreams with 2 packets in each one. 50 is maximum number of packets. after that packets are not queued but dropped

AD.3. What about Janism document http://mum.mikrotik.com/presentations/US08/janism.pdf?
He say on page 26 how to calculate substreams. I mean substream is a queue per IP in case classifier is dst-ip or src-ip. Is it?

yes, that’s true. what’s unusual?..

Unusual for me is how you calculated 1000 substreams in opposite to Janism’s calculation. I’m sure you have read it already. Janism’s document shows how to calculate substreams:

‘number of substreams’=total-limit / limit

In this case it is 2000/50=40 - not so complicated equation :wink:

You told there are 1000 substreams. I don’t understand. Can you explain your point of view?

He use "may", so it mean that it could be 2 packets per sub-stream so you will have 1000 sub-stream. 50 is just the maximum number of packet per sub-stream.

Example:
PCQ on 4 differents dst-ip

192.168.1.10 : 50 packets
192.168.1.20: 50 packets
192.168.1.30: 50 packets
192.168.1.40: 50 packets

Total: 200 packets

There is place for 1800 packets, so theorically 1800 sub-stream of 1 packet or 900 of 2 packets or 90 of 20 packets, etc.

In the worst case (each dst-ip receive 50 packets), you will have 40 sub-stream.

is this your interpretation of his words ‘It can take only 40 users to fill the queue’? yes, it can… if each user will occupy 50 places in his queue. but it’s rare case, so if every of your 100 users will use 10 packets queue, overall length will be 100*10=1000 packets, so additional packets need to be queued will be queued, still not dropped =)

Understood very clearly. Thank You guys.

I have one another question. What PCQ will do in this scenario:

address-list - contain 2000 IPs
I create PCQ queue with those parameters:
classifier - src-address (from address-list via mangle)
limit=50
total-limit=1000

All 2000 IPs are active (theoretically) and doing his job all the time.

PCQ in this scenario can create max 1000 substreams with 1 packet per subs and 1000 IPs can do job and another 1000 IPs will wait for free resources OR will PCQ hang due to no more space for create substream?

Maybe my questions are stupid for you but I have problem and trying to find solution.

Answer is simple - you will see a lots of packet drops

In theory i’m able to agree. But have you ever test such PCQ behavior? I just want to know your opinion is not clear theory but experience from working PCQ implementations.

from Janis presentation:

There must be at least 10-20 packet places in queue available per user

so do not do such short queues for such huge address lists!

it’s abnormal

You should analyse traffic to see how much packet per second (per IP if you really want to be sure) you’ve got. Then give a try with your PCQ and watch for the dropped parameter of the queue. If the dropped parameter si not zero then limit or max-limit is insuffisant. You must determinate which one by monitoring in huge traffic period.