kohler / click

The Click modular router: fast modular packet processing and analysis
Other
734 stars 324 forks source link

what's the bandwidth of the fake-iprouter program #482

Open knight9uzi opened 3 years ago

knight9uzi commented 3 years ago

Hello! I tried to test the bandwidth of the fake-iprouter(mainly the IP packets) So I add a Counter element to the configuration

// Hand incoming IP packets to the routing table. // CheckIPHeader checks all the lengths and length fields // for sanity. ip :: Strip(14) -> CheckIPHeader(INTERFACES 18.26.4.1/24 18.26.7.1/24) -> c:: Counter -> [0]rt; c0[2] -> Paint(1) -> ip; c1[2] -> Paint(2) -> ip;

Script(print c.count);

the result is 2059 packets. Is this result right? Or do I put Counter in a wrong place?

tbarbette commented 3 years ago

By default the Script element will run at the beginning of your program. Do you want to print the bandwidth every second? Or at the end of the program? And what do you call bandwidth? https://github.com/kohler/click/wiki/Counter gives the various available handlers, but there's also AverageCounter you might want to look at.

knight9uzi commented 3 years ago

By default the Script element will run at the beginning of your program. Do you want to print the bandwidth every second? Or at the end of the program? And what do you call bandwidth? https://github.com/kohler/click/wiki/Counter gives the various available handlers, but there's also AverageCounter you might want to look at.

Thanks! I want to print bandwidth every 5 seconds and at the end of the program.How to make it? I first use c.rate to test the bandwidth.Since I don’t know whether the result is right. I use c.count to ask this question for convenience

ahenning commented 3 years ago

Script(wait 5, print c.count, loop);

knight9uzi commented 3 years ago

Script(wait 5, print c.count, loop);

Thanks! I added this but it shows nothing

// Hand incoming IP packets to the routing table. // CheckIPHeader checks all the lengths and length fields // for sanity. ip :: Strip(14) -> CheckIPHeader(INTERFACES 18.26.4.1/24 18.26.7.1/24) -> c:: Counter -> [0]rt; c0[2] -> Paint(1) -> ip; c1[2] -> Paint(2) -> ip;

Script(wait 5, print c.count, loop);

QQ截图20210308182328

knight9uzi commented 3 years ago

Sorry I'm just newbie to Click. Did I make a mistake? Sincerely hope for your help.

tbarbette commented 3 years ago

You use userlevel click right? Kernel configurations run with click-kernel. You have no FromDevice element in this example. Kernel logs are shown in dmesg while userlevel one go to stdout/stderr.

knight9uzi commented 3 years ago

It's just part of the original fake-iprouter.click. I think there are elements work as the FromeDevice

fake-iprouter.click

c0 :: Classifier(12/0806 20/0001, 12/0806 20/0002, 12/0800, -); c1 :: Classifier(12/0806 20/0001, 12/0806 20/0002, 12/0800, -);

Idle -> [0]c0; InfiniteSource(DATA \< // Ethernet header 00 00 c0 ae 67 ef 00 00 00 00 00 00 08 00 // IP header 45 00 00 28 00 00 00 00 40 11 77 c3 01 00 00 01 02 00 00 02 // UDP header 13 69 13 69 00 14 d6 41 // UDP payload 55 44 50 20 70 61 63 6b 65 74 21 0a 04 00 00 00 01 00 00 00
01 00 00 00 00 00 00 00 00 80 04 08 00 80 04 08 53 53 00 00 53 53 00 00 05 00 00 00 00 10 00 00 01 00 00 00 54 53 00 00 54 e3 04 08 54 e3 04 08 d8 01 00 00

, LIMIT 600000, STOP true) -> [0]c1; out0 :: Queue(200) -> Discard; out1 :: Queue(200) -> Discard; tol :: Discard;

// An "ARP querier" for each interface. fake_arpq0 :: EtherEncap(0x0800, 00:00:c0:ae:67:ef, 00:00:c0:4f:71:ef); //ARPQuerier(18.26.4.24, 00:00:C0:AE:67:EF); fake_arpq1 :: EtherEncap(0x0800, 00:00:c0:4f:71:ef, 00:00:c0:4f:71:ef); //ARPQuerier(18.26.7.1, 00:00:C0:4F:71:EF);

// Deliver ARP responses to ARP queriers as well as Linux. t :: Tee(3); c0[1] -> t; c1[1] -> t; t[0] -> tol; t[1] -> fake_arpq0; // was -> [1]arpq0 t[2] -> fake_arpq1; // was -> [1]arpq1

// Connect ARP outputs to the interface queues. fake_arpq0 -> out0; fake_arpq1 -> out1;

// Proxy ARP on eth0 for 18.26.7, as well as cone's IP address. ar0 :: ARPResponder(18.26.4.24 00:00:C0:AE:67:EF, 18.26.7.0/24 00:00:C0:AE:67:EF); c0[0] -> ar0 -> out0;

// Ordinary ARP on eth1. ar1 :: ARPResponder(18.26.7.1 00:00:C0:4F:71:EF); c1[0] -> ar1 -> out1;

// IP routing table. Outputs: // 0: packets for this machine. // 1: packets for 18.26.4. // 2: packets for 18.26.7. // All other packets are sent to output 1, with 18.26.4.1 as the gateway. rt :: StaticIPLookup(18.26.4.24/32 0, 18.26.4.255/32 0, 18.26.4.0/32 0, 18.26.7.1/32 0, 18.26.7.255/32 0, 18.26.7.0/32 0, 18.26.4.0/24 1, 18.26.7.0/24 2, 0.0.0.0/0 18.26.4.1 1);

// Hand incoming IP packets to the routing table. // CheckIPHeader checks all the lengths and length fields // for sanity. ip :: Strip(14) -> CheckIPHeader(INTERFACES 18.26.4.1/24 18.26.7.1/24) -> c:: Counter -> [0]rt; c0[2] -> Paint(1) -> ip; c1[2] -> Paint(2) -> ip;

when I use Script(print c.count) it can show 2059. But when I use Script(wait 5, print c.count, loop) as suggested it shows nothing.

tbarbette commented 3 years ago

Try with ACTIVE true maybe?