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()