[Click] print out queue size in my own element
Eddie Kohler
kohler at cs.ucla.edu
Mon Feb 23 01:51:41 EST 2009
Hey late to the party as usual,
If you really want to print on every packet, try something like this.
elementclass PrintQueueSize {
input -> c :: Counter(COUNT_CALL 1 s.run) -> output;
s :: Script(TYPE PASSIVE, write c.reset, print q.length);
}
To print on every 10th packet.
elementclass PrintQueueSize {
input -> c :: Counter(COUNT_CALL 1 s.run) -> output;
s :: Script(TYPE PASSIVE, init i 0, write c.reset,
set i $(add $i 1), goto end $(lt $i 10),
print q.length, set i 0);
}
If you use the new Script support I just checked in, this gets simpler:
elementclass PrintQueueSize {
input -> Script(TYPE PACKET, print q.length) -> output
}
elementclass PrintQueueSize {
input -> Script(TYPE PACKET, init i 0,
set i $(mod $(add $i 1) 10),
goto end $(ne $i 0), print q.length) -> output
}
Eddie
Roman Chertov wrote:
> Eric,
>
> You can use click_chatter() to print queue size; however, this will
> result in poor performance at high packet rates and will flood your
> syslog. The other approach would be to use a read handler to read the
> queue size every so often.
>
> Roman
>
> Eric Sohn wrote:
>> Hello,
>>
>> I would like to figure out how to print out the queue size.
>> I implemented Queue(200) element in interface and want to print out the queue size during routing process using PrintQueueSize().
>>
>> Followings are my click configuration.
>> Please let me know how I can get queue size of the interface.
>> Thank you
>>
>> Eric
>>
>>
>> // Shared IPv4 input path and routing table
>>
>> ip4 :: Strip(14)
>> -> CheckIPHeader(INTERFACES 10.1.4.3/24 10.1.1.2/24 10.1.5.3/24)
>> -> IPC :: IPClassifier(src 10.1.3.2/24 and dst 10.1.1.3/24, icmp, -);
>> IPC[0]
>> -> PrintQueueSize()
>> -> rt4 :: LinearIPLookup(10.1.4.3/32 3, 10.1.1.2/32 3, 10.1.5.3/32 3);
>> IPC[1]
>> -> rt4 ;
>> IPC[2]
>> -> rt4 ;
>>
>>
>> // ARP responses are copied to each ARPQuerier and the host.
>>
>> arpt :: Tee(4);
>>
>>
>> // Input and output paths for eth2
>>
>> FromDevice(eth2) -> c0 :: Classifier(
>> 12/0800, // [0] IPv4 packet
>> 12/0806 20/0001, // [1] ARP request
>> 12/0806 20/0002, // [2] ARP reply
>> 12/86dd 20/3aff 54/87, // [3] IPv6 ICMP ND solicitation
>> 12/86dd 20/3aff 54/88, // [4] IPv6 ICMP ND advertisment
>> 12/86dd, // [5] IPv6 packet
>> -) // [6] Unsupported protocol;
>> out0 :: Queue(200) -> to_device0 :: ToDevice(eth2);
>>
>> // IPv4
>> c0[0] -> Paint(1) -> ip4;
>> c0[1] -> ARPResponder(10.1.4.3 0:4:23:b7:3f:96) -> out0;
>> arpq0 :: ARPQuerier(10.1.4.3, 0:4:23:b7:3f:96) -> out0;
>> c0[2] -> arpt;
>> arpt[0] -> [1] arpq0;
>>
>> // Discard IPv6
>> c0[5] -> Discard;
>> c0[3] -> Discard;
>> c0[4] -> Discard;
>>
>> // Unknown protocol
>> c0[6] -> Print("eth2 unknown protocol") -> Discard;
>>
>> _______________________________________________
>> click mailing list
>> click at amsterdam.lcs.mit.edu
>> https://amsterdam.lcs.mit.edu/mailman/listinfo/click
>> _______________________________________________
>> click mailing list
>> click at amsterdam.lcs.mit.edu
>> https://amsterdam.lcs.mit.edu/mailman/listinfo/click
>>
>
> _______________________________________________
> click mailing list
> click at amsterdam.lcs.mit.edu
> https://amsterdam.lcs.mit.edu/mailman/listinfo/click
More information about the click
mailing list