DHCP Server/Client EMU

455 views
Skip to first unread message

Shishir Mandal

unread,
Apr 20, 2022, 1:58:11 PM4/20/22
to TRex Traffic Generator
Hello,

Referring to https://trex-tgn.cisco.com/trex/doc/trex_emu.html#_dhcpv4_server , I am using a Catalyst9k switch as DHCP relay, with 2 ports on TREX for DHCP server and client.

I can see the client sending DISCOVER messages but I believe they are not being forwarded to the DHCP server. Before I start the EMU, I can ping the Trex server interface. But as soon as I start the emulation I can no longer ping the directly connected TREX port, or the emulated Server IP 1.1.1.3.

Not sure what I am doing wrong, please advise?

Steps followed:

1. Port/TREX config
trex@trex-vm:~/v2.97$ cat /etc/trex_cfg.yaml
### Config file generated by dpdk_setup_ports.py ###

- version: 2
  interfaces: ['0b:00.0', '03:00.0']
  port_info:
      - ip: 1.1.1.3
        default_gw: 1.1.1.1
      - ip: 1.1.2.2
        default_gw: 1.1.2.1

  platform:
      master_thread_id: 0
      latency_thread_id: 1
      dual_if:
        - socket: 0
          threads: [2,3,4,5,6,7]
         
trex@trex-vm:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 00:50:56:ae:14:6e  
          inet addr:1.1.2.2  Bcast:1.1.2.255  Mask:255.255.255.0
          inet6 addr: fe80::250:56ff:feae:146e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:120 (120.0 B)  TX bytes:648 (648.0 B)

eth1      Link encap:Ethernet  HWaddr 00:50:56:ae:38:37  
          inet addr:1.1.1.2  Bcast:1.1.1.255  Mask:255.255.255.0
          inet6 addr: fe80::250:56ff:feae:3837/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:120 (120.0 B)  TX bytes:648 (648.0 B)

eth2      Link encap:Ethernet  HWaddr 00:50:56:ae:42:0b  
          inet addr:172.21.228.177  Bcast:172.21.228.255  Mask:255.255.255.0
          inet6 addr: fe80::250:56ff:feae:420b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:85 errors:0 dropped:0 overruns:0 frame:0
          TX packets:38 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:14518 (14.5 KB)  TX bytes:6547 (6.5 KB)


trex@trex-vm:~$ cat /etc/network/interfaces
# The loopback network interface
auto lo
iface lo inet loopback

# Trex interfaces
# 38:37 sunyi-port1-10G vmnic15 nyquist4 Te1/1/7
auto eth1
iface eth1 inet static
address 1.1.1.2
netmask 255.255.255.0
#gateway 1.1.1.1

# 14:6e sunyi-port2-10G vmnic14 nyquist4 te1/1/8
auto eth0
iface eth0 inet static
address 1.1.2.2
netmask 255.255.255.0
#gateway 2.2.2.1

# The primary network interface
auto eth2
iface eth2 inet static
address 172.21.228.177
netmask 255.255.255.0
gateway 172.21.228.1


2. Cat9k Switch config

interface TenGigabitEthernet1/1/7
 description connected UCS VM TREX port eth1
 no switchport
 ip address 1.1.1.1 255.255.255.0

interface TenGigabitEthernet1/1/8
 description connected UCS VM TREX port eth0
 no switchport
 ip address 1.1.2.1 255.255.255.0
 ip helper-address 1.1.1.3
 load-interval 30

#show arp
Protocol  Address          Age (min)  Hardware Addr   Type   Interface
Internet  1.1.1.1                 -   50f7.222b.f666  ARPA   TenGigabitEthernet1/1/7
Internet  1.1.1.2                 0   0050.56ae.3837  ARPA   TenGigabitEthernet1/1/7
Internet  1.1.2.1                 -   50f7.222b.f667  ARPA   TenGigabitEthernet1/1/8
Internet  1.1.2.2                 0   0050.56ae.146e  ARPA   TenGigabitEthernet1/1/8

ping 1.1.1.2 / 1.1.2.2 works fine

3.
In one SSH session to TREX VM, start
sudo ./t-rex-64 -i -c 1 --software --emu

Keep this running

SCAPY and Emu servers are started properly

4. In another SSH session on a different xterm, start
./trex-console  --emu

Using 'python3' as Python interpeter
Connecting to RPC server on localhost:4501                   [SUCCESS]
Connecting to publisher server on localhost:4500             [SUCCESS]
Acquiring ports [0, 1]:                                      [SUCCESS]
Server Info:
Server version:   v2.97 @ STL
Server mode:      Stateless
Server CPU:       1 x Intel(R) Xeon(R) CPU E5-2667 v3 @ 3.20GHz
Ports count:      2 x 10Gbps @ VMXNET3 Ethernet Controller    
Connecting to RPC server on localhost:4510                   [SUCCESS]
Loading plugin: emu                                          [SUCCESS]
-=TRex Console v3.0=-
Type 'help' or '?' for supported actions
trex>

5. Start the Relay profile with 10 clients

emu_load_profile -f emu/dhcpsrv_relay.py -t --clients 10

6. Check output

trex>emu_show_all
Namespace #1 Information

Port | Vlan tags | Tpids |      Plugins       | #Clients
-----+-----------+-------+--------------------+---------
 0   |     -     |   -   | arp, dhcpsrv, icmp |    1    

Clients Information

       MAC        |  IPv4   | DG-IPv4 | MTU  |      Plugins      
------------------+---------+---------+------+-------------------
00:00:00:70:00:01 | 1.1.1.3 | 1.1.1.1 | 1500 | arp, dhcpsrv, icmp

Press Enter to see more namespaces
Namespace #2 Information

Port | Vlan tags | Tpids |     Plugins     | #Clients
-----+-----------+-------+-----------------+---------
 1   |     -     |   -   | arp, dhcp, icmp |    10    

Clients Information

       MAC        |     Plugins    
------------------+----------------
00:00:00:70:00:02 | arp, dhcp, icmp
00:00:00:70:00:03 | arp, dhcp, icmp
00:00:00:70:00:04 | arp, dhcp, icmp
00:00:00:70:00:05 | arp, dhcp, icmp
00:00:00:70:00:06 | arp, dhcp, icmp
00:00:00:70:00:07 | arp, dhcp, icmp
00:00:00:70:00:08 | arp, dhcp, icmp
00:00:00:70:00:09 | arp, dhcp, icmp
00:00:00:70:00:0a | arp, dhcp, icmp
00:00:00:70:00:0b | arp, dhcp, icmp

587.85 [ms]

trex>
trex>emu_dhcp_show_counters -p 1 --mac 00:00:00:70:00:02
Dhcp Counters

    name      | value
--------------+------
pktTxDiscover | 6    

9.41 [ms]

trex>emu_dhcpsrv_show_counters -p 0 --mac 00:00:00:70:00:01
There is no information to show with current filter

12.16 [ms]

7. Check cat9k again

I cannot ping the DHCP emulated server 1.1.1.3 but I see an ARP entry created for it?
I can now NO LONGER ping 1.1.1.2 but I can still ping 1.1.2.2.
1.1.1.2 is the Trex port behind which we emulate the Server

#ping 1.1.1.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.3, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
#ping 1.1.1.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.2, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
#ping 1.1.2.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 2/3/8 ms

nyquist4-sjc24#show arp
Protocol  Address          Age (min)  Hardware Addr   Type   Interface
Internet  1.1.1.1                 -   50f7.222b.f666  ARPA   TenGigabitEthernet1/1/7
Internet  1.1.1.2                 5   0050.56ae.3837  ARPA   TenGigabitEthernet1/1/7
Internet  1.1.1.3                 0   0000.0070.0001  ARPA   TenGigabitEthernet1/1/7
Internet  1.1.2.1                 -   50f7.222b.f667  ARPA   TenGigabitEthernet1/1/8
Internet  1.1.2.2                 1   0050.56ae.146e  ARPA   TenGigabitEthernet1/1/8

Thanks,
Shishir (Cisco)

Besart Dollma

unread,
Apr 21, 2022, 2:27:25 AM4/21/22
to TRex Traffic Generator
Hi Shishir, 
Have you enabled promiscuous, multicast and service mode?
Thanks,

Shishir Mandal

unread,
Apr 26, 2022, 1:48:10 PM4/26/22
to TRex Traffic Generator
Hi, thanks for the response. I enabled  promiscuousmulticast and service --no-tcp-udp modes but unfortunately it did not seem to work 

Any ideas? 

trex>service --no-tcp-udp

Enable filtered service mode on port(s) [0, 1] with mask 1   [SUCCESS]

5.24 [ms]

trex(service-filtered)>
trex(service-filtered)>portattr -a
Port Status

     port       |          0           |          1          
----------------+----------------------+---------------------
driver          |     net_vmxnet3      |     net_vmxnet3      
description     |  VMXNET3 Ethernet C  |  VMXNET3 Ethernet C  
link status     |          UP          |          UP          
link speed      |       10 Gb/s        |       10 Gb/s        
port status     |         IDLE         |         IDLE        
promiscuous     |         off          |         off          
multicast       |         off          |         off          
flow ctrl       |         N/A          |         N/A          
vxlan fs        |          -           |          -          
--              |                      |                      
layer mode      |         IPv4         |         IPv4        
src IPv4        |       1.1.1.3        |       1.1.2.2        
IPv6            |         off          |         off          
src MAC         |  00:50:56:ae:38:37   |  00:50:56:ae:14:6e  
---             |                      |                      
Destination     |       1.1.1.1        |       1.1.2.1        
ARP Resolution  |  50:f7:22:2b:f6:66   |  50:f7:22:2b:f6:67  
----            |                      |                      
VLAN            |          -           |          -          
-----           |                      |                      
PCI Address     |     0000:0b:00.0     |     0000:03:00.0    
NUMA Node       |          0           |          0          
RX Filter Mode  |      fetch all       |      fetch all      
RX Queueing     |         off          |         off          
Grat ARP        |  every 120 seconds   |  every 120 seconds  
------          |                      |                      

trex(service-filtered)>
trex(service-filtered)>portattr -a --prom on

Applying attributes on port(s) [0, 1]:                       [SUCCESS]

trex(service-filtered)>portattr -a --mult on

Applying attributes on port(s) [0, 1]:                       [SUCCESS]

trex(service-filtered)>portattr -a
Port Status

     port       |          0           |          1          
----------------+----------------------+---------------------
driver          |     net_vmxnet3      |     net_vmxnet3      
description     |  VMXNET3 Ethernet C  |  VMXNET3 Ethernet C  
link status     |          UP          |          UP          
link speed      |       10 Gb/s        |       10 Gb/s        
port status     |         IDLE         |         IDLE        
promiscuous     |          on          |          on          
multicast       |          on          |          on          
flow ctrl       |         N/A          |         N/A          
vxlan fs        |          -           |          -          
--              |                      |                      
layer mode      |         IPv4         |         IPv4        
src IPv4        |       1.1.1.3        |       1.1.2.2        
IPv6            |         off          |         off          
src MAC         |  00:50:56:ae:38:37   |  00:50:56:ae:14:6e  
---             |                      |                      
Destination     |       1.1.1.1        |       1.1.2.1        
ARP Resolution  |  50:f7:22:2b:f6:66   |  50:f7:22:2b:f6:67  
----            |                      |                      
VLAN            |          -           |          -          
-----           |                      |                      
PCI Address     |     0000:0b:00.0     |     0000:03:00.0    
NUMA Node       |          0           |          0          
RX Filter Mode  |      fetch all       |      fetch all      
RX Queueing     |         off          |         off          
Grat ARP        |  every 120 seconds   |  every 120 seconds  
------          |                      |                      

trex(service-filtered)>emu_load_profile -f emu/dhcpsrv_relay.py -t --clients 10

Converting file to profile                                   [SUCCESS]

Converting profile took: 4.47 [ms]

Removing old emu profile                                     [SUCCESS]


Sending emu profile                                          
                                       
[SUCCESS]                              

Sending profile took: 13.10 [ms]
19.91 [ms]

trex(service-filtered)>
trex(service-filtered)>
trex(service-filtered)>emu_show_all
4.49 [sec]

trex(service-filtered)>
trex(service-filtered)>emu_dhcp_show_counters -p 1 --mac 00:00:00:70:00:02

Dhcp Counters

    name      | value
--------------+------
pktTxDiscover | 14    

7.18 [ms]

trex(service-filtered)>
trex(service-filtered)>emu_dhcp_show_counters -p 1 --mac 00:00:00:70:00:03

Dhcp Counters

    name      | value
--------------+------
pktTxDiscover | 15    

2.35 [ms]

trex(service-filtered)>
trex(service-filtered)>emu_dhcpsrv_show_counters -p 0 --mac 00:00:00:70:00:01

There is no information to show with current filter

8.07 [ms]

trex(service-filtered)>emu_dhcpsrv_show_counters -p 0 --mac 00:00:00:70:00:02

dhcpsrv_show_counters - Error there is no valid client 00:00:00:70:00:02 for this MAC


hanoh haim

unread,
Apr 27, 2022, 12:11:32 PM4/27/22
to Shishir Mandal, TRex Traffic Generator
You should enable DHCP mask, try to enable service mode (all) with one core first (-c 1) 

Thanks
Hanoh

Shishir Mandal

unread,
Apr 27, 2022, 1:49:29 PM4/27/22
to TRex Traffic Generator
Hi Hanoh, thanks for the response. No luck still with service --all which enables the DHCP Mask 255 

I start TREX with 1 core and and in EMU mode 
trex@trex-vm:~/v2.97$ sudo ./t-rex-64 -i -c 1 --software --emu

Then in another window I start -  ./trex-console  --emu , with service --all, prom/mult on 

But it still does not work

Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-31-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage
Last login: Wed Apr 27 04:02:22 2022 from 10.30.218.168
===
TRex installation directory: /opt/trex
Documentation: https://trex-tgn.cisco.com/trex/doc/index.html
Try this to start:

# Generating basic config automatically for ports 2,3
sudo /opt/trex/autoinit-trex-cfg

# or manually via interactive setup
(cd /opt/trex/v* ; sudo ./dpdk_setup_ports.py -i)
# Running TRex
cd /opt/trex/v* ; sudo ./t-rex-64 -i

Open http://THIS_VM:80 for more information
trex@trex-vm:~$ cd v2.97/
trex@trex-vm:~/v2.97$

trex@trex-vm:~/v2.97$ ./trex-console  --emu

Using 'python3' as Python interpeter
Connecting to RPC server on localhost:4501                   [SUCCESS]
Connecting to publisher server on localhost:4500             [SUCCESS]
Acquiring ports [0, 1]:                                      [SUCCESS]
Server Info:

Server version:   v2.97 @ STL
Server mode:      Stateless
Server CPU:       1 x Intel(R) Xeon(R) CPU E5-2667 v3 @ 3.20GHz
Ports count:      2 x 10Gbps @ VMXNET3 Ethernet Controller    

Connecting to RPC server on localhost:4510                   [SUCCESS]
Loading plugin: emu                                          [SUCCESS]

-=TRex Console v3.0=-

Type 'help' or '?' for supported actions

trex>
trex>service --all

Enable filtered service mode on port(s) [0, 1] with mask 255 [SUCCESS]

11.28 [ms]
Converting profile took: 5.25 [ms]


Removing old emu profile                                     [SUCCESS]


Sending emu profile                                          
                                       
[SUCCESS]                              

Sending profile took: 15.71 [ms]
23.18 [ms]
6.48 [sec]


trex(service-filtered)>emu_dhcp_show_counters -p 1 --mac 00:00:00:70:00:02
Dhcp Counters

    name      | value
--------------+------
pktTxDiscover | 9    

6.26 [ms]

trex(service-filtered)>

Besart Dollma

unread,
Apr 28, 2022, 2:31:23 AM4/28/22
to TRex Traffic Generator
Hi, 
Are you using a Virtual Machine? You might need to enable promiscuous at the VM level too.
Anyway, please clear the counters in the interfaces of CAT9k and then start TRex.
Let's see that the actual Te1/1/7 is sending the broadcast packets.
Thanks,

Shishir Mandal

unread,
Jun 29, 2022, 6:13:38 PM6/29/22
to TRex Traffic Generator
Hi, apologies for the delay in responding, I was indeed able to get this working, thank you for all of the help! 

I am using EMU for dhcp server and client with my cat9k switch in the middle acting as relay. I would now like to try VLANs, i.e. for my 10 clients right now I want to split them into 2 different VLANs, how can I accomplish this? 

trex(service-filtered)>emu_show_all
Namespace #1 Information

Port | Vlan tags | Tpids |      Plugins       | #Clients
-----+-----------+-------+--------------------+---------
 0   |     -     |   -   | arp, dhcpsrv, icmp |    1    

Clients Information

       MAC        |  IPv4   | DG-IPv4 | MTU  |      Plugins      
------------------+---------+---------+------+-------------------
00:00:00:70:00:01 | 1.1.1.3 | 1.1.1.1 | 1500 | arp, dhcpsrv, icmp

Press Enter to see more namespaces
Namespace #2 Information

Port | Vlan tags | Tpids |     Plugins     | #Clients
-----+-----------+-------+-----------------+---------
 1   |     -     |   -   | arp, dhcp, icmp |    10    

Clients Information

       MAC        |   IPv4   | DG-IPv4 | MTU  |     Plugins    
------------------+----------+---------+------+----------------
00:00:00:70:00:02 | 1.1.2.3  | 1.1.2.1 | 1500 | arp, dhcp, icmp
00:00:00:70:00:03 | 1.1.2.4  | 1.1.2.1 | 1500 | arp, dhcp, icmp
00:00:00:70:00:04 | 1.1.2.5  | 1.1.2.1 | 1500 | arp, dhcp, icmp
00:00:00:70:00:05 | 1.1.2.6  | 1.1.2.1 | 1500 | arp, dhcp, icmp
00:00:00:70:00:06 | 1.1.2.7  | 1.1.2.1 | 1500 | arp, dhcp, icmp
00:00:00:70:00:07 | 1.1.2.8  | 1.1.2.1 | 1500 | arp, dhcp, icmp
00:00:00:70:00:08 | 1.1.2.9  | 1.1.2.1 | 1500 | arp, dhcp, icmp
00:00:00:70:00:09 | 1.1.2.10 | 1.1.2.1 | 1500 | arp, dhcp, icmp
00:00:00:70:00:0a | 1.1.2.11 | 1.1.2.1 | 1500 | arp, dhcp, icmp
00:00:00:70:00:0b | 1.1.2.12 | 1.1.2.1 | 1500 | arp, dhcp, icmp

1.26 [sec]

nyquist4#show ip dhcp snooping binding
MacAddress          IpAddress        Lease(sec)  Type           VLAN  Interface
------------------  ---------------  ----------  -------------  ----  --------------------
00:00:00:70:00:05   1.1.2.6          93          dhcp-snooping   52    TenGigabitEthernet1/1/8
00:00:00:70:00:03   1.1.2.4          93          dhcp-snooping   52    TenGigabitEthernet1/1/8
00:00:00:70:00:07   1.1.2.8          93          dhcp-snooping   52    TenGigabitEthernet1/1/8
00:00:00:70:00:02   1.1.2.3          93          dhcp-snooping   52    TenGigabitEthernet1/1/8
00:00:00:70:00:0A   1.1.2.11         93          dhcp-snooping   52    TenGigabitEthernet1/1/8
00:00:00:70:00:08   1.1.2.9          93          dhcp-snooping   52    TenGigabitEthernet1/1/8
00:00:00:70:00:04   1.1.2.5          93          dhcp-snooping   52    TenGigabitEthernet1/1/8
00:00:00:70:00:09   1.1.2.10         93          dhcp-snooping   52    TenGigabitEthernet1/1/8
00:00:00:70:00:0B   1.1.2.12         93          dhcp-snooping   52    TenGigabitEthernet1/1/8
00:00:00:70:00:06   1.1.2.7          93          dhcp-snooping   52    TenGigabitEthernet1/1/8
Total number of bindings: 10

Shishir Mandal

unread,
Jun 29, 2022, 7:19:19 PM6/29/22
to TRex Traffic Generator
Another question - I am also looking into Automation using PyATS with the TREX HLTAPI 

I see that it references STLClient , which seems to come from trex_client/interactive with the following 3 folders - trex_stl_lib, trex, profiles. In turn, trex_client was packaged as trex_client_v2.97.tar.gz which was inside v2.97.tar.gz .

Question: Is this controllable via trex hltapi instead using PyATS's framework of defining the trex tgen in the testbed yaml file? This part is not clear to me. 
i.e. connect using trex hltapi 
Then follow steps to set the service mode, promiscuous, multicast etc. And then connect to the EMU server. 
This flow is not clear to me, please advise

Besart Dollma

unread,
Jun 30, 2022, 3:45:21 AM6/30/22
to TRex Traffic Generator
1. When creating the namespace here: https://github.com/cisco-system-traffic-generator/trex-core/blob/e420d15a3194036583982a6034d8d504da958860/scripts/emu/dhcpsrv_relay.py#L52 add a vlan: https://github.com/cisco-system-traffic-generator/trex-core/blob/e420d15a3194036583982a6034d8d504da958860/scripts/automation/trex_control_plane/interactive/trex/emu/trex_emu_profile.py#L25 using the tci.
2. Python Automation Api is developed by our team and maintained as part of the open source. It is the most versatile and complete. HLTAPI was added only for STL and it is not maintained. Try to avoid it and write pure python api.
Thanks,

Shishir Mandal

unread,
Jul 5, 2022, 6:31:30 PM7/5/22
to TRex Traffic Generator
Hi, thanks for the response. I have some basic questions about how VLANs work

So far I've been using this: 

trex@trex-vm:~/v2.97$ cat /etc/trex_cfg.yaml
### Config file generated by dpdk_setup_ports.py ###

- version: 2
  interfaces: ['0b:00.0', '03:00.0']
  port_info:
      - ip: 1.1.1.3
        default_gw: 1.1.1.1
      - ip: 1.1.2.2
        default_gw: 1.1.2.1

My cat9k Switch:
interface Vlan51
 ip address 1.1.1.1 255.255.255.0

interface Vlan52

 ip address 1.1.2.1 255.255.255.0
 ip helper-address 1.1.1.3

interface TenGigabitEthernet1/1/7
 description trex client facing VPORT 10 vlan 51
 switchport access vlan 51
 switchport mode access

interface TenGigabitEthernet1/1/8
 description trex client facing VPORT 1 vlan 52
 switchport access vlan 52
 switchport mode access

With this configuration, I can ARP/PING and use DHCP EMU. Clients get assigned DHCP addresses properly with my cat9k switch acting as relay. My cat9k switch acting as DHCP server with the trex as simulated clients works fine as well. 

I then wanted to try with VLANs to segregate my DHCP clients per VLAN

I then added VLANs to my 2 ports
trex@trex-vm:~/v2.97$ cat /etc/trex_cfg.yaml
### Config file generated by dpdk_setup_ports.py ###

- version: 2
  interfaces: ['0b:00.0', '03:00.0']
  port_info:
      - ip: 1.1.1.3
        default_gw: 1.1.1.1
        vlan: 51

      - ip: 1.1.2.2
        default_gw: 1.1.2.1
        vlan: 52

With this I cannot even ARP
trex(service)>portattr -a

Port Status

     port       |          0           |          1          
----------------+----------------------+---------------------
driver          |     net_vmxnet3      |     net_vmxnet3      
description     |  VMXNET3 Ethernet C  |  VMXNET3 Ethernet C  
link status     |          UP          |          UP          
link speed      |       10 Gb/s        |       10 Gb/s        
port status     |         IDLE         |         IDLE        
promiscuous     |          on          |          on          
multicast       |          on          |          on          
flow ctrl       |         N/A          |         N/A          
vxlan fs        |          -           |          -          
--              |                      |                      
layer mode      |         IPv4         |         IPv4        
src IPv4        |       1.1.1.3        |       1.1.2.2        
IPv6            |         off          |         off          
src MAC         |  00:50:56:ae:38:37   |  00:50:56:ae:14:6e  
---             |                      |                      
Destination     |       1.1.1.1        |       1.1.2.1        
ARP Resolution  |      unresolved      |      unresolved      
----            |                      |                      
VLAN            |          51          |          52          
-----           |                      |                      
PCI Address     |     0000:0b:00.0     |     0000:03:00.0    
NUMA Node       |          0           |          0          
RX Filter Mode  |      fetch all       |      fetch all      
RX Queueing     |         off          |         off          
Grat ARP        |         off          |         off          
------          |                      |                      

trex(service)>
trex(service)>
trex(service)>
trex(service)>arp -a

Resolving destination on port(s) [0, 1]:                     [FAILED]


arp - Could not resolve following ports: [0, 1]


I'm not exactly sure what I am doing wrong here. The switch config is the same for now with just vlan 51 and 52 set to the 2 ports. 
I eventually want to use multiple VLANs per port i.e. the switchports on the cat9k Switch will be in trunk mode. TREX server <> clients communications will happen over multiple VLANs. Is this possible? 

I did try adding tci/tpid to the EMU namespace definition as well under the create_profile section, but that did not work either. 

Shishir Mandal

unread,
Jul 5, 2022, 6:44:57 PM7/5/22
to TRex Traffic Generator
To clarify, I am starting TREX like this - single core

trex@trex-vm:~/v2.97$ sudo ./t-rex-64 -i -c 1 --software --emu

Then in another xterm, I start trex console with emu 
trex@trex-vm:~/v2.97$ ./trex-console  --emu

In the working scenario it looks like this i.e when I'm not using VLANs on TREX. Note that I still use Layer3 VLANs (SVIs) on my cat9k switch on vlan 51 / vlan 52 on my te1/1/7 - te1/1/8 interfaces configured with switchport mode access 

trex(service-filtered)>portattr -a
Port Status

     port       |          0           |          1          
----------------+----------------------+---------------------
driver          |     net_vmxnet3      |     net_vmxnet3      
description     |  VMXNET3 Ethernet C  |  VMXNET3 Ethernet C  
link status     |          UP          |          UP          
link speed      |       10 Gb/s        |       10 Gb/s        
port status     |         IDLE         |         IDLE        
promiscuous     |          on          |          on          
multicast       |          on          |          on          
flow ctrl       |         N/A          |         N/A          
vxlan fs        |          -           |          -          
--              |                      |                      
layer mode      |         IPv4         |         IPv4        
src IPv4        |       1.1.1.3        |       1.1.2.2        
IPv6            |         off          |         off          
src MAC         |  00:50:56:ae:38:37   |  00:50:56:ae:14:6e  
---             |                      |                      
Destination     |       1.1.1.1        |       1.1.2.1        
ARP Resolution  |  50:f7:22:2b:f6:46   |  50:f7:22:2b:f6:54  
----            |                      |                      
VLAN            |          -           |          -          
-----           |                      |                      
PCI Address     |     0000:0b:00.0     |     0000:03:00.0    
NUMA Node       |          0           |          0          
RX Filter Mode  |      fetch all       |      fetch all      
RX Queueing     |         off          |         off          
Grat ARP        |  every 120 seconds   |  every 120 seconds  
------          |   

Trying to get this working with VLANs now.

Thanks,
Shishir

Shishir Mandal

unread,
Jul 5, 2022, 7:56:07 PM7/5/22
to TRex Traffic Generator

To clarify I did try VLANs with the EMU namespaces 

tci 51 on vport 0, tci 52 on vport 1, using default tpid 
vport 0 is connected to te1/1/7 on my cat9k - with trex server on 1.1.1.3
vport 1 is connected to te1/1/8 on my cat9k - clients coming from 1.1.2.2+ 

Am I understanding this correctly? The clients will be sent dot1q tagged with vlan 52. My cat9k should strip the vlan tag 52 then using the "ip helper address" under vlan 52, send it to 1.1.1.3 which is on vlan 51. The trex dhcp server will communicate over vlan 51.

Screenshot 2022-07-05 161609.png

Here, why are there 2 vlan tags per port? 

trex(service-filtered)>emu_show_all
Namespace #1 Information

Port | Vlan tags |    Tpids    |      Plugins       | #Clients
-----+-----------+-------------+--------------------+---------
 0   |   51, 0   | 0x8100, 0x0 | arp, dhcpsrv, icmp |    1    

Clients Information

       MAC        |  IPv4   | DG-IPv4 | MTU  |      Plugins      
------------------+---------+---------+------+-------------------
00:00:00:70:00:01 | 1.1.1.3 | 1.1.1.1 | 1500 | arp, dhcpsrv, icmp

Press Enter to see more namespaces
Namespace #2 Information

Port | Vlan tags |    Tpids    |     Plugins     | #Clients
-----+-----------+-------------+-----------------+---------
 1   |   52, 0   | 0x8100, 0x0 | arp, dhcp, icmp |    5    

Clients Information

       MAC        |     Plugins    
------------------+----------------
00:00:00:70:00:02 | arp, dhcp, icmp
00:00:00:70:00:03 | arp, dhcp, icmp
00:00:00:70:00:04 | arp, dhcp, icmp
00:00:00:70:00:05 | arp, dhcp, icmp
00:00:00:70:00:06 | arp, dhcp, icmp

1.16 [sec]
trex(service-filtered)>

Shishir Mandal

unread,
Jul 5, 2022, 9:15:58 PM7/5/22
to TRex Traffic Generator
Hi, apologies for the multiple posts. Here is a quick recap of where I am and what I would like to do:

Topology:
                    |------------------------|
                    |                        |
TREX vport 0 ------ | Te1/1/7        Te1/1/8 | ----- TREX vport 1
1.1.1.3             | Vlan51          Vlan52 |       1.1.2.2
DHCP Server         | 1.1.1.1        1.1.2.1 |       DHCP Clients
                    |------------------------|

Current Config: cat9k acting as DHCP Relay

interface Vlan51

 ip address 1.1.1.1 255.255.255.0

interface Vlan52
 ip address 1.1.2.1 255.255.255.0
 ip helper-address 1.1.1.3

interface TenGigabitEthernet1/1/7
 description trex client facing VPORT 10 vlan 51
 switchport access vlan 51
 switchport mode access
 ip dhcp snooping trust


interface TenGigabitEthernet1/1/8
 description trex client facing VPORT 1 vlan 52
 switchport access vlan 52
 switchport mode access
 
nyquist4-sjc24#sh int vlan 51 | i bia
  Hardware is Ethernet SVI, address is 50f7.222b.f646 (bia 50f7.222b.f646)
nyquist4-sjc24#sh int vlan 52 | i bia
  Hardware is Ethernet SVI, address is 50f7.222b.f654 (bia 50f7.222b.f654)

 
1st Xterm:

sudo ./t-rex-64 -i -c 1 --software --emu

2nd Xterm:
./trex-console  --emu
Then:
service --all
portattr -a --prom on --mult on
trex(service-filtered)>emu_load_profile -f emu/dhcpsrv_relay.py -t --clients 10

CAT9K:
nyquist4-sjc24#show ip dhcp snooping binding
MacAddress          IpAddress        Lease(sec)  Type           VLAN  Interface
------------------  ---------------  ----------  -------------  ----  --------------------
00:00:00:70:00:05   1.1.2.6          111         dhcp-snooping   52    TenGigabitEthernet1/1/8
00:00:00:70:00:03   1.1.2.4          111         dhcp-snooping   52    TenGigabitEthernet1/1/8
00:00:00:70:00:07   1.1.2.8          111         dhcp-snooping   52    TenGigabitEthernet1/1/8
00:00:00:70:00:02   1.1.2.3          111         dhcp-snooping   52    TenGigabitEthernet1/1/8
00:00:00:70:00:0A   1.1.2.11         111         dhcp-snooping   52    TenGigabitEthernet1/1/8
00:00:00:70:00:08   1.1.2.9          111         dhcp-snooping   52    TenGigabitEthernet1/1/8
00:00:00:70:00:04   1.1.2.5          111         dhcp-snooping   52    TenGigabitEthernet1/1/8
00:00:00:70:00:09   1.1.2.10         111         dhcp-snooping   52    TenGigabitEthernet1/1/8
00:00:00:70:00:0B   1.1.2.12         111         dhcp-snooping   52    TenGigabitEthernet1/1/8
00:00:00:70:00:06   1.1.2.7          111         dhcp-snooping   52    TenGigabitEthernet1/1/8

Total number of bindings: 10

Note vlan 52

Currently, TREX is not adding any vlan/dot1x tag. Only the cat9k switch interfaces are configured with access vlans.
I would like to now segregate DHCP clients on a per-VLAN basis.
I.e. DHCP server can remain on vlan 51, but I would like TREX dhcp clients to be vlan tagged. The idea is to test DHCP Clients over multiple vlans.
So Te1/1/8 would convert to a Trunk Port, serving Vlans 52,53,54+ etc.
"show ip dhcp snooping binding" should indicate Te1/1/8 but different entries on a per-VLAN basis. Is this possible?

I've tried a few different things but no luck. When I place te1/1/8 into trunk mode, I can no longer ARP. I tried adding vlan via tci/tpid in the EMU namespace create_profile part as well, but no luck yet. What am I missing?

Reference:
trex@trex-vm:~/v2.97$ cat /etc/trex_cfg.yaml
### Config file generated by dpdk_setup_ports.py ###

- version: 2
  interfaces: ['0b:00.0', '03:00.0']
  port_info:
      - ip: 1.1.1.3
        default_gw: 1.1.1.1
        #vlan: 51 # commented out
        #dest_mac: '50:f7:22:2b:f6:46'

      - ip: 1.1.2.2
        default_gw: 1.1.2.1
        #vlan: 52   # commented out
        #dest_mac: '50:f7:22:2b:f6:54'


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


Thanks,
Shishir

Besart Dollma

unread,
Jul 6, 2022, 2:54:37 AM7/6/22
to TRex Traffic Generator
Hi, 
Please put the CAT9k ports in trunk. 
The Emu clients should send tagged traffic.
Thanks, 

Shishir Mandal

unread,
Jul 6, 2022, 11:41:53 AM7/6/22
to TRex Traffic Generator
Hi, thank you for the response. I'm trying a modified version of emu/dhcp_json_options.py with vlan tag added and some custom options (which works in the non-vlan case) 

It is not clear to me why there are 2 VLANs per port? What is the purpose? 

This is with trex acting as client alone with my cat9k as dhcp server. cat9k switch interface connected to trex is in trunk mode. There is a vlan 51 whose subnet has a dhcp pool defined. I also placed the trex port into pure Ethernet mode as well, but no luck. 

I tried setting both vlans to 51 as well on the client side but no luck. 

trex(service-filtered)>emu_show_all
Namespace #1 Information

Port | Vlan tags |    Tpids    |        Plugins        | #Clients
-----+-----------+-------------+-----------------------+---------
 0   |   51, 0   | 0x8100, 0x0 | arp, dhcp, icmp, igmp |    5    

Clients Information

       MAC        |        Plugins        
------------------+----------------------
00:00:00:70:00:01 | arp, dhcp, icmp, igmp
00:00:00:70:00:02 | arp, dhcp, icmp, igmp
00:00:00:70:00:03 | arp, dhcp, icmp, igmp
00:00:00:70:00:04 | arp, dhcp, icmp, igmp
00:00:00:70:00:05 | arp, dhcp, icmp, igmp

17.40 [ms]

trex@trex-vm:~/v2.97$ cat emu/dhcp2.py
from trex.emu.api import *
import argparse


class Prof1():
    def __init__(self):
        self.mac = Mac('00:00:00:70:00:01')
        self.def_ns_plugs  = {'igmp' : {'dmac':self.mac.V()}}
        self.def_c_plugs  = None

    def create_profile(self, ns_size, clients_size, clientMac, options):
        ns_list = []

        # create different namespace each time
        vport, tci, tpid = 0, [51, 0], [0x8100, 0x00]
        for j in range(vport, ns_size + vport):
            ns_key = EMUNamespaceKey(vport  = j,
                                    tci     = tci,
                                    tpid    = tpid)
            ns = EMUNamespaceObj(ns_key = ns_key, def_c_plugs = self.def_c_plugs)

            mac = Mac(clientMac)
            ipv4 = Ipv4('0.0.0.0')
            dg = Ipv4('0.0.0.0')
            # create a different client each time
            for i in range(clients_size):      
                client = EMUClientObj(mac     = mac[i].V(),
                                      ipv4    = ipv4.V(),
                                      ipv4_dg = dg.V(),
                                      plugs   = {'arp': {},
                                                 'icmp': {},
                                                 'igmp': {},
                                                 'dhcp': {'options': options},
                                              },
                                      )
                ns.add_clients(client)
            ns_list.append(ns)

        return EMUProfile(ns = ns_list, def_ns_plugs = self.def_ns_plugs)

    def get_profile(self, tuneables):
      # Argparse for tunables
        parser = argparse.ArgumentParser(description='Argparser for Dhcp Json Option', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
        parser.add_argument('--ns', type = int, default = 1,
                    help='Number of namespaces to create')
        parser.add_argument('--clients', type = int, default = 1,
                    help='Number of clients to create in each namespace')
        parser.add_argument('--mac', type = str, default = '00:00:00:70:00:01',
                    help='Mac address of the first client')
        parser.add_argument('--options', type=str, help="A JSON encoded options dictionary.")

        args = parser.parse_args(tuneables)
        HOSTNAME_DHCP_OPTION = 12
        options = {
           "discoverDhcpClassIdOption": "MSFT 5.0",
           "requestDhcpClassIdOption": "MSFT 6.0",
           "dis": [
                   [HOSTNAME_DHCP_OPTION, ord('j'), ord('s'), ord('o'), ord('n')]
                   ],
           "req":[
                   [HOSTNAME_DHCP_OPTION, ord('s'), ord('h'), ord('i'), ord('s'), ord('h'), ord('r')]
                 ],

         }
        #return self.create_profile(args.ns, args.clients,args.mac, json.loads(args.options))
        return self.create_profile(args.ns, args.clients,args.mac, options)

def register():
    return Prof1()

Besart Dollma

unread,
Jul 7, 2022, 2:20:18 AM7/7/22
to TRex Traffic Generator
Why are you adding two vlans here? 

vport, tci, tpid = 0, [51, 0][0x8100, 0x00]


Shishir Mandal

unread,
Jul 7, 2022, 9:07:34 PM7/7/22
to TRex Traffic Generator
HI, as per our chat this morning could you please check the loop in the example emu/ .py profiles 
Even when I do 
vport, tci, tpid = 0, 51, 0x8100
I still see 

trex(service-filtered)>emu_show_all
Namespace #1 Information

Port | Vlan tags |    Tpids    |        Plugins        | #Clients
-----+-----------+-------------+-----------------------+---------
 0   |   51, 0   | 0x8100, 0x0 | arp, dhcp, icmp, igmp |    5    

Clients Information

       MAC        |        Plugins        
------------------+----------------------
00:00:00:70:00:01 | arp, dhcp, icmp, igmp
00:00:00:70:00:02 | arp, dhcp, icmp, igmp
00:00:00:70:00:03 | arp, dhcp, icmp, igmp
00:00:00:70:00:04 | arp, dhcp, icmp, igmp
00:00:00:70:00:05 | arp, dhcp, icmp, igmp

18.26 [ms]

Johannes Luther

unread,
Oct 24, 2022, 1:36:23 PM10/24/22
to TRex Traffic Generator
Hi all,
I stumbled over this thread because I want a TRex Emu example with VLANs. Thank you for that.
Regarding one of the questions, I guess I know the answer:


>> It is not clear to me why there are 2 VLANs per port? What is the purpose? 
I guess it's for Q-in-Q tagging (so two VLAN tags instead of one).
See IEEE 802.1ad.
Often used in simple Service Provider networks to allow multiple customers (identified using outer VLAN tag / S-VLAN) using their VLANs (inner VLAN / C-VLAN) over the Service Provider connection.
This is exactely what I want, because myTRex server is connected with two NICs to a "TRex distribution switch", which is connected to multiple devices for test purposed. By setting the outer tag in TRex, I can control the used egress interface of the switch.

But I guess you don't have to set any VLAN on TRex beause:
Your switch ports connected to TRex (e.g. Te1/1/7 ) are configured as access ports "switchport mode access / switchport access vlan 51". So the switch does not expect VLAN tagged traffic here. It means, that untagged traffic entering (ingress) this switch port is places into the VLAN 51.
As with any client which is connected to an access port, VLAN tagging on the end device side is not required - furthermore it's not allowed!!

So in comination with switchport mode access don't tag your traffic on TRex. If you connect TRex to a trunk port, allowing VLAN 51, you must tag your traffic.

Just my two cents.
Best regards
Johannes
Reply all
Reply to author
Forward
0 new messages