kohler / click

The Click modular router: fast modular packet processing and analysis
Other
735 stars 322 forks source link

how to quit click after some specific event #443

Closed TummanapallyAnuraag closed 4 years ago

TummanapallyAnuraag commented 4 years ago

I am trying to generate UDP packets for benchmarking purposes. my click configuration file: fastudp.click

/*
 * Author: Anuraag
 */

// FastUDPSource(RATE, LIMIT, LENGTH, SRCETH, SRCIP, SPORT, DSTETH, DSTIP, DPORT [, CHECKSUM, INTERVAL, ACTIVE])

FastUDPSource(1000, 2000, 64, 78:32:1b:71:81:b8, 192.168.0.250, 5432, FF:FF:FF:FF:FF:FF , 192.168.0.1, 5433)->ToDevice(enp2s0);

The command that I run to use click:

sudo click fastudp.click -h fudp.rate -h fudp.count

After 2 seconds, when I press CTRL+C:

^Cfudp.rate:
1000

fudp.count:
2000

What do I want?

I want a method/workaround so that the program automatically quits after sending the 2000 packets and displays the handler details fudp.rate and fudp.count

Any suggestion/comments are appreciated, thanks in advance

bcronje commented 4 years ago

You typically use the Script element or DriverManager element for these types of things. As an example, run the config and stop after 2 seconds:

fudp::FastUDPSource(1000, 2000, 64, 78:32:1b:71:81:b8, 192.168.0.250, 5432, FF:FF:FF:FF:FF:FF , 192.168.0.1, 5433)->ToDevice(enp2s0);

Script ( 
    wait 2,
    printn "fudp.rate: ",
    print fudp.rate,
    printn "fudp.count: ",
    print fudp.count,
    stop
)
TummanapallyAnuraag commented 4 years ago

Thanks, this solves my problem