blob: c5a3ec1da97447abb01cce6d910b818a5822295c [file] [log] [blame]
package.path = package.path ..";?.lua;test/?.lua;app/?.lua;"
-- Demo for Tofino/ONOS at Layer 123
pktgen.screen("off");
pktgen.pause("Starting traffic generator...\n", 1000);
-- 'set' commands for a number of per port values
pktgen.set("all", "count", 0);
pktgen.set("all", "rate", 100);
pktgen.set("all", "size", 1518);
pktgen.set("all", "burst", 64);
pktgen.set("all", "sport", 1234);
pktgen.set("all", "dport", 5678);
pktgen.set("all", "prime", 1);
pktgen.set("all", "seq_cnt", 1);
pktgen.set_type("all", "ipv4");
pktgen.set_proto("all", "udp");
pktgen.set_ipaddr("0", "dst", "10.0.0.2");
pktgen.set_ipaddr("0", "src", "10.0.0.1/8");
pktgen.set_ipaddr("1", "dst", "10.0.0.1");
pktgen.set_ipaddr("1", "src", "10.0.0.2/8");
-- Wait for links to come up
printf("\nInitializing links ");
up = false
for i=1,5 do
-- this does not seem to be reliably updated between runs
s = pktgen.linkState("all");
if s["n"] == 2 and s[0] ~= "<--Down-->" and s[1] ~= "<--Down-->" then
up = true
break
end
printf(".");
pktgen.delay(2000);
end
if up then
printf(" SUCCESS!\n");
else
printf(" Continuing...\n");
end
pktgen.linkState("all");
pktgen.delay(3000);
-- Send gratuitous arps
printf("Sending gratuitous ARPs for host discovery...", i);
for i=1,10 do
pktgen.send_arp("all", "g");
pktgen.delay(100);
end
pktgen.delay(2000);
printf(" DONE\n");
-- Initialize the traffic using range command
pktgen.pause("Initializing traffic...\n", 2000);
pktgen.page("range");
pktgen.src_ip("0", "start", "10.1.0.1");
pktgen.src_ip("0", "min", "10.1.0.0");
pktgen.src_ip("0", "max", "10.1.255.255");
pktgen.src_ip("0", "inc", "0.0.1.0");
pktgen.dst_ip("0", "start", "10.0.0.2");
pktgen.dst_ip("0", "min", "10.0.0.2");
pktgen.dst_ip("0", "max", "10.0.0.2");
pktgen.dst_ip("0", "inc", "0.0.0.0");
pktgen.src_ip("1", "start", "10.2.0.1");
pktgen.src_ip("1", "min", "10.2.0.0");
pktgen.src_ip("1", "max", "10.2.255.255");
pktgen.src_ip("1", "inc", "0.0.1.0");
pktgen.dst_ip("1", "start", "10.0.0.1");
pktgen.dst_ip("1", "min", "10.0.0.1");
pktgen.dst_ip("1", "max", "10.0.0.1");
pktgen.dst_ip("1", "inc", "0.0.0.0");
pktgen.dst_port("all", "start", 1234);
pktgen.dst_port("all", "inc", 4);
pktgen.dst_port("all", "min", 1234);
pktgen.dst_port("all", "max", 2345);
pktgen.src_port("all", "start", 5678);
pktgen.src_port("all", "inc", 5);
pktgen.src_port("all", "min", 1234);
pktgen.src_port("all", "max", 9999);
pktgen.pkt_size("all", "start", 1518);
pktgen.pkt_size("all", "min", 1518);
pktgen.pkt_size("all", "max", 1518);
pktgen.pkt_size("all", "inc", 0);
pktgen.delay(2000);
pktgen.page("0");
pktgen.set_range("all", "on");
pktgen.screen("on");
-- Start traffic
pktgen.pause("Starting traffic...\n", 1000);
pktgen.start(0);