DHCP¶
- class trex.emu.emu_plugins.emu_plugin_dhcp.DHCPPlugin(emu_client)[source]¶
Defines DHCP plugin based on DHCP
Implemented based on RFC 2131 Client
- INIT_JSON_NS = {'dhcp': {}}¶
- Parameters
Empty.
- INIT_JSON_CLIENT = {'dhcp': {'timerd': 5, 'timero': 10}}¶
- Parameters
- timerd: uint32
DHCP timer discover in seconds.
- timero: uint32
DHCP timer offer in seconds.
- options: dict
Dictionary that contains DHCP Options:
- Options
- discoverDhcpClassIdOption: string
ClassIdOption option for discover packet e.g. “MSFT 5.0”
- requestDhcpClassIdOption: string
ClassIdOption option for request packet
- dis: List[List[byte]]
List of byte lists. Each byte list represents an Option that will be added to a Discovery Packet.
Each byte list should be of the format [Type][Data] (pay attention, no length).
For example:
"dis": [ [60, 8, 77, 83, 70, 84, 32, 53, 46, 48], # Vendor Class Id - Type 60 [0x0c, 0x68, 0x6f, 0x73, 0x74, 0x2d, 0x74, 0x72, 0x65, 0x78] # Hostname - Type 12 ]
- req: List[List[byte]]
List of byte lists. Each byte list represents an Option that will be added to a Request Packet.
- ren: List[List[byte]]
List of byte lists. Each byte list represents an Option that will be added to a Renew Packet.
- get_counters(c_key, cnt_filter=None, zero=True, verbose=True)[source]¶
Get the DHCP counters of a client.
- Parameters
- c_key:
trex.emu.trex_emu_profile.EMUClientKey EMUClientKey
- cnt_filter: list
List of counters types as strings. i.e: [‘INFO’, ‘ERROR’, ‘WARNING’]. Default is None, means no filter. If verbosity is off, this filter can’t be used.
- zero: bool
Get zero values, default is True.
- verbose: bool
Show verbose version of each counter, default is True.
- c_key:
- Returns
Dictionary of all wanted counters. When verbose is True, each plugin contains a list of counter dictionaries.
{'pluginName': [{'help': 'Explanation 1', 'info': 'INFO', 'name': 'counterOne', 'unit': 'pkts', 'value': 8, 'zero': False}, {'help': 'Explanation 2', 'info': 'ERROR', 'name': 'counterTwo', 'unit': 'pkts', 'value': 6, 'zero': False}]}
When verbose is False, each plugins returns a dictionary of counterName, value pairs.
{'pluginName': {'counterOne': 8, 'counterTwo': 6}}
- Raises
TRexError
- tear_down_ns(ns_key)¶
This function will be called before removing this plugin from namespace.
- parameters
- ns_key: EMUNamespaceKey
- clear_counters(c_key)[source]¶
Clear the DHCP counters of a client.
- Parameters
- c_key:
trex.emu.trex_emu_profile.EMUClientKey EMUClientKey
- c_key:
- Returns
- Boolean indicating if clearing was successful.
True: Clearing was successful.
False: Clearing was not successful.
- Raises
TRexError
- trex.emu.emu_plugins.emu_plugin_dhcp.wraps(func)¶
Replaces functools.wraps in order to undo wrapping.
Can be used to preserve the decorated function’s signature in the documentation generated by Sphinx.