Multiple flows in stateless mode

1,605 views
Skip to first unread message

deep23...@gmail.com

unread,
Apr 7, 2017, 10:13:09 AM4/7/17
to TRex Traffic Generator
Hi,

I am trying to create multiple flows in a single stream using example scripts stl/bench.py in stateless mode. The setup is L2 loopback in a VM.

Command: start -f stl/bench.py -t vm=tuple,size=64 -p 0 --force

But the packet capture shows me single src and dst port both in RX and TX.

The definition of multiple flows if I understand correctly is this one https://tools.ietf.org/html/rfc3917#section-2.1

I believe TRex also follows this definition.

I want to create traffic between a single source and destination IP with multiple UDP ports. I achieved this by creating streams but we have a limit of 20k streams per port. I want to create around 500K-1M flows. Please guide how can I achieve this?

Thanks,
Deepanshu

hanoh haim

unread,
Apr 7, 2017, 11:16:56 AM4/7/17
to deepanshu bhatia, TRex Traffic Generator
Hi Deepanshu,

Interesting. it seems there is a bug/typo in this profile for this case


a working example see here

a fix is to add 
vm_var = STLScVmRaw(vm_raw);
at line 60

in general each single stream can be program to generate unlimited number flows using Field Engine program. 
There is a performance penalty when adding more streams (it is not the right way)
 

Hanoh


--
You received this message because you are subscribed to the Google Groups "TRex Traffic Generator" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trex-tgn+unsubscribe@googlegroups.com.
To post to this group, send email to trex...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trex-tgn/a09cbb5a-8263-4b46-b093-d23067175721%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Hanoh
Sent from my iPhone

deep23...@gmail.com

unread,
Apr 8, 2017, 7:36:05 AM4/8/17
to TRex Traffic Generator, deep23...@gmail.com
Hi Hanoch,

I tried the solution suggested by you. It doesn't seem to work. I also tried the udp_1pkt_tuple_gen.py, that didn't work too.

Yes, I understand there is a penalty because the streams are being opened in parallel.

I also tried passing a list for sport and dport because scapy supports that, that didn't work either.

Thanks,
Deepanshu

On Friday, April 7, 2017 at 8:46:56 PM UTC+5:30, Hanoch Haim wrote:
> Hi Deepanshu,
>
>
> Interesting. it seems there is a bug/typo in this profile for this case
> https://github.com/cisco-system-traffic-generator/trex-core/blob/master/scripts/stl/bench.py#L80
>
>
>
>
>
> a working example see here
> https://github.com/cisco-system-traffic-generator/trex-core/blob/master/scripts/stl/udp_1pkt_tuple_gen.py
>
>
>
> a fix is to add 
> vm_var = STLScVmRaw(vm_raw);
>
> at line 60
>
>
> in general each single stream can be program to generate unlimited number flows using Field Engine program. 
> There is a performance penalty when adding more streams (it is not the right way)
>  
>
>
>
> Hanoh
>
>
> On Fri, Apr 7, 2017 at 5:13 PM, <deep23...@gmail.com> wrote:
> Hi,
>
>
>
> I am trying to create multiple flows in a single stream using example scripts stl/bench.py in stateless mode. The setup is L2 loopback in a VM.
>
>
>
> Command: start -f stl/bench.py -t vm=tuple,size=64 -p 0 --force
>
>
>
> But the packet capture shows me single src and dst port both in RX and TX.
>
>
>
> The definition of multiple flows if I understand correctly is this one https://tools.ietf.org/html/rfc3917#section-2.1
>
>
>
> I believe TRex also follows this definition.
>
>
>
> I want to create traffic between a single source and destination IP with multiple UDP ports. I achieved this by creating streams but we have a limit of 20k streams per port. I want to create around 500K-1M flows. Please guide how can I achieve this?
>
>
>
> Thanks,
>
> Deepanshu
>
>
>
> --
>
> You received this message because you are subscribed to the Google Groups "TRex Traffic Generator" group.
>
> To unsubscribe from this group and stop receiving emails from it, send an email to trex-tgn+u...@googlegroups.com.

hanoh haim

unread,
Apr 8, 2017, 12:55:51 PM4/8/17
to deepanshu bhatia, TRex Traffic Generator
Hi,

Could you provide the capture file?
look here for what you should expect (after wrap of IP there would be a change of src port, might be the reason for you "issue")
http://trex-tgn.cisco.com/trex/doc/trex_rpc_server_spec.html#_tuple_flow_var

you can program change of both src and dst port using flow variable 


Hanoh


To unsubscribe from this group and stop receiving emails from it, send an email to trex-tgn+unsubscribe@googlegroups.com.

To post to this group, send email to trex...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

deepanshu bhatia

unread,
Apr 9, 2017, 2:32:39 AM4/9/17
to hanoh haim, TRex Traffic Generator
Hi,

Yes, I understand I can use variations in both src and dst ports but the default code of udp_1pkt_tuple_gen.py doesn't seem to be working only for src.

This is my trex_cfg.yaml

### Config file generated by dpdk_setup_ports.py ###

- port_limit: 2
  version: 2
  interfaces: ['00:04.0', '00:05.0']
  port_info:
      - ip: 50.0.50.6
        default_gw: 50.0.50.8
      - ip: 50.0.50.8
        default_gw: 50.0.50.6

  platform:
      master_thread_id: 0
      latency_thread_id: 1
      dual_if:
        - socket: 0
          threads: [2,3,4,5]

For multiple src ports, I have made these changes in udp_1pkt_tuple_gen.py:
def create_stream (self, packet_len):
# Create base packet and pad it to size

base_pkt = Ether() / IP(src="50.0.50.6", dst="50.0.50.8") / UDP(dport=12, sport=1025)

pad = max(0, packet_len - len(base_pkt)) * 'x'

vm = STLScVmRaw([STLVmTupleGen(ip_min="50.0.50.6", ip_max="50.0.50.6",
port_min=1025, port_max=65535,
name="tuple"), # define tuple gen

STLVmWrFlowVar(fv_name="tuple.ip", pkt_offset="IP.src"), # write ip to packet IP.src
STLVmFixIpv4(offset="IP"), # fix checksum
STLVmWrFlowVar(fv_name="tuple.port", pkt_offset="UDP.sport") # write udp.port
]
);

pkt = STLPktBuilder(pkt = base_pkt/pad,
vm = vm)

return STLStream(packet = pkt,
mode = STLTXCont())

For multiple src and dst ports, I have made these changes in udp_1pkt_tuple_gen.py:

def create_stream (self, packet_len):
# Create base packet and pad it to size

base_pkt = Ether() / IP(src="50.0.50.6", dst="50.0.50.8") / UDP(dport=12, sport=1025)

pad = max(0, packet_len - len(base_pkt)) * 'x'

vm = STLScVmRaw([STLVmTupleGen(ip_min="50.0.50.6", ip_max="50.0.50.6",
port_min=1025, port_max=65535,
name="tuple"), # define tuple gen
STLVmTupleGen(ip_min="50.0.50.8", ip_max="50.0.50.8",
port_min=1025, port_max=65535,
name="tuple2"), # define tuple gen
STLVmWrFlowVar(fv_name="tuple.ip", pkt_offset="IP.src"), # write ip to packet IP.src
STLVmWrFlowVar(fv_name="tuple2.ip", pkt_offset="IP.dst"), # write ip to packet IP.dst
STLVmFixIpv4(offset="IP"), # fix checksum
STLVmWrFlowVar(fv_name="tuple.port", pkt_offset="UDP.sport"), # write udp.port
STLVmWrFlowVar(fv_name="tuple2.port", pkt_offset="UDP.dport") # write udp.port
]
);

pkt = STLPktBuilder(pkt = base_pkt/pad,
vm = vm)

return STLStream(packet = pkt,
mode = STLTXCont())
Both aren't working though. 

Thanks,
Deepanshu

Regards,
Deepanshu Bhatia
capture output file

hanoh haim

unread,
Apr 9, 2017, 3:43:19 AM4/9/17
to deepanshu bhatia, TRex Traffic Generator
Hi Deepanshu,
It is working, just not as you expect it.

Please read the pointer I gave you to better understand how this instruction should work.

For your use case you don't need to use TupleGen, just use simple varible and write it.

See this example 


BTW I was wrong and bench.py does not have an issue.

Thanks,
Hanoh



--
Hanoh
Sent from my iPhone

--
You received this message because you are subscribed to the Google Groups "TRex Traffic Generator" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trex-tgn+u...@googlegroups.com.
To post to this group, send email to trex...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

deepanshu bhatia

unread,
Apr 9, 2017, 4:16:54 AM4/9/17
to hanoh haim, TRex Traffic Generator
Hi,

Modified syn attack for UDP and it seems to be working as I expect. 
def create_stream (self):

# UDP
base_pkt = Ether()/IP(src="50.0.50.6", dst="50.0.50.8")/UDP()
# vm
vm = STLScVmRaw( [
STLVmFlowVar(name="src_port",
min_value=1025,
max_value=65000,
size=2, op="random"),
STLVmFlowVar(name="dst_port",
min_value=1025,
max_value=65000,
size=2, op="random"),
STLVmFixIpv4(offset = "IP"), # fix checksum
STLVmWrFlowVar(fv_name="src_port",
pkt_offset= "UDP.sport"), # fix udp len
STLVmWrFlowVar(fv_name="dst_port",
pkt_offset="UDP.dport") # fix udp len
]
)

pkt = STLPktBuilder(pkt = base_pkt,

vm = vm)

return STLStream(packet = pkt,
                     random_seed = 0x1234,# can be remove. will give the same random value any run
mode = STLTXCont())

The example of tuple_flow_var says it has 2 available src IPs and 4 ports with max flows limit as 10.
First it create flows with 1 port and all the IP and then increment. If there is only one IP, it will generate flow 1 with IP and port1 and flow 2 with IP and port 2. As specified here, the default value of limit_flows is 100000, it should stop if this is reached or all flows are being created. This is my expectation. 

"It is working, just not as you expect it."
What should be my expectation then? How can I check that? It might be that I am understanding flows in a wrong way. Please elaborate a little.


Regards,
Deepanshu Bhatia

Hanoh
To unsubscribe from this group and stop receiving emails from it, send an email to trex-tgn+unsubscribe@googlegroups.com.

To post to this group, send email to trex...@googlegroups.com.



--
Hanoh
Sent from my iPhone

--
You received this message because you are subscribed to the Google Groups "TRex Traffic Generator" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trex-tgn+unsubscribe@googlegroups.com.

To post to this group, send email to trex...@googlegroups.com.

hanoh haim

unread,
Apr 9, 2017, 5:17:18 AM4/9/17
to deepanshu bhatia, TRex Traffic Generator
Hi, 

There is not need to use TupleGen if you have *one* src IP. The use case of  TupleGen is in cases that you want to generate 1M distinct flows  (like we do with Stateful) - in this case there is a dependency between the variables.

 
You probably hitting a corner case of the Splitting algorithm in case of 1 src IP.
my suggestion is to use 2 different variables and write it to the right location. 

right tool for the right job.

thanks,
Hanoh

deep23...@gmail.com

unread,
Apr 9, 2017, 5:26:14 AM4/9/17
to TRex Traffic Generator, deep23...@gmail.com
> mode = STLTXCont())Both aren't working though. 
>
>
> Thanks,
> Deepanshu
>
>
>
>
>
> Regards,
> Deepanshu Bhatia
>
>
>
>
> On Sat, Apr 8, 2017 at 10:25 PM, hanoh haim <hhaim...@gmail.com> wrote:
>
>
> Hi,
>
>
> Could you provide the capture file?
> look here for what you should expect (after wrap of IP there would be a change of src port, might be the reason for you "issue")http://trex-tgn.cisco.com/trex/doc/trex_rpc_server_spec.html#_tuple_flow_var
> To view this discussion on the web visit https://groups.google.com/d/msgid/trex-tgn/e2b2c517-ad3a-4e4f-b214-b62dda11cf45%40googlegroups.com.
>
>
>
> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
>
> --
>
>
>
> HanohSent from my iPhone
>
>
>
>
>
>
>
> --
>
> You received this message because you are subscribed to the Google Groups "TRex Traffic Generator" group.
>
> To unsubscribe from this group and stop receiving emails from it, send an email to trex-tgn+u...@googlegroups.com.
>
> To post to this group, send email to trex...@googlegroups.com.
>
> HanohSent from my iPhone
>
>
>
>
>
>
> --
>
>
>
> HanohSent from my iPhone

Hi,

Okay. Understood now.

Thanks,
Deepanshu
Reply all
Reply to author
Forward
0 new messages