Kaushal Patel
Kaushal Patel

Reputation: 1

pktgen: Not able to send vlan tagged traffic using .lua script

I need right format for enabling vlan while sending traffic through lua script, following format is working without error, but it send traffic without vlan tag, not sure what is missing here, please help

pktgen.range.dst_mac("0", "start", "00:00:5e:00:01:00");
pktgen.range.src_mac("0", "start", "00:16:00:01:00:01");
pktgen.range.src_mac("0", "inc", "00:00:00:00:00:01");
pktgen.range.src_mac("0", "min", "00:16:00:01:00:01");
pktgen.range.src_mac("0", "max", "00:16:00:01:00:cd");
pktgen.range.src_ip("0", "start", "1.1.1.1");
pktgen.range.src_ip("0", "inc", "0.0.0.0");
pktgen.range.src_ip("0", "mint", "1.1.1.1");
pktgen.range.src_ip("0", "max", "1.1.1.1");
pktgen.range.dst_ip("0", "start", "1.1.1.2");
pktgen.range.dst_ip("0", "inc", "0.0.0.0");
pktgen.range.dst_ip("0", "mint", "1.1.1.2");
pktgen.range.dst_ip("0", "max", "1.1.1.2");
pktgen.set_type("0", "ipv4");
pktgen.set_proto("0", "udp");
pktgen.set("0", "size", 1024);
pktgen.set("0", "rate", 0.25);
pktgen.set("0", "burst", 1);
pktgen.set_range("all", "on");
pktgen.vlanid("0", 9);
local port ="0";
pktgen.start(port);

Upvotes: 0

Views: 280

Answers (1)

Vipin Varghese
Vipin Varghese

Reputation: 4798

As mentioned in the comments, the vlan enable is not triggered in the LUA scripts which causes VLAN not to be enabled. I have modified the above lua script to enable vlan,

please find the details below

package.path = package.path ..";?.lua;test/?.lua;app/?.lua;"
require "Pktgen"

-- enable vlan feature, default setting is disabled.
pktgen.vlan("all", "enable");

pktgen.range.dst_mac("0", "start", "00:00:5e:00:01:00");
pktgen.range.src_mac("0", "start", "00:16:00:01:00:01");
pktgen.range.src_mac("0", "inc", "00:00:00:00:00:01");
pktgen.range.src_mac("0", "min", "00:16:00:01:00:01");
pktgen.range.src_mac("0", "max", "00:16:00:01:00:cd");
pktgen.range.src_ip("0", "start", "1.1.1.1");
pktgen.range.src_ip("0", "inc", "0.0.0.0");
pktgen.range.src_ip("0", "mint", "1.1.1.1");
pktgen.range.src_ip("0", "max", "1.1.1.1");
pktgen.range.dst_ip("0", "start", "1.1.1.2");
pktgen.range.dst_ip("0", "inc", "0.0.0.0");
pktgen.range.dst_ip("0", "mint", "1.1.1.2");
pktgen.range.dst_ip("0", "max", "1.1.1.2");
pktgen.set_type("0", "ipv4");
pktgen.set_proto("0", "udp");
pktgen.set("0", "size", 1024);
pktgen.set("0", "rate", 0.25);
pktgen.set("0", "burst", 1);
pktgen.set_range("all", "on");
pktgen.vlanid("0", 9);
pktgen.start(port);

Note:

  1. there are 2 options in pktgen to run the lua from command line use option -f, and within interactive mode use script option.
  2. results for without running the script (left side) and result for after running the script (right side) shared in the image below

enter image description here

Upvotes: 1

Related Questions