Summary#

The summary of XOA HL-API (object-oriented) is provided in the attached file.

You can find set and get method of APIs of tester, module, port, stream, and impairment flow.

See also

Read more about Get and Set Method

   1import asyncio
   2
   3from xoa_driver import testers
   4from xoa_driver import modules
   5from xoa_driver import ports
   6from xoa_driver import enums
   7from xoa_driver import utils
   8from xoa_driver import misc
   9from xoa_driver.hlfuncs import mgmt
  10from xoa_driver.misc import Hex
  11from xoa_driver.lli import commands
  12import ipaddress
  13
  14
  15async def my_awesome_func(stop_event: asyncio.Event):
  16
  17# region Tester
  18    #################################################
  19    #                   Tester                      #
  20    #################################################
  21    tester = await testers.L23Tester(
  22        host="10.10.10.10",
  23        username="my_name",
  24        password="xena",
  25        enable_logging=False)
  26    
  27    # Shutdown/Restart
  28    await tester.down.set(operation=enums.ChassisShutdownAction.POWER_OFF)
  29    await tester.down.set_poweroff()
  30    await tester.down.set(operation=enums.ChassisShutdownAction.RESTART)
  31    await tester.down.set_restart()
  32
  33    # Flash
  34    await tester.flash.set(on_off=enums.OnOff.OFF)
  35    await tester.flash.set_off()
  36    await tester.flash.set(on_off=enums.OnOff.ON)
  37    await tester.flash.set_on()
  38
  39    resp = await tester.flash.get()
  40    resp.on_off
  41
  42    # Debug Log
  43    resp = await tester.debug_log.get()
  44    resp.data
  45    resp.message_length
  46
  47    # IP Address
  48    await tester.management_interface.ip_address.set(
  49        ipv4_address=ipaddress.IPv4Address("10.10.10.10"),
  50        subnet_mask=ipaddress.IPv4Address("255.255.255.0"),
  51        gateway=ipaddress.IPv4Address("10.10.10.1"))
  52    
  53    resp = await tester.management_interface.ip_address.get()
  54    resp.ipv4_address
  55    resp.subnet_mask
  56    resp.gateway
  57
  58    # MAC Address
  59    resp = await tester.management_interface.macaddress.get()
  60    resp.mac_address
  61
  62    # Hostname
  63    await tester.management_interface.hostname.set(hostname="name")
  64
  65    resp = await tester.management_interface.hostname.get()
  66    resp.hostname
  67
  68    # DHCP
  69    await tester.management_interface.dhcp.set(on_off=enums.OnOff.ON)
  70    await tester.management_interface.dhcp.set_on()
  71    await tester.management_interface.dhcp.set(on_off=enums.OnOff.OFF)
  72    await tester.management_interface.dhcp.set_off()
  73
  74    resp = await tester.management_interface.dhcp.get()
  75    resp.on_off
  76
  77    # Capabilities
  78    resp = await tester.capabilities.get()
  79    resp.version
  80    resp.max_name_len
  81    resp.max_comment_len
  82    resp.max_password_len
  83    resp.max_ext_rate
  84    resp.max_session_count
  85    resp.max_chain_depth
  86    resp.max_module_count
  87    resp.max_protocol_count
  88    resp.can_stream_based_arp
  89    resp.can_sync_traffic_start
  90    resp.can_read_log_files
  91    resp.can_par_module_upgrade
  92    resp.can_upgrade_timekeeper
  93    resp.can_custom_defaults
  94    resp.max_owner_name_length
  95    resp.can_read_temperatures
  96    resp.can_latency_f2f
  97
  98    # Name
  99    await tester.name.set(chassis_name="name")
 100
 101    resp = await tester.name.get()
 102    resp.chassis_name
 103
 104    # Password
 105    await tester.password.set(password="xena")
 106
 107    resp = await tester.password.get()
 108    resp.password
 109
 110    # Description
 111    await tester.comment.set(comment="description")
 112    
 113    resp = await tester.comment.get()
 114    resp.comment
 115
 116    # Model
 117    resp = await tester.model.get()
 118    resp.model
 119
 120    # Serial Number
 121    resp = await tester.serial_no.get()
 122    resp.serial_number
 123
 124    # Firmware Version
 125    resp = await tester.version_no.get()
 126    resp.chassis_major_version
 127    resp.pci_driver_version
 128
 129    resp = await tester.version_no_minor.get()
 130    resp.chassis_minor_version
 131    resp.reserved_1
 132    resp.reserved_2
 133
 134    # Build String
 135    resp = await tester.build_string.get()
 136    resp.build_string
 137
 138    # Reservation
 139    await tester.reservation.set(operation=enums.ReservedAction.RELEASE)
 140    await tester.reservation.set_release()
 141    await tester.reservation.set(operation=enums.ReservedAction.RELINQUISH)
 142    await tester.reservation.set_relinquish()
 143    await tester.reservation.set(operation=enums.ReservedAction.RESERVE)
 144    await tester.reservation.set_reserve()
 145
 146    resp = await tester.reservation.get()
 147    resp.operation
 148
 149    # Reserved By
 150    resp = await tester.reserved_by.get()
 151    resp.username
 152
 153    # Information
 154    # The following are pre-fetched in cache when connection is established, thus no need to use await
 155
 156    tester.session.owner_name
 157    tester.session.keepalive
 158    tester.session.pwd
 159    tester.session.is_online
 160    tester.session.sessions_info
 161    tester.session.timeout
 162    tester.is_released()
 163    tester.is_reserved_by_me()
 164
 165    # Logoff
 166    await tester.session.logoff()
 167
 168    # Time
 169    resp = await tester.time.get()
 170    resp.local_time
 171
 172    # TimeKeeper Configuration
 173    await tester.time_keeper.config_file.set(config_file="filename")
 174    
 175    resp = await tester.time_keeper.config_file.get()
 176    resp.config_file
 177
 178    # TimeKeeper GPS State
 179    resp = await tester.time_keeper.gps_state.get()
 180    resp.status
 181
 182    # TimeKeeper License File
 183    await tester.time_keeper.license_file.set(license_content="")
 184    
 185    resp = await tester.time_keeper.license_file.get()
 186    resp.license_content
 187
 188    # TimeKeeper License State
 189    resp = await tester.time_keeper.license_state.get()
 190    resp.license_errors
 191    resp.license_file_state
 192    resp.license_type
 193
 194    # TimeKeeper Status
 195    resp = await tester.time_keeper.status.get()
 196    resp.status_string
 197
 198    resp = await tester.time_keeper.status_extended.get()
 199    resp.status_string
 200
 201    # Chassis Traffic
 202    await tester.traffic.set(on_off=enums.OnOff.ON, module_ports=[0,0,0,1])
 203    await tester.traffic.set(on_off=enums.OnOff.OFF, module_ports=[0,0,0,1])
 204    await tester.traffic.set_on(module_ports=[0,0,0,1])
 205    await tester.traffic.set_off(module_ports=[0,0,0,1])
 206
 207    # Synchronized Chassis Traffic
 208    await tester.traffic_sync.set(on_off=enums.OnOff.ON, timestamp=1234567, module_ports=[0,0,0,1])
 209    await tester.traffic_sync.set(on_off=enums.OnOff.OFF, timestamp=1234567, module_ports=[0,0,0,1])
 210    await tester.traffic_sync.set_on(timestamp=1234567, module_ports=[0,0,0,1])
 211    await tester.traffic_sync.set_off(timestamp=1234567, module_ports=[0,0,0,1])
 212
 213# endregion
 214
 215# region Module
 216    #################################################
 217    #                   Module                      #
 218    #################################################
 219
 220    # Access module index 0 on the tester
 221    module = tester.modules.obtain(0)
 222
 223    # Capabilities
 224    resp = await module.capabilities.get()
 225    resp.can_advanced_timing
 226    resp.can_local_time_adjust
 227    resp.can_media_config
 228    resp.can_ppm_sweep
 229    resp.can_tsn
 230    resp.is_chimera
 231    resp.max_clock_ppm
 232
 233    # Name
 234    resp = await module.name.get()
 235    resp.name
 236
 237    # Description
 238    await module.comment.set(comment="description")
 239    
 240    resp = await module.comment.get()
 241    resp.comment
 242
 243    # Legacy Model
 244    resp = await module.model.get()
 245    resp.model
 246
 247    # Model
 248    resp = await module.revision.get()
 249    resp.revision
 250
 251    # Serial Number
 252    resp = await module.serial_number.get()
 253    resp.serial_number
 254
 255    # Firmware Version
 256    resp = await module.version_number.get()
 257    resp.version
 258
 259    # Port Count
 260    resp = await module.port_count.get()
 261    resp.port_count
 262
 263    # Status
 264    resp = await module.status.get()
 265    resp.temperature
 266
 267    # Media Configuration
 268    await module.media.set(media_config=enums.MediaConfigurationType.BASE_T1)
 269    await module.media.set(media_config=enums.MediaConfigurationType.BASE_T1S)
 270    await module.media.set(media_config=enums.MediaConfigurationType.CFP)
 271    await module.media.set(media_config=enums.MediaConfigurationType.CFP4)
 272    await module.media.set(media_config=enums.MediaConfigurationType.CXP)
 273    await module.media.set(media_config=enums.MediaConfigurationType.OSFP800)
 274    await module.media.set(media_config=enums.MediaConfigurationType.OSFP800_ANLT)
 275    await module.media.set(media_config=enums.MediaConfigurationType.QSFP112)
 276    await module.media.set(media_config=enums.MediaConfigurationType.QSFP112_ANLT)
 277    await module.media.set(media_config=enums.MediaConfigurationType.QSFP28_NRZ)
 278    await module.media.set(media_config=enums.MediaConfigurationType.QSFP28_PAM4)
 279    await module.media.set(media_config=enums.MediaConfigurationType.QSFP56_PAM4)
 280    await module.media.set(media_config=enums.MediaConfigurationType.QSFPDD_NRZ)
 281    await module.media.set(media_config=enums.MediaConfigurationType.QSFPDD_PAM4)
 282    await module.media.set(media_config=enums.MediaConfigurationType.QSFPDD800)
 283    await module.media.set(media_config=enums.MediaConfigurationType.QSFPDD800_ANLT)
 284    await module.media.set(media_config=enums.MediaConfigurationType.SFP112)
 285    await module.media.set(media_config=enums.MediaConfigurationType.SFP28)
 286    await module.media.set(media_config=enums.MediaConfigurationType.SFP56)
 287    await module.media.set(media_config=enums.MediaConfigurationType.SFPDD)
 288
 289    resp = await module.media.get()
 290    resp.media_config
 291    
 292    # Supported Media
 293    resp = await module.available_speeds.get()
 294    resp.media_info_list
 295
 296    # Port Configuration
 297    await module.cfp.config.set(portspeed_list=[1, 800000])
 298    await module.cfp.config.set(portspeed_list=[2, 400000, 400000])
 299    await module.cfp.config.set(portspeed_list=[4, 200000, 200000, 200000, 200000])
 300    await module.cfp.config.set(portspeed_list=[8, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000])
 301
 302    resp = await module.cfp.config.get()
 303    resp.portspeed_list
 304
 305    # Reservation
 306    await module.reservation.set(operation=enums.ReservedAction.RELEASE)
 307    await module.reservation.set_release()
 308    await module.reservation.set(operation=enums.ReservedAction.RELINQUISH)
 309    await module.reservation.set_relinquish()
 310    await module.reservation.set(operation=enums.ReservedAction.RESERVE)
 311    await module.reservation.set_reserve()
 312
 313    resp = await module.reservation.get()
 314    resp.operation
 315    
 316    # Reserved By
 317    resp = await module.reserved_by.get()
 318    resp.username
 319
 320    # TX Clock Filter Loop Bandwidth
 321    if not isinstance(module, modules.ModuleChimera):
 322        await module.advanced_timing.clock_tx.filter.set(filter_bandwidth=enums.LoopBandwidth.BW103HZ)
 323        await module.advanced_timing.clock_tx.filter.set_bw103hz()
 324        await module.advanced_timing.clock_tx.filter.set(filter_bandwidth=enums.LoopBandwidth.BW1683HZ)
 325        await module.advanced_timing.clock_tx.filter.set_bw1683hz()
 326        await module.advanced_timing.clock_tx.filter.set(filter_bandwidth=enums.LoopBandwidth.BW207HZ)
 327        await module.advanced_timing.clock_tx.filter.set_bw207hz()
 328        await module.advanced_timing.clock_tx.filter.set(filter_bandwidth=enums.LoopBandwidth.BW416HZ)
 329        await module.advanced_timing.clock_tx.filter.set_bw416hz()
 330        await module.advanced_timing.clock_tx.filter.set(filter_bandwidth=enums.LoopBandwidth.BW7019HZ)
 331        await module.advanced_timing.clock_tx.filter.set_bw7019hz()
 332
 333        resp = await module.advanced_timing.clock_tx.filter.get()
 334        resp.filter_bandwidth
 335
 336    # TX Clock Source
 337    if not isinstance(module, modules.ModuleChimera):
 338        await module.advanced_timing.clock_tx.source.set(tx_clock=enums.TXClockSource.MODULELOCALCLOCK)
 339        await module.advanced_timing.clock_tx.source.set_modulelocalclock()
 340        await module.advanced_timing.clock_tx.source.set(tx_clock=enums.TXClockSource.P0RXCLK)
 341        await module.advanced_timing.clock_tx.source.set_p0rxclk()
 342        await module.advanced_timing.clock_tx.source.set(tx_clock=enums.TXClockSource.P1RXCLK)
 343        await module.advanced_timing.clock_tx.source.set_p1rxclk()
 344        await module.advanced_timing.clock_tx.source.set(tx_clock=enums.TXClockSource.P2RXCLK)
 345        await module.advanced_timing.clock_tx.source.set_p2rxclk()
 346        await module.advanced_timing.clock_tx.source.set(tx_clock=enums.TXClockSource.P3RXCLK)
 347        await module.advanced_timing.clock_tx.source.set_p3rxclk()
 348        await module.advanced_timing.clock_tx.source.set(tx_clock=enums.TXClockSource.P4RXCLK)
 349        await module.advanced_timing.clock_tx.source.set_p4rxclk()
 350        await module.advanced_timing.clock_tx.source.set(tx_clock=enums.TXClockSource.P5RXCLK)
 351        await module.advanced_timing.clock_tx.source.set_p5rxclk()
 352        await module.advanced_timing.clock_tx.source.set(tx_clock=enums.TXClockSource.P6RXCLK)
 353        await module.advanced_timing.clock_tx.source.set_p6rxclk()
 354        await module.advanced_timing.clock_tx.source.set(tx_clock=enums.TXClockSource.P7RXCLK)
 355        await module.advanced_timing.clock_tx.source.set_p7rxclk()
 356
 357        resp = await module.advanced_timing.clock_tx.source.get()
 358        resp.tx_clock
 359
 360    # TX Clock Status
 361    if not isinstance(module, modules.ModuleChimera):
 362        resp = await module.advanced_timing.clock_tx.status.get()
 363        resp.status
 364
 365    # SMA Status
 366    if not isinstance(module, modules.ModuleChimera):
 367        resp = await module.advanced_timing.sma.status.get()
 368        resp.status
 369
 370    # SMA Input
 371    if not isinstance(module, modules.ModuleChimera):
 372        await module.advanced_timing.sma.input.set(sma_in=enums.SMAInputFunction.NOT_USED)
 373        await module.advanced_timing.sma.input.set_notused()
 374        await module.advanced_timing.sma.input.set(sma_in=enums.SMAInputFunction.TX10MHZ)
 375        await module.advanced_timing.sma.input.set_tx10mhz()
 376        await module.advanced_timing.sma.input.set(sma_in=enums.SMAInputFunction.TX2MHZ)
 377        await module.advanced_timing.sma.input.set_tx2mhz()
 378
 379        resp = await module.advanced_timing.sma.input.get()
 380        resp.sma_in
 381
 382    # SMA Output
 383    if not isinstance(module, modules.ModuleChimera):
 384        await module.advanced_timing.sma.output.set(sma_out=enums.SMAOutputFunction.DISABLED)
 385        await module.advanced_timing.sma.output.set_disabled()
 386        await module.advanced_timing.sma.output.set(sma_out=enums.SMAOutputFunction.P0RXCLK)
 387        await module.advanced_timing.sma.output.set_p0rxclk()
 388        await module.advanced_timing.sma.output.set(sma_out=enums.SMAOutputFunction.P0RXCLK2MHZ)
 389        await module.advanced_timing.sma.output.set_p0rxclk2mhz()
 390        await module.advanced_timing.sma.output.set(sma_out=enums.SMAOutputFunction.P0SOF)
 391        await module.advanced_timing.sma.output.set_p0sof()
 392        await module.advanced_timing.sma.output.set(sma_out=enums.SMAOutputFunction.P1RXCLK)
 393        await module.advanced_timing.sma.output.set_p1rxclk()
 394        await module.advanced_timing.sma.output.set(sma_out=enums.SMAOutputFunction.P1RXCLK2MHZ)
 395        await module.advanced_timing.sma.output.set_p1rxclk2mhz()
 396        await module.advanced_timing.sma.output.set(sma_out=enums.SMAOutputFunction.P1SOF)
 397        await module.advanced_timing.sma.output.set_p1sof()
 398        await module.advanced_timing.sma.output.set(sma_out=enums.SMAOutputFunction.PASSTHROUGH)
 399        await module.advanced_timing.sma.output.set_passthrough()
 400        await module.advanced_timing.sma.output.set(sma_out=enums.SMAOutputFunction.REF10MHZ)
 401        await module.advanced_timing.sma.output.set_ref10mhz()
 402        await module.advanced_timing.sma.output.set(sma_out=enums.SMAOutputFunction.REF125MHZ)
 403        await module.advanced_timing.sma.output.set_ref125mhz()
 404        await module.advanced_timing.sma.output.set(sma_out=enums.SMAOutputFunction.REF156MHZ)
 405        await module.advanced_timing.sma.output.set_ref156mhz()
 406        await module.advanced_timing.sma.output.set(sma_out=enums.SMAOutputFunction.REF2MHZ)
 407        await module.advanced_timing.sma.output.set_ref2mhz()
 408        await module.advanced_timing.sma.output.set(sma_out=enums.SMAOutputFunction.TS_PPS)
 409        await module.advanced_timing.sma.output.set_ts_pps()
 410
 411        resp = await module.advanced_timing.sma.output.get()
 412        resp.sma_out
 413
 414    # Local Clock Adjust
 415    await module.timing.clock_local_adjust.set(ppb=10)
 416    
 417    resp = await module.timing.clock_local_adjust.get()
 418    resp.ppb
 419
 420    # Clock Sync Status
 421    resp = await module.timing.clock_sync_status.get()
 422    resp.m_clock_diff
 423    resp.m_correction
 424    resp.m_is_steady_state
 425    resp.m_tune_is_increase
 426    resp.m_tune_value
 427
 428    # Clock Source
 429    await module.timing.source.set(source=enums.TimingSource.CHASSIS)
 430    await module.timing.source.set_chassis()
 431    await module.timing.source.set(source=enums.TimingSource.EXTERNAL)
 432    await module.timing.source.set_external()
 433    await module.timing.source.set(source=enums.TimingSource.MODULE)
 434    await module.timing.source.set_module()
 435
 436    resp = await module.timing.source.get()
 437    resp.source
 438
 439    # Clock PPM Sweep Configuration
 440    FREYA_MODULES = (modules.MFreya800G4S1P_a, modules.MFreya800G4S1P_b, modules.MFreya800G4S1POSFP_a, modules.MFreya800G4S1POSFP_b)
 441    if isinstance(module, FREYA_MODULES):
 442        await module.clock_sweep.config.set(mode=enums.PPMSweepMode.OFF, ppb_step=10, step_delay=10, max_ppb=10, loops=1)
 443        await module.clock_sweep.config.set(mode=enums.PPMSweepMode.TRIANGLE, ppb_step=10, step_delay=10, max_ppb=10, loops=1)
 444
 445        resp = await module.clock_sweep.config.get()
 446        resp.mode
 447        resp.ppb_step
 448        resp.step_delay
 449        resp.max_ppb
 450        resp.loops
 451
 452    # Clock PPM Sweep Status
 453    if isinstance(module, FREYA_MODULES):
 454        resp = await module.clock_sweep.status.get()
 455        resp.curr_step
 456        resp.curr_sweep
 457        resp.max_steps
 458
 459    
 460    # Chimera - Bypass Mode
 461    if isinstance(module, modules.ModuleChimera):
 462        await module.emulator_bypass_mode.set(on_off=enums.OnOff.ON)
 463        await module.emulator_bypass_mode.set_on()
 464        await module.emulator_bypass_mode.set(on_off=enums.OnOff.OFF)
 465        await module.emulator_bypass_mode.set_off()
 466
 467        resp = await module.emulator_bypass_mode.get()
 468        resp.on_off
 469
 470    # Chimera - Latency Mode
 471    if isinstance(module, modules.ModuleChimera):
 472        await module.latency_mode.set(mode=enums.ImpairmentLatencyMode.NORMAL)
 473        await module.latency_mode.set_normal()
 474        await module.latency_mode.set(mode=enums.ImpairmentLatencyMode.EXTENDED)
 475        await module.latency_mode.set_extended()
 476
 477        resp = await module.latency_mode.get()
 478        resp.mode
 479
 480    # Chimera - TX Clock Source
 481    if isinstance(module, modules.ModuleChimera):
 482        await module.tx_clock.source.set(tx_clock=enums.TXClockSource.MODULELOCALCLOCK)
 483        await module.tx_clock.source.set_modulelocalclock()
 484        await module.tx_clock.source.set(tx_clock=enums.TXClockSource.P0RXCLK)
 485        await module.tx_clock.source.set_p0rxclk()
 486        await module.tx_clock.source.set(tx_clock=enums.TXClockSource.P1RXCLK)
 487        await module.tx_clock.source.set_p1rxclk()
 488        await module.tx_clock.source.set(tx_clock=enums.TXClockSource.P2RXCLK)
 489        await module.tx_clock.source.set_p2rxclk()
 490        await module.tx_clock.source.set(tx_clock=enums.TXClockSource.P3RXCLK)
 491        await module.tx_clock.source.set_p3rxclk()
 492        await module.tx_clock.source.set(tx_clock=enums.TXClockSource.P4RXCLK)
 493        await module.tx_clock.source.set_p4rxclk()
 494        await module.tx_clock.source.set(tx_clock=enums.TXClockSource.P5RXCLK)
 495        await module.tx_clock.source.set_p5rxclk()
 496        await module.tx_clock.source.set(tx_clock=enums.TXClockSource.P6RXCLK)
 497        await module.tx_clock.source.set_p6rxclk()
 498        await module.tx_clock.source.set(tx_clock=enums.TXClockSource.P7RXCLK)
 499        await module.tx_clock.source.set_p7rxclk()
 500
 501        resp = await module.tx_clock.source.get()
 502        resp.tx_clock
 503
 504    # Chimera - TX Clock Status
 505    if isinstance(module, modules.ModuleChimera):
 506        resp = await module.tx_clock.status.get()
 507        resp.status
 508    
 509# endregion
 510
 511# region Port
 512    #################################################
 513    #                    Port                       #
 514    #################################################
 515
 516    port = module.ports.obtain(0)
 517
 518    # Reset
 519    await port.reset.set()
 520
 521    if isinstance(port, ports.PortChimera):
 522        return
 523
 524    # Flash
 525    await port.flash.set(on_off=enums.OnOff.ON)
 526    await port.flash.set_on()
 527    await port.flash.set(on_off=enums.OnOff.OFF)
 528    await port.flash.set_off()
 529
 530    resp = await port.flash.get()
 531    resp.on_off
 532
 533
 534    # MAC Address
 535    await port.net_config.mac_address.set(mac_address=Hex("000000000000"))
 536    
 537    resp = await port.net_config.mac_address.get()
 538    resp.mac_address
 539
 540    # IPv4 Address
 541    await port.net_config.ipv4.address.set(
 542        ipv4_address=ipaddress.IPv4Address("10.10.10.10"),
 543        subnet_mask=ipaddress.IPv4Address("255.255.255.0"),
 544        gateway=ipaddress.IPv4Address("10.10.1.1"),
 545        wild=ipaddress.IPv4Address("0.0.0.0"))
 546    
 547    resp = await port.net_config.ipv4.address.get()
 548    resp.ipv4_address
 549    resp.gateway
 550    resp.subnet_mask
 551    resp.wild
 552
 553    # ARP Reply
 554    await port.net_config.ipv4.arp_reply.set(on_off=enums.OnOff.ON)
 555    await port.net_config.ipv4.arp_reply.set(on_off=enums.OnOff.OFF)
 556    
 557    resp = await port.net_config.ipv4.arp_reply.get()
 558    resp.on_off
 559
 560    # Ping Reply
 561    await port.net_config.ipv4.ping_reply.set(on_off=enums.OnOff.ON)
 562    await port.net_config.ipv4.ping_reply.set(on_off=enums.OnOff.OFF)
 563
 564    resp = await port.net_config.ipv4.ping_reply.get()
 565    resp.on_off
 566
 567    # IPv6 Address
 568    await port.net_config.ipv6.address.set(
 569        ipv6_address=ipaddress.IPv6Address("fc00::0002"),
 570        gateway=ipaddress.IPv6Address("fc00::0001"),
 571        subnet_prefix=7,
 572        wildcard_prefix=0
 573    )
 574    
 575    resp = await port.net_config.ipv6.address.get()
 576    resp.ipv6_address
 577    resp.gateway
 578    resp.subnet_prefix
 579    resp.wildcard_prefix
 580
 581    # NDP Reply
 582    await port.net_config.ipv6.arp_reply.set(on_off=enums.OnOff.ON)
 583    await port.net_config.ipv6.arp_reply.set(on_off=enums.OnOff.OFF)
 584
 585    resp = await port.net_config.ipv6.arp_reply.get()
 586    resp.on_off
 587
 588    # IPv6 Ping Reply
 589    await port.net_config.ipv6.ping_reply.set(on_off=enums.OnOff.ON)
 590    await port.net_config.ipv6.ping_reply.set(on_off=enums.OnOff.OFF)
 591
 592    resp = await port.net_config.ipv6.ping_reply.get()
 593    resp.on_off
 594
 595    # ARP Table, https://github.com/xenanetworks/open-automation-script-library/tree/main/ip_streams_arp_table
 596    await port.arp_rx_table.set(chunks=[])
 597    
 598    resp = await port.arp_rx_table.get()
 599    resp.chunks
 600
 601    # NDP Table, https://github.com/xenanetworks/open-automation-script-library/tree/main/ip_streams_arp_table
 602    await port.ndp_rx_table.set(chunks=[])
 603    
 604    resp = await port.ndp_rx_table.get()
 605    resp.chunks
 606
 607    # Capture Trigger Criteria, https://github.com/xenanetworks/open-automation-script-library/blob/main/packet_capture/packet_capture.py
 608    await port.capturer.trigger.set(start_criteria=enums.StartTrigger.ON, start_criteria_filter=0, stop_criteria=enums.StopTrigger.FULL, stop_criteria_filter=0)
 609    await port.capturer.trigger.set(start_criteria=enums.StartTrigger.ON, start_criteria_filter=0, stop_criteria=enums.StopTrigger.USERSTOP, stop_criteria_filter=0)
 610    await port.capturer.trigger.set(start_criteria=enums.StartTrigger.FCSERR, start_criteria_filter=0, stop_criteria=enums.StopTrigger.FCSERR, stop_criteria_filter=0)
 611    await port.capturer.trigger.set(start_criteria=enums.StartTrigger.PLDERR, start_criteria_filter=0, stop_criteria=enums.StopTrigger.PLDERR, stop_criteria_filter=0)
 612    await port.capturer.trigger.set(start_criteria=enums.StartTrigger.FILTER, start_criteria_filter=0, stop_criteria=enums.StopTrigger.FILTER, stop_criteria_filter=0)
 613
 614    resp = await port.capturer.trigger.get()
 615    resp.start_criteria
 616    resp.start_criteria_filter
 617    resp.stop_criteria
 618    resp.stop_criteria_filter
 619
 620    # Capture - Frame to Keep, https://github.com/xenanetworks/open-automation-script-library/blob/main/packet_capture/packet_capture.py
 621    await port.capturer.keep.set(kind=enums.PacketType.ALL, index=0, byte_count=0)
 622    await port.capturer.keep.set_all()
 623    await port.capturer.keep.set(kind=enums.PacketType.FCSERR, index=0, byte_count=0)
 624    await port.capturer.keep.set_fcserr()
 625    await port.capturer.keep.set(kind=enums.PacketType.FILTER, index=0, byte_count=0)
 626    await port.capturer.keep.set_filter()
 627    await port.capturer.keep.set(kind=enums.PacketType.NOTPLD, index=0, byte_count=0)
 628    await port.capturer.keep.set_notpld()
 629    await port.capturer.keep.set(kind=enums.PacketType.PLDERR, index=0, byte_count=0)
 630    await port.capturer.keep.set_plderr()
 631    await port.capturer.keep.set(kind=enums.PacketType.TPLD, index=0, byte_count=0)
 632    await port.capturer.keep.set_tpld()
 633
 634    resp = await port.capturer.keep.get()
 635    resp.kind
 636    resp.index
 637    resp.byte_count
 638
 639    # Capture - State
 640    await port.capturer.state.set(on_off=enums.StartOrStop.START)
 641    await port.capturer.state.set_start()
 642    await port.capturer.state.set(on_off=enums.StartOrStop.STOP)
 643    await port.capturer.state.set_stop()
 644
 645    resp = await port.capturer.state.get()
 646    resp.on_off
 647
 648    # Capture - Statistics
 649    resp = await port.capturer.stats.get()
 650    resp.start_time
 651    resp.status
 652
 653    # Read Captured Packets
 654    pkts = await port.capturer.obtain_captured()
 655    for i in range(len(pkts)):
 656        resp = await pkts[i].packet.get()
 657        print(f"Packet content # {i}: {resp.hex_data}")
 658
 659    # Inter-frame Gap
 660    await port.interframe_gap.set(min_byte_count=20)
 661
 662    resp = await port.interframe_gap.get()
 663    resp.min_byte_count
 664
 665    # PAUSE Frames
 666    await port.pause.set(on_off=enums.OnOff.ON)
 667    await port.pause.set_on()
 668    await port.pause.set(on_off=enums.OnOff.OFF)
 669    await port.pause.set_off()
 670
 671    resp = await port.pause.get()
 672    resp.on_off
 673
 674    # Auto-Train
 675    await port.autotrain.set(interval=1)
 676
 677    resp = await port.autotrain.get()
 678    resp.interval
 679
 680    # Gap Monitor
 681    await port.gap_monitor.set(start=100, stop=10)
 682    
 683    resp = await port.gap_monitor.get()
 684    resp.start
 685    resp.stop
 686
 687    # Priority Flow Control
 688    await port.pfc_enable.set(
 689        cos_0=enums.OnOff.ON,
 690        cos_1=enums.OnOff.OFF,
 691        cos_2=enums.OnOff.ON,
 692        cos_3=enums.OnOff.OFF,
 693        cos_4=enums.OnOff.ON,
 694        cos_5=enums.OnOff.OFF,
 695        cos_6=enums.OnOff.ON,
 696        cos_7=enums.OnOff.OFF,
 697        )
 698    
 699    resp = await port.pfc_enable.get()
 700    resp.cos_0
 701    resp.cos_1
 702    resp.cos_2
 703    resp.cos_3
 704    resp.cos_4
 705    resp.cos_5
 706    resp.cos_6
 707    resp.cos_7
 708
 709    # Loopback
 710    await port.loop_back.set(mode=enums.LoopbackMode.L1RX2TX)
 711    await port.loop_back.set_l1rx2tx()
 712    await port.loop_back.set(mode=enums.LoopbackMode.L2RX2TX)
 713    await port.loop_back.set_l2rx2tx()
 714    await port.loop_back.set(mode=enums.LoopbackMode.L3RX2TX)
 715    await port.loop_back.set_l3rx2tx()
 716    await port.loop_back.set(mode=enums.LoopbackMode.NONE)
 717    await port.loop_back.set_none()
 718    await port.loop_back.set(mode=enums.LoopbackMode.PORT2PORT)
 719    await port.loop_back.set_port2port()
 720    await port.loop_back.set(mode=enums.LoopbackMode.TXOFF2RX)
 721    await port.loop_back.set_txoff2rx()
 722    await port.loop_back.set(mode=enums.LoopbackMode.TXON2RX)
 723    await port.loop_back.set_txon2rx()
 724
 725    resp = await port.loop_back.get()
 726    resp.mode
 727
 728    # BRR Mode
 729    await port.brr_mode.set(mode=enums.BRRMode.MASTER)
 730    await port.brr_mode.set_master()
 731    await port.brr_mode.set(mode=enums.BRRMode.SLAVE)
 732    await port.brr_mode.set_slave()
 733
 734    resp = await port.brr_mode.get()
 735    resp.mode
 736
 737    # MDI/MDIX Mode
 738    await port.mdix_mode.set(mode=enums.MDIXMode.AUTO)
 739    await port.mdix_mode.set_auto()
 740    await port.mdix_mode.set(mode=enums.MDIXMode.MDI)
 741    await port.mdix_mode.set_mdi()
 742    await port.mdix_mode.set(mode=enums.MDIXMode.MDIX)
 743    await port.mdix_mode.set_mdix()
 744
 745    resp = await port.mdix_mode.get()
 746    resp.mode
 747
 748    # EEE- Capabilities
 749    resp = await port.eee.capabilities.get()
 750    resp.eee_capabilities
 751
 752    # EEE - Partner Capabilities
 753    resp = await port.eee.partner_capabilities.get()
 754    resp.cap_1000base_t
 755    resp.cap_100base_kx
 756    resp.cap_10gbase_kr
 757    resp.cap_10gbase_kx4
 758    resp.cap_10gbase_t
 759
 760    # EEE - Control
 761    await port.eee.enable.set(on_off=enums.OnOff.OFF)
 762    await port.eee.enable.set_off()
 763    await port.eee.enable.set(on_off=enums.OnOff.ON)
 764    await port.eee.enable.set_on()
 765
 766    resp = await port.eee.enable.get()
 767    resp.on_off
 768
 769    # EEE - Low Power TX Mode
 770    await port.eee.mode.set(on_off=enums.OnOff.ON)
 771    await port.eee.mode.set_off()
 772    await port.eee.mode.set(on_off=enums.OnOff.OFF)
 773    await port.eee.mode.set_on()
 774
 775    resp = await port.eee.mode.get()
 776    resp.on_off
 777
 778    # EEE - RX Power
 779    resp = await port.eee.rx_power.get()
 780    resp.channel_a
 781    resp.channel_b
 782    resp.channel_c
 783    resp.channel_d
 784
 785    # EEE - SNR Margin
 786    resp = await port.eee.snr_margin.get()
 787    resp.channel_a
 788    resp.channel_b
 789    resp.channel_c
 790    resp.channel_d
 791
 792    # EEE - Status
 793    resp = await port.eee.status.get()
 794    resp.link_up
 795    resp.rxc
 796    resp.rxh
 797    resp.txc
 798    resp.txh
 799
 800    # Fault - Signaling
 801    await port.fault.signaling.set(fault_signaling=enums.FaultSignaling.DISABLED)
 802    await port.fault.signaling.set_disabled()
 803    await port.fault.signaling.set(fault_signaling=enums.FaultSignaling.FORCE_LOCAL)
 804    await port.fault.signaling.set_force_local()
 805    await port.fault.signaling.set(fault_signaling=enums.FaultSignaling.FORCE_REMOTE)
 806    await port.fault.signaling.set_force_remote()
 807    await port.fault.signaling.set(fault_signaling=enums.FaultSignaling.NORMAL)
 808    await port.fault.signaling.set_normal()
 809
 810    resp = await port.fault.signaling.get()
 811    resp.fault_signaling
 812
 813    # Fault - Status
 814    resp = await port.fault.status.get()
 815    resp.local_fault_status
 816    resp.remote_fault_status
 817
 818    # Interface
 819    resp = await port.interface.get()
 820    resp.interface
 821
 822    # Description
 823    await port.comment.set(comment="description")
 824    
 825    resp = await port.comment.get()
 826    resp.comment
 827
 828    # Status
 829    resp = await port.status.get()
 830    resp.optical_power
 831
 832    # Latency Mode
 833    if not isinstance(port, ports.PortChimera):
 834        await port.latency_config.mode.set(mode=enums.LatencyMode.FIRST2FIRST)
 835        await port.latency_config.mode.set_first2first()
 836        await port.latency_config.mode.set(mode=enums.LatencyMode.FIRST2LAST)
 837        await port.latency_config.mode.set_first2last()
 838        await port.latency_config.mode.set(mode=enums.LatencyMode.LAST2FIRST)
 839        await port.latency_config.mode.set_last2first()
 840        await port.latency_config.mode.set(mode=enums.LatencyMode.LAST2LAST)
 841        await port.latency_config.mode.set_last2last()
 842
 843        resp = await port.latency_config.mode.get()
 844        resp.mode
 845
 846    # Latency Offset
 847    if not isinstance(port, ports.PortChimera):
 848        await port.latency_config.offset.set(offset=5)
 849
 850        resp = await port.latency_config.offset.get()
 851        resp.offset
 852    
 853    # Link Flap - Control
 854    await port.pcs_pma.link_flap.enable.set(on_off=enums.OnOff.ON)
 855    await port.pcs_pma.link_flap.enable.set_on()
 856    await port.pcs_pma.link_flap.enable.set(on_off=enums.OnOff.OFF)
 857    await port.pcs_pma.link_flap.enable.set_off()
 858
 859    resp = await port.pcs_pma.link_flap.enable.get()
 860    resp.on_off
 861
 862    # Link Flap - Configuration
 863    await port.pcs_pma.link_flap.params.set(duration=10, period=20, repetition=0)
 864    
 865    resp = await port.pcs_pma.link_flap.params.get()
 866    resp.duration
 867    resp.period
 868    resp.repetition
 869
 870    # Multicast Mode
 871    await port.multicast.mode.set(
 872        ipv4_multicast_addresses=[],
 873        operation=enums.MulticastOperation.JOIN,
 874        second_count=10)
 875    await port.multicast.mode.set(
 876        ipv4_multicast_addresses=[],
 877        operation=enums.MulticastOperation.JOIN,
 878        second_count=10)
 879    await port.multicast.mode.set(
 880        ipv4_multicast_addresses=[],
 881        operation=enums.MulticastOperation.LEAVE,
 882        second_count=10)
 883    await port.multicast.mode.set(
 884        ipv4_multicast_addresses=[],
 885        operation=enums.MulticastOperation.OFF,
 886        second_count=10)
 887    await port.multicast.mode.set(
 888        ipv4_multicast_addresses=[],
 889        operation=enums.MulticastOperation.ON,
 890        second_count=10)
 891
 892    resp = await port.multicast.mode.get()
 893    resp.ipv4_multicast_addresses
 894    resp.operation
 895    resp.second_count
 896
 897    # Multicast Extended Mode
 898    await port.multicast.mode_extended.set(
 899        ipv4_multicast_addresses=[],
 900        operation=enums.MulticastExtOperation.EXCLUDE,
 901        second_count=10,
 902        igmp_version=enums.IGMPVersion.IGMPV3
 903    )
 904    await port.multicast.mode_extended.set(
 905        ipv4_multicast_addresses=[],
 906        operation=enums.MulticastExtOperation.INCLUDE,
 907        second_count=10,
 908        igmp_version=enums.IGMPVersion.IGMPV3
 909    )
 910    await port.multicast.mode_extended.set(
 911        ipv4_multicast_addresses=[],
 912        operation=enums.MulticastExtOperation.JOIN,
 913        second_count=10,
 914        igmp_version=enums.IGMPVersion.IGMPV2
 915    )
 916    await port.multicast.mode_extended.set(
 917        ipv4_multicast_addresses=[],
 918        operation=enums.MulticastExtOperation.LEAVE,
 919        second_count=10,
 920        igmp_version=enums.IGMPVersion.IGMPV2
 921    )
 922    await port.multicast.mode_extended.set(
 923        ipv4_multicast_addresses=[],
 924        operation=enums.MulticastExtOperation.LEAVE_TO_ALL,
 925        second_count=10,
 926        igmp_version=enums.IGMPVersion.IGMPV2
 927    )
 928    await port.multicast.mode_extended.set(
 929        ipv4_multicast_addresses=[],
 930        operation=enums.MulticastExtOperation.GENERAL_QUERY,
 931        second_count=10,
 932        igmp_version=enums.IGMPVersion.IGMPV2
 933    )
 934    await port.multicast.mode_extended.set(
 935        ipv4_multicast_addresses=[],
 936        operation=enums.MulticastExtOperation.GROUP_QUERY,
 937        second_count=10,
 938        igmp_version=enums.IGMPVersion.IGMPV2
 939    )
 940    await port.multicast.mode_extended.set(
 941        ipv4_multicast_addresses=[],
 942        operation=enums.MulticastExtOperation.ON,
 943        second_count=10,
 944        igmp_version=enums.IGMPVersion.IGMPV2
 945    )
 946    await port.multicast.mode_extended.set(
 947        ipv4_multicast_addresses=[],
 948        operation=enums.MulticastExtOperation.OFF,
 949        second_count=10,
 950        igmp_version=enums.IGMPVersion.IGMPV2
 951    )
 952
 953    resp = await port.multicast.mode_extended.get()
 954    resp.ipv4_multicast_addresses
 955    resp.operation
 956    resp.second_count
 957    resp.igmp_version
 958
 959    # Multicast Source List
 960    await port.multicast.source_list.set(ipv4_addresses=[])
 961    
 962    resp = await port.multicast.source_list.get()
 963    resp.ipv4_addresses
 964
 965
 966    # Multicast Header
 967    await port.multicast.header.set(header_count=1, header_format=enums.MulticastHeaderFormat.VLAN, tag=10, pcp=0, dei=0)
 968    await port.multicast.header.set(header_count=0, header_format=enums.MulticastHeaderFormat.NOHDR, tag=10, pcp=0, dei=0)
 969    
 970    resp = await port.multicast.header.get()
 971    resp.header_count
 972    resp.header_format
 973    resp.tag
 974    resp.pcp
 975    resp.dei
 976
 977    # Random Seed
 978    await port.random_seed.set(seed=1)
 979
 980    resp = await port.random_seed.get()
 981    resp.seed
 982
 983    # Checksum Offset
 984    await port.checksum.set(offset=14)
 985
 986    resp = await port.checksum.get()
 987    resp.offset
 988
 989    # Maximum Header Length
 990    await port.max_header_length.set(max_header_length=56)
 991
 992    resp = await port.max_header_length.get()
 993    resp.max_header_length
 994
 995    # MIX Weights
 996    await port.mix.weights.set(
 997        weight_56_bytes:=0,
 998        weight_60_bytes:=0,
 999        weight_64_bytes:=70,
1000        weight_70_bytes:=15,
1001        weight_78_bytes:=15,
1002        weight_92_bytes:=0,
1003        weight_256_bytes:=0,
1004        weight_496_bytes:=0,
1005        weight_512_bytes:=0,
1006        weight_570_bytes:=0,
1007        weight_576_bytes:=0,
1008        weight_594_bytes:=0,
1009        weight_1438_bytes:=0,
1010        weight_1518_bytes:=0,
1011        weight_9216_bytes:=0,
1012        weight_16360_bytes:=0)
1013    
1014    resp = await port.mix.weights.get()
1015    resp.weight_56_bytes
1016    resp.weight_60_bytes
1017    resp.weight_64_bytes
1018    resp.weight_70_bytes
1019    resp.weight_78_bytes
1020    resp.weight_92_bytes
1021    resp.weight_256_bytes
1022    resp.weight_496_bytes
1023    resp.weight_512_bytes
1024    resp.weight_570_bytes
1025    resp.weight_576_bytes
1026    resp.weight_594_bytes
1027    resp.weight_1438_bytes
1028    resp.weight_1518_bytes
1029    resp.weight_9216_bytes
1030    resp.weight_16360_bytes
1031
1032    # MIX Lengths
1033    await port.mix.lengths[0].set(frame_size=56)
1034    await port.mix.lengths[1].set(frame_size=60)
1035    await port.mix.lengths[14].set(frame_size=9216)
1036    await port.mix.lengths[15].set(frame_size=16360)
1037
1038    resp = await port.mix.lengths[0].get()
1039    resp.frame_size
1040    resp = await port.mix.lengths[1].get()
1041    resp.frame_size
1042    resp = await port.mix.lengths[14].get()
1043    resp.frame_size
1044    resp = await port.mix.lengths[15].get()
1045    resp.frame_size
1046
1047    # Payload Mode
1048    await port.payload_mode.set(mode=enums.PayloadMode.NORMAL)
1049    await port.payload_mode.set_normal()
1050    await port.payload_mode.set(mode=enums.PayloadMode.EXTPL)
1051    await port.payload_mode.set_extpl()
1052    await port.payload_mode.set(mode=enums.PayloadMode.CDF)
1053    await port.payload_mode.set_cdf()
1054
1055    resp = await port.payload_mode.get()
1056    resp.mode
1057
1058    # RX Preamble Insert
1059    await port.preamble.rx_insert.set(on_off=enums.OnOff.ON)
1060    await port.preamble.rx_insert.set(on_off=enums.OnOff.OFF)
1061
1062    resp = await port.preamble.rx_insert.get()
1063    resp.on_off
1064
1065    # TX Preamble Removal   
1066    await port.preamble.tx_remove.set(on_off=enums.OnOff.ON)
1067    await port.preamble.tx_remove.set(on_off=enums.OnOff.OFF)
1068
1069    resp = await port.preamble.tx_remove.get()
1070    resp.on_off
1071
1072    # Reservation
1073    await port.reservation.set(operation=enums.ReservedAction.RELEASE)
1074    await port.reservation.set_release()
1075    await port.reservation.set(operation=enums.ReservedAction.RELINQUISH)
1076    await port.reservation.set_relinquish()
1077    await port.reservation.set(operation=enums.ReservedAction.RESERVE)
1078    await port.reservation.set_reserve()
1079
1080    resp = await port.reservation.get()
1081    resp.status
1082    
1083    # Reserved By
1084    resp = await port.reserved_by.get()
1085    resp.username
1086
1087    # Runt - RX Length
1088    await port.runt.rx_length.set(runt_length=40)
1089    
1090    resp = await port.runt.rx_length.get()
1091    resp.runt_length
1092
1093    # Runt - TX Length
1094    await port.runt.tx_length.set(runt_length=40)
1095
1096    resp = await port.runt.tx_length.get()
1097    resp.runt_length
1098
1099    # Runt - Length Error
1100    resp = await port.runt.has_length_errors.get()
1101    resp.status
1102
1103    # Speed Mode Selection
1104    await port.speed.mode.selection.set(mode=enums.PortSpeedMode.AUTO)
1105    await port.speed.mode.selection.set_auto()
1106    await port.speed.mode.selection.set(mode=enums.PortSpeedMode.F10M)
1107    await port.speed.mode.selection.set_f10m()
1108    await port.speed.mode.selection.set(mode=enums.PortSpeedMode.F10M100M)
1109    await port.speed.mode.selection.set_f10m100m()
1110    await port.speed.mode.selection.set(mode=enums.PortSpeedMode.F10MHDX)
1111    await port.speed.mode.selection.set_f10mhdx()
1112    await port.speed.mode.selection.set(mode=enums.PortSpeedMode.F100M)
1113    await port.speed.mode.selection.set_f100m()
1114    await port.speed.mode.selection.set(mode=enums.PortSpeedMode.F100M1G)
1115    await port.speed.mode.selection.set_f100m1g()
1116    await port.speed.mode.selection.set(mode=enums.PortSpeedMode.F100M1G10G)
1117    await port.speed.mode.selection.set_f100m1g10g()
1118    await port.speed.mode.selection.set(mode=enums.PortSpeedMode.F100M1G2500M)
1119    await port.speed.mode.selection.set_f100m1g2500m()
1120    await port.speed.mode.selection.set(mode=enums.PortSpeedMode.F100MHDX)
1121    await port.speed.mode.selection.set_f100mhdx()
1122    await port.speed.mode.selection.set(mode=enums.PortSpeedMode.F1G)
1123    await port.speed.mode.selection.set_f1g()
1124    await port.speed.mode.selection.set(mode=enums.PortSpeedMode.F2500M)
1125    await port.speed.mode.selection.set_f2500m()
1126    await port.speed.mode.selection.set(mode=enums.PortSpeedMode.F5G)
1127    await port.speed.mode.selection.set_f5g()
1128    await port.speed.mode.selection.set(mode=enums.PortSpeedMode.F10G)
1129    await port.speed.mode.selection.set_f10g()
1130    await port.speed.mode.selection.set(mode=enums.PortSpeedMode.F40G)
1131    await port.speed.mode.selection.set_f40g()
1132    await port.speed.mode.selection.set(mode=enums.PortSpeedMode.F100G)
1133    await port.speed.mode.selection.set_f100g()
1134    await port.speed.mode.selection.set(mode=enums.PortSpeedMode.UNKNOWN)
1135    await port.speed.mode.selection.set_unknown()
1136    await port.speed.mode.selection.set(mode=enums.PortSpeedMode.F200G)
1137    await port.speed.mode.selection.set(mode=enums.PortSpeedMode.F400G)
1138    await port.speed.mode.selection.set(mode=enums.PortSpeedMode.F800G)
1139    await port.speed.mode.selection.set(mode=enums.PortSpeedMode.F1600G)
1140
1141    resp = await port.speed.mode.selection.get()
1142    resp.mode
1143
1144    # Supported Speed Modes
1145    resp = await port.speed.mode.supported.get()
1146    resp.auto
1147    resp.f10M
1148    resp.f100M
1149    resp.f1G
1150    resp.f10G
1151    resp.f40G
1152    resp.f100G
1153    resp.f10MHDX
1154    resp.f100MHDX
1155    resp.f10M100M
1156    resp.f100M1G
1157    resp.f100M1G10G
1158    resp.f2500M
1159    resp.f5G
1160    resp.f100M1G2500M
1161    resp.f25G
1162    resp.f50G
1163    resp.f200G
1164    resp.f400G
1165    resp.f800G
1166    resp.f1600G
1167
1168    # Current Speed
1169    resp = await port.speed.current.get()
1170    resp.port_speed
1171
1172    # Speed Reduction
1173    await port.speed.reduction.set(ppm=100)
1174    
1175    resp = await port.speed.reduction.get()
1176    resp.ppm
1177
1178    # Sync Status
1179    resp = await port.sync_status.get()
1180    resp.sync_status == enums.SyncStatus.IN_SYNC
1181    resp.sync_status == enums.SyncStatus.NO_SYNC
1182
1183    # Transceiver Status
1184    resp = await port.tcvr_status.get()
1185    resp.rx_loss_lane_0
1186    resp.rx_loss_lane_1
1187    resp.rx_loss_lane_2
1188    resp.rx_loss_lane_3
1189
1190    # Transceiver Read & Write
1191    my_int = 1234
1192    await port.transceiver.access_rw(page_address=0, register_address=0).set(value=hex(my_int)[2:])
1193    
1194    resp = await port.transceiver.access_rw(page_address=0, register_address=0).get()
1195    resp.value
1196    my_int_resp = int(resp.value, 16)
1197    print(f"Returned value: {my_int_resp}")
1198
1199    # Transceiver Sequential Read & Write
1200    await port.transceiver.access_rw_seq(page_address=0, register_address=0, byte_count=4).set(value=Hex("00FF00FF"))
1201    
1202    resp = await port.transceiver.access_rw_seq(page_address=0, register_address=0, byte_count=4).get()
1203    resp.value
1204
1205    # Transceiver MII
1206    await port.transceiver.access_mii(register_address=0).set(value=Hex("00"))
1207    
1208    resp = await port.transceiver.access_mii(register_address=0).get()
1209    resp.value
1210
1211    # Transceiver Temperature
1212    resp = await port.transceiver.access_temperature().get()
1213    resp.integral_part
1214    resp.fractional_part
1215
1216    # Transceiver RX Laser Power
1217    resp = await port.pcs_pma.transceiver.rx_laser_power.get()
1218    resp.nanowatts
1219
1220    # Transceiver TX Laser Power
1221    resp = await port.pcs_pma.transceiver.tx_laser_power.get()
1222    resp.nanowatts
1223
1224    # Traffic Control - Rate Percent
1225    await port.rate.fraction.set(port_rate_ppm=1_000_000)
1226    
1227    resp = await port.rate.fraction.get()
1228    resp.port_rate_ppm
1229
1230    # Traffic Control - Rate L2 Bits Per Second
1231    await port.rate.l2_bps.set(port_rate_bps=1_000_000)
1232
1233    resp = await port.rate.l2_bps.get()
1234    resp.port_rate_bps
1235
1236    # Traffic Control - Rate Frames Per Second
1237    await port.rate.pps.set(port_rate_pps=10_000)
1238    
1239    resp = await port.rate.pps.get()
1240    resp.port_rate_pps
1241
1242    # Traffic Control - Start and Stop
1243    await port.traffic.state.set(on_off=enums.StartOrStop.START)
1244    await port.traffic.state.set_start()
1245    await port.traffic.state.set(on_off=enums.StartOrStop.STOP)
1246    await port.traffic.state.set_stop()
1247
1248    resp = await port.traffic.state.get()
1249    resp.on_off
1250
1251    # Traffic Control - Traffic Error
1252    resp = await port.traffic.error.get()
1253    resp.error
1254
1255    # Traffic Control - Single Frame TX
1256    await port.tx_single_pkt.send.set(hex_data=Hex("00000000000102030405060800FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"))
1257
1258    # Traffic Control - Single Frame Time
1259    resp = await port.tx_single_pkt.time.get()
1260    resp.nanoseconds
1261
1262    # TPLD Mode
1263    await port.tpld_mode.set(mode=enums.TPLDMode.NORMAL)
1264    await port.tpld_mode.set_normal()
1265    await port.tpld_mode.set(mode=enums.TPLDMode.MICRO)
1266    await port.tpld_mode.set_micro()
1267
1268    resp = await port.tpld_mode.get()
1269    resp.mode
1270
1271    # TX Mode
1272    await port.tx_config.mode.set(mode=enums.TXMode.NORMAL)
1273    await port.tx_config.mode.set_normal()
1274    await port.tx_config.mode.set(mode=enums.TXMode.BURST)
1275    await port.tx_config.mode.set_burst()
1276    await port.tx_config.mode.set(mode=enums.TXMode.SEQUENTIAL)
1277    await port.tx_config.mode.set_sequential()
1278    await port.tx_config.mode.set(mode=enums.TXMode.STRICTUNIFORM)
1279    await port.tx_config.mode.set_strictuniform()
1280
1281    resp = await port.tx_config.mode.get()
1282    resp.mode
1283
1284    # Burst Period
1285    await port.tx_config.burst_period.set(burst_period=100)
1286    
1287    resp = await port.tx_config.burst_period.get()
1288    resp.burst_period
1289
1290    # TX Delay
1291    await port.tx_config.delay.set(delay_val=100)
1292
1293    resp = await port.tx_config.delay.get()
1294    resp.delay_val
1295
1296    # TX Enable
1297    await port.tx_config.enable.set(on_off=enums.OnOff.ON)
1298    await port.tx_config.enable.set(on_off=enums.OnOff.OFF)
1299    
1300    resp = await port.tx_config.enable.get()
1301    resp.on_off
1302
1303    # Packet Limit
1304    await port.tx_config.packet_limit.set(packet_count_limit=1_000_000)
1305    
1306    resp = await port.tx_config.packet_limit.get()
1307    resp.packet_count_limit
1308
1309    # Time Limit
1310    await port.tx_config.time_limit.set(microseconds=1_000_000)
1311    
1312    resp = await port.tx_config.time_limit.get()
1313    resp.microseconds
1314
1315    # TX Time Elapsed
1316    resp = await port.tx_config.time.get()
1317    resp.microseconds
1318
1319    # Prepare TX
1320    await port.tx_config.prepare.set()
1321
1322    # Dynamic Traffic Rate
1323    await port.dynamic.set(on_off=enums.OnOff.OFF)
1324    await port.dynamic.set_off()
1325    await port.dynamic.set(on_off=enums.OnOff.ON)
1326    await port.dynamic.set_on()
1327    
1328    resp = await port.dynamic.get()
1329    resp.on_off
1330
1331    await port.uat.mode.set(mode=enums.OnOff.ON, delay=500)
1332    await port.uat.mode.set(mode=enums.OnOff.OFF, delay=500)
1333    await port.uat.frame_loss_ratio.get()
1334
1335    #################################################
1336    #                 Port Filter                   #
1337    #################################################
1338    
1339    # Create and Obtain
1340    # Create a filter on the port, and obtain the filter object. The filter index is automatically assigned by the port.
1341    filter = await port.filters.create()
1342
1343    # Obtain One or Multiple
1344    filter = port.filters.obtain(position_idx=0)
1345    filter_list = port.filters.obtain_multiple(*[0,1,2])
1346
1347    # Remove
1348    # Remove a filter on the port with an explicit filter index by the index manager of the port.
1349    await port.filters.remove(position_idx=0)
1350
1351    # Filter - Enable
1352    await filter.enable.set(on_off=enums.OnOff.ON)
1353    await filter.enable.set_on()
1354    await filter.enable.set(on_off=enums.OnOff.OFF)
1355    await filter.enable.set_off()
1356
1357    resp = await filter.enable.get()
1358    resp.on_off
1359
1360    # Filter - Description
1361    await filter.comment.set(comment="this is a comment")
1362
1363    resp = await filter.comment.get()
1364    resp.comment
1365
1366    # Filter - Condition
1367    await filter.condition.set(and_expression_0=0, and_not_expression_0=0, and_expression_1=1, and_not_expression_1=0, and_expression_2=0, and_expression_3=0)
1368    
1369    resp = await filter.condition.get()
1370    resp.and_expression_0
1371    resp.and_not_expression_0
1372    resp.and_expression_1
1373    resp.and_not_expression_1
1374    resp.and_expression_2
1375    resp.and_expression_3
1376
1377    # Filter - String Representation
1378    await filter.string.set(string_name="this is name")
1379
1380    resp = await filter.string.get()
1381    resp.string_name
1382
1383    #################################################
1384    #               Port Length Term                #
1385    #################################################
1386
1387    # Create and Obtain
1388    # Create a length term on the port, and obtain the length term object. The length term index is automatically assigned by the port.
1389    length_term = await port.length_terms.create()
1390    
1391    # Obtain One or Multiple
1392    length_term = port.length_terms.obtain(key=0)
1393    length_term_list = port.length_terms.obtain_multiple(*[0,1,2])
1394
1395    # Remove
1396    # Remove a length term on the port with an explicit length term index by the index manager of the port.
1397    await port.length_terms.remove(position_idx=0)
1398
1399    #################################################
1400    #               Port Match Term                 #
1401    #################################################
1402
1403    # Create and Obtain
1404    # Create a match term on the port, and obtain the match term object. The match term index is automatically assigned by the port.
1405    match_term = await port.match_terms.create()
1406    
1407    # Obtain One or Multiple
1408    length_term = port.match_terms.obtain(key=0)
1409    length_term_list = port.match_terms.obtain_multiple(*[0,1,2])
1410
1411    # Remove
1412    # Remove a match term on the port with an explicit match term index by the index manager of the port.
1413    await port.match_terms.remove(position_idx=0)
1414
1415    #################################################
1416    #               Port Histogram                  #
1417    #################################################
1418
1419    # Create and Obtain
1420    # Create a histogram on the port, and obtain the histogram object. The histogram index is automatically assigned by the port.
1421    dataset = await port.datasets.create()
1422    
1423    # Obtain One or Multiple
1424    length_term = port.datasets.obtain(key=0)
1425    length_term_list = port.datasets.obtain_multiple(*[0,1,2])
1426
1427    # Remove
1428    # Remove a histogram on the port with an explicit histogram index by the index manager of the port.
1429    await port.datasets.remove(position_idx=0)
1430
1431    #################################################
1432    #               Port PCS/PMA                   #
1433    #################################################
1434
1435    # Auto-Negotiation Settings
1436    resp = await port.pcs_pma.auto_neg.settings.get()
1437    resp.tec_ability
1438    resp.fec_capable
1439    resp.fec_requested
1440    resp.pause_mode
1441
1442    # Auto-Negotiation Status
1443    resp = await port.pcs_pma.auto_neg.status.get()
1444    resp.mode
1445    resp.auto_state
1446    resp.tec_ability
1447    resp.fec_capable
1448    resp.fec_requested
1449    resp.fec
1450    resp.pause_mode
1451
1452    # Auto-Negotiation Selection
1453    # Only applicable to RJ45 ports
1454    await port.autoneg_selection.set(on_off=enums.OnOff.ON)
1455    await port.autoneg_selection.set_on()
1456    await port.autoneg_selection.set(on_off=enums.OnOff.OFF)
1457    await port.autoneg_selection.set_off()
1458
1459    resp = await port.autoneg_selection.get()
1460    resp.on_off
1461
1462    # FEC Mode
1463    await port.pcs_pma.phy.auto_neg.set(fec_mode=enums.OnOff.ON,reserved_1=0, reserved_2=0, reserved_3=0, reserved_4=0)
1464
1465    await port.fec_mode.set(mode=enums.FECMode.RS_FEC)
1466    await port.fec_mode.set(mode=enums.FECMode.RS_FEC_KP)
1467    await port.fec_mode.set(mode=enums.FECMode.RS_FEC_KR)
1468    await port.fec_mode.set(mode=enums.FECMode.FC_FEC)
1469    await port.fec_mode.set(mode=enums.FECMode.OFF)
1470    await port.fec_mode.set(mode=enums.FECMode.ON)
1471
1472    resp = await port.fec_mode.get()
1473    resp.mode
1474
1475    # Link Training Settings
1476    await port.pcs_pma.link_training.settings.set(
1477        mode=enums.LinkTrainingMode.DISABLED, 
1478        pam4_frame_size=enums.PAM4FrameSize.P4K_FRAME, 
1479        nrz_pam4_init_cond=enums.LinkTrainingInitCondition.NO_INIT, 
1480        nrz_preset=enums.NRZPreset.NRZ_WITH_PRESET, 
1481        timeout_mode=enums.TimeoutMode.DEFAULT)
1482    await port.pcs_pma.link_training.settings.set(
1483        mode=enums.LinkTrainingMode.STANDALONE, 
1484        pam4_frame_size=enums.PAM4FrameSize.P4K_FRAME, 
1485        nrz_pam4_init_cond=enums.LinkTrainingInitCondition.NO_INIT, 
1486        nrz_preset=enums.NRZPreset.NRZ_WITH_PRESET, 
1487        timeout_mode=enums.TimeoutMode.DEFAULT)
1488    await port.pcs_pma.link_training.settings.set(
1489        mode=enums.LinkTrainingMode.INTERACTIVE, 
1490        pam4_frame_size=enums.PAM4FrameSize.P4K_FRAME, 
1491        nrz_pam4_init_cond=enums.LinkTrainingInitCondition.NO_INIT, 
1492        nrz_preset=enums.NRZPreset.NRZ_WITH_PRESET, 
1493        timeout_mode=enums.TimeoutMode.DISABLED)
1494    await port.pcs_pma.link_training.settings.set(
1495        mode=enums.LinkTrainingMode.START_AFTER_AUTONEG, 
1496        pam4_frame_size=enums.PAM4FrameSize.P4K_FRAME, 
1497        nrz_pam4_init_cond=enums.LinkTrainingInitCondition.NO_INIT, 
1498        nrz_preset=enums.NRZPreset.NRZ_WITH_PRESET, 
1499        timeout_mode=enums.TimeoutMode.DEFAULT)
1500
1501    resp = await port.pcs_pma.link_training.settings.get()
1502    resp.mode
1503    resp.pam4_frame_size
1504    resp.nrz_pam4_init_cond
1505    resp.nrz_preset
1506    resp.timeout_mode
1507
1508    # Link Training Serdes Status
1509    resp = await port.pcs_pma.link_training.per_lane_status[0].get()
1510    resp.mode
1511    resp.failure
1512    resp.status
1513
1514    # PMA Pulse Error Inject Control
1515    await port.pcs_pma.pma_pulse_err_inj.enable.set(on_off=enums.OnOff.ON)
1516    await port.pcs_pma.pma_pulse_err_inj.enable.set_on()
1517    await port.pcs_pma.pma_pulse_err_inj.enable.set(on_off=enums.OnOff.OFF)
1518    await port.pcs_pma.pma_pulse_err_inj.enable.set_off()
1519
1520    resp = await port.pcs_pma.pma_pulse_err_inj.enable.get()
1521    resp.on_off
1522
1523    # PMA Pulse Error Inject Configuration
1524    await port.pcs_pma.pma_pulse_err_inj.params.set(duration=1000, period=1000, repetition=10, coeff=5, exp=-5)
1525    
1526    resp = await port.pcs_pma.pma_pulse_err_inj.params.get()
1527    resp.duration
1528    resp.period
1529    resp.coeff
1530    resp.exp
1531
1532    # RX Status - Lane Error Counters
1533    resp = await port.pcs_pma.lanes[0].rx_status.errors.get()
1534    resp.alignment_error_count
1535    resp.corrected_fec_error_count
1536    resp.header_error_count
1537
1538    # RX Status - Lock Status
1539    resp = await port.pcs_pma.lanes[0].rx_status.lock.get()
1540    resp.align_lock
1541    resp.header_lock
1542
1543    # RX Status - Lane Status
1544    resp = await port.pcs_pma.lanes[0].rx_status.status.get()
1545    resp.skew
1546    resp.virtual_lane
1547
1548    # RX Status - Clear Counters
1549    await port.pcs_pma.rx.clear.set()
1550
1551    # RX Status - RX FEC Stats
1552    resp = await port.pcs_pma.rx.fec_status.get()
1553    resp.stats_type
1554    resp.data_count
1555    resp.stats
1556
1557    # RX Status - RX Total Stats
1558    resp = await port.pcs_pma.rx.total_status.get()
1559    resp.total_corrected_codeword_count
1560    resp.total_corrected_symbol_count
1561    resp.total_post_fec_ber
1562    resp.total_pre_fec_ber
1563    resp.total_rx_bit_count
1564    resp.total_rx_codeword_count
1565    resp.total_uncorrectable_codeword_count
1566
1567    # TX Configuration - Error Counters
1568    resp = await port.pcs_pma.alarms.errors.get()
1569    resp.total_alarms
1570    resp.los_error_count
1571    resp.total_align_error_count
1572    resp.total_bip_error_count
1573    resp.total_fec_error_count
1574    resp.total_header_error_count
1575    resp.total_higher_error_count
1576    resp.total_pcs_error_count
1577    resp.valid_mask
1578
1579    # TX Configuration - Error Generation Rate
1580    resp = await port.pcs_pma.error_gen.error_rate.get()
1581    resp.rate
1582
1583    # TX Configuration - Error Generation Inject
1584    await port.pcs_pma.error_gen.inject_one.set()
1585
1586    # TX Configuration - Error Injection
1587    await port.pcs_pma.lanes[0].tx_error_inject.set_alignerror()
1588    await port.pcs_pma.lanes[0].tx_error_inject.set_bip8error()
1589    await port.pcs_pma.lanes[0].tx_error_inject.set_headererror()
1590
1591    # TX Configuration - Lane Configuration
1592    await port.pcs_pma.lanes[0].tx_config.set(virt_lane_index=1, skew=10)
1593    
1594    resp = await port.pcs_pma.lanes[0].tx_config.get()
1595    resp.virt_lane_index
1596    resp.skew
1597
1598    #################################################
1599    #               Port Medium                     #
1600    #################################################
1601
1602    # Eye Diagram Information
1603    resp = await port.serdes[0].eye_diagram.info.get()
1604    resp.width_mui
1605    resp.height_mv
1606    resp.h_slope_left
1607    resp.h_slope_right
1608    resp.y_intercept_left
1609    resp.y_intercept_right
1610    resp.r_squared_fit_left
1611    resp.r_squared_fit_right
1612    resp.est_rj_rms_left
1613    resp.est_rj_rms_right
1614    resp.est_dj_pp
1615    resp.v_slope_bottom
1616    resp.v_slope_top
1617    resp.x_intercept_bottom
1618    resp.x_intercept_top
1619    resp.r_squared_fit_bottom
1620    resp.r_squared_fit_top
1621    resp.est_rj_rms_bottom
1622    resp.est_rj_rms_top
1623    
1624    # Eye Diagram Bit Error Rate
1625    resp = await port.serdes[0].eye_diagram.ber.get()
1626    resp.eye_ber_estimation
1627
1628    # Eye Diagram Dwell Bits
1629    resp = await port.serdes[0].eye_diagram.dwell_bits.get()
1630    resp.max_dwell_bit_count
1631    resp.min_dwell_bit_count
1632
1633    # Eye Diagram Measure
1634    resp = await port.serdes[0].eye_diagram.measure.get()
1635    resp.status
1636
1637    # Eye Diagram Resolution
1638    resp = await port.serdes[0].eye_diagram.resolution.get()
1639    resp.x_resolution
1640    resp.y_resolution
1641
1642    # Eye Diagram Data Columns
1643    resp = await port.serdes[0].eye_diagram.read_column[0].get()
1644    resp.valid_column_count
1645    resp.values
1646    resp.x_resolution
1647    resp.y_resolution
1648
1649    # PHY - Signal Status
1650    resp = await port.pcs_pma.phy.signal_status.get()
1651    resp.phy_signal_status
1652
1653    # PHY - Settings
1654    await port.pcs_pma.phy.settings.set(
1655        link_training_on_off=enums.OnOff.ON, 
1656        precode_on_off=enums.OnOffDefault.DEFAULT, 
1657        graycode_on_off=enums.OnOff.OFF, pam4_msb_lsb_swap=enums.OnOff.OFF)
1658    
1659    resp = await port.pcs_pma.phy.settings.get()
1660    resp.link_training_on_off
1661    resp.precode_on_off
1662    resp.graycode_on_off
1663    resp.pam4_msb_lsb_swap
1664
1665    # TX Tap Autotune
1666    await port.serdes[0].phy.autotune.set(on_off=enums.OnOff.ON)
1667    await port.serdes[0].phy.autotune.set_on()
1668    await port.serdes[0].phy.autotune.set(on_off=enums.OnOff.OFF)
1669    await port.serdes[0].phy.autotune.set_off()
1670
1671    resp = await port.serdes[0].phy.autotune.get()
1672    resp.on_off
1673
1674    # TX Tap Retune
1675    await port.serdes[0].phy.retune.set(dummy=1)
1676
1677    # TX Tap Configuration
1678    await port.serdes[0].phy.tx_equalizer.set(pre2=0, pre1=0, main=86, post1=0, post2=0, post3=0)
1679    resp = await port.serdes[0].phy.tx_equalizer.get()
1680    resp.pre2
1681    resp.pre
1682    resp.main
1683    resp.post
1684    resp.pre3_post2
1685    resp.post3
1686
1687    # RX Tap Configuration
1688    await port.serdes[0].phy.rx_equalizer.set(auto=0, ctle=0, reserved=0)
1689    
1690    resp = await port.serdes[0].phy.rx_equalizer.get()
1691    resp.auto
1692    resp.ctle
1693
1694    #################################################
1695    #               Port PRBS                       #
1696    #################################################
1697
1698    # PRBS Configuration
1699    await port.serdes[0].prbs.config.type.set(
1700        prbs_inserted_type=enums.PRBSInsertedType.PHY_LINE, 
1701        polynomial=enums.PRBSPolynomial.PRBS7, 
1702        invert=enums.PRBSInvertState.NON_INVERTED, 
1703        statistics_mode=enums.PRBSStatisticsMode.ACCUMULATIVE)
1704    await port.serdes[0].prbs.config.type.set(
1705        prbs_inserted_type=enums.PRBSInsertedType.CAUI_VIRTUAL, 
1706        polynomial=enums.PRBSPolynomial.PRBS9, 
1707        invert=enums.PRBSInvertState.NON_INVERTED, 
1708        statistics_mode=enums.PRBSStatisticsMode.PERSECOND)
1709    await port.serdes[0].prbs.config.type.set(
1710        prbs_inserted_type=enums.PRBSInsertedType.PHY_LINE, 
1711        polynomial=enums.PRBSPolynomial.PRBS10, 
1712        invert=enums.PRBSInvertState.NON_INVERTED, 
1713        statistics_mode=enums.PRBSStatisticsMode.ACCUMULATIVE)
1714    await port.serdes[0].prbs.config.type.set(
1715        prbs_inserted_type=enums.PRBSInsertedType.PHY_LINE, 
1716        polynomial=enums.PRBSPolynomial.PRBS11, 
1717        invert=enums.PRBSInvertState.NON_INVERTED, 
1718        statistics_mode=enums.PRBSStatisticsMode.ACCUMULATIVE)
1719    await port.serdes[0].prbs.config.type.set(
1720        prbs_inserted_type=enums.PRBSInsertedType.PHY_LINE, 
1721        polynomial=enums.PRBSPolynomial.PRBS13, 
1722        invert=enums.PRBSInvertState.NON_INVERTED, 
1723        statistics_mode=enums.PRBSStatisticsMode.ACCUMULATIVE)
1724    await port.serdes[0].prbs.config.type.set(
1725        prbs_inserted_type=enums.PRBSInsertedType.PHY_LINE, 
1726        polynomial=enums.PRBSPolynomial.PRBS15, 
1727        invert=enums.PRBSInvertState.NON_INVERTED, 
1728        statistics_mode=enums.PRBSStatisticsMode.ACCUMULATIVE)
1729    await port.serdes[0].prbs.config.type.set(
1730        prbs_inserted_type=enums.PRBSInsertedType.PHY_LINE, 
1731        polynomial=enums.PRBSPolynomial.PRBS20, 
1732        invert=enums.PRBSInvertState.NON_INVERTED, 
1733        statistics_mode=enums.PRBSStatisticsMode.ACCUMULATIVE)
1734    await port.serdes[0].prbs.config.type.set(
1735        prbs_inserted_type=enums.PRBSInsertedType.PHY_LINE, 
1736        polynomial=enums.PRBSPolynomial.PRBS23, 
1737        invert=enums.PRBSInvertState.NON_INVERTED, 
1738        statistics_mode=enums.PRBSStatisticsMode.ACCUMULATIVE)
1739    await port.serdes[0].prbs.config.type.set(
1740        prbs_inserted_type=enums.PRBSInsertedType.PHY_LINE, 
1741        polynomial=enums.PRBSPolynomial.PRBS31, 
1742        invert=enums.PRBSInvertState.NON_INVERTED, 
1743        statistics_mode=enums.PRBSStatisticsMode.ACCUMULATIVE)
1744    await port.serdes[0].prbs.config.type.set(
1745        prbs_inserted_type=enums.PRBSInsertedType.PHY_LINE, 
1746        polynomial=enums.PRBSPolynomial.PRBS49, 
1747        invert=enums.PRBSInvertState.NON_INVERTED, 
1748        statistics_mode=enums.PRBSStatisticsMode.ACCUMULATIVE)
1749    await port.serdes[0].prbs.config.type.set(
1750        prbs_inserted_type=enums.PRBSInsertedType.PHY_LINE, 
1751        polynomial=enums.PRBSPolynomial.PRBS58, 
1752        invert=enums.PRBSInvertState.NON_INVERTED, 
1753        statistics_mode=enums.PRBSStatisticsMode.ACCUMULATIVE)
1754
1755    resp = await port.serdes[0].prbs.config.type.get()
1756    resp.prbs_inserted_type
1757    resp.polynomial
1758    resp.invert
1759    resp.statistics_mode
1760
1761
1762    # PRBS Statistics
1763    resp = await port.serdes[0].prbs.status.get()
1764    resp.byte_count
1765    resp.error_count
1766    resp.lock
1767# endregion
1768
1769# region Statistics 
1770    #################################################
1771    #               Statistics                      #
1772    #################################################
1773
1774    # Error Counter
1775    resp = await port.errors_count.get()
1776    resp.error_count
1777
1778    # RX Statistics - Clear Counter
1779    await port.statistics.rx.clear.set()
1780
1781    # RX Statistics - Calibrate
1782    await port.statistics.rx.calibrate.set()
1783
1784    # RX Statistics - Total Counter
1785    resp = await port.statistics.rx.total.get()
1786    resp.byte_count_since_cleared
1787    resp.packet_count_since_cleared
1788    resp.bit_count_last_sec
1789    resp.packet_count_last_sec
1790
1791    # RX Statistics - Non-TPLD Counter
1792    resp = await port.statistics.rx.no_tpld.get()
1793    resp.byte_count_since_cleared
1794    resp.packet_count_since_cleared
1795    resp.bit_count_last_sec
1796    resp.packet_count_last_sec
1797
1798    # RX Statistics - PFC Counter
1799    resp = await port.statistics.rx.pfc_stats.get()
1800    resp.packet_count
1801    resp.quanta_pri_0
1802    resp.quanta_pri_1
1803    resp.quanta_pri_2
1804    resp.quanta_pri_3
1805    resp.quanta_pri_4
1806    resp.quanta_pri_5
1807    resp.quanta_pri_6
1808    resp.quanta_pri_7
1809
1810    # RX Statistics - Extra Counter
1811    resp = await port.statistics.rx.extra.get()
1812    resp.fcs_error_count
1813    resp.pause_frame_count
1814    resp.gap_count
1815    resp.gap_duration
1816    resp.pause_frame_count
1817    resp.rx_arp_reply_count
1818    resp.rx_arp_request_count
1819    resp.rx_ping_reply_count
1820    resp.rx_ping_request_count
1821
1822    # RX Statistics - Received TPLDs
1823    await port.statistics.rx.obtain_available_tplds()
1824
1825    # RX Statistics - TPLD - Error Counter
1826    resp = await port.statistics.rx.access_tpld(tpld_id=0).errors.get()
1827    resp.non_incre_payload_packet_count
1828    resp.non_incre_seq_event_count
1829    resp.swapped_seq_misorder_event_count
1830
1831    # RX Statistics - TPLD - Latency Counter
1832    resp = await port.statistics.rx.access_tpld(tpld_id=0).latency.get()
1833    resp.avg_last_sec
1834    resp.max_last_sec
1835    resp.min_last_sec
1836    resp.avg_val
1837    resp.max_val
1838    resp.min_val
1839
1840    # RX Statistics - TPLD - Jitter Counter
1841    resp = await port.statistics.rx.access_tpld(tpld_id=0).jitter.get()
1842    resp.avg_last_sec
1843    resp.max_last_sec
1844    resp.min_last_sec
1845    resp.avg_val
1846    resp.max_val
1847    resp.min_val
1848
1849    # RX Statistics - TPLD - Traffic Counter
1850    resp = await port.statistics.rx.access_tpld(tpld_id=0).traffic.get()
1851    resp.byte_count_since_cleared
1852    resp.packet_count_since_cleared
1853    resp.bit_count_last_sec
1854    resp.packet_count_last_sec
1855
1856    # RX Statistics - Filter Statistics
1857    resp = await port.statistics.rx.obtain_filter_statistics(filter=0).get()
1858    resp.byte_count_since_cleared
1859    resp.packet_count_since_cleared
1860    resp.bit_count_last_sec
1861    resp.packet_count_last_sec
1862
1863    # TX Statistics - Clear Counter
1864    await port.statistics.tx.clear.set()
1865
1866    # TX Statistics - Total Counter
1867    resp = await port.statistics.tx.total.get()
1868    resp.byte_count_since_cleared
1869    resp.packet_count_since_cleared
1870    resp.bit_count_last_sec
1871    resp.packet_count_last_sec
1872
1873    # TX Statistics - Non-TPLD Counter
1874    resp = await port.statistics.tx.no_tpld.get()
1875    resp.byte_count_since_cleared
1876    resp.packet_count_since_cleared
1877    resp.bit_count_last_sec
1878    resp.packet_count_last_sec
1879
1880    # TX Statistics - Extra Counter
1881    resp = await port.statistics.tx.extra.get()
1882    resp.tx_arp_req_count
1883
1884    # TX Statistics - Stream Counter
1885    resp = await port.statistics.tx.obtain_from_stream(stream=0).get()
1886    resp.byte_count_since_cleared
1887    resp.packet_count_since_cleared
1888    resp.bit_count_last_sec
1889    resp.packet_count_last_sec
1890# endregion
1891
1892# region Stream
1893    #################################################
1894    #                   Stream                      #
1895    #################################################
1896
1897    # Create and Obtain
1898    # Create a stream on the port, and obtain the stream object. The stream index is automatically assigned by the port.
1899    stream = await port.streams.create()
1900
1901    # Obtain One or Multiple
1902    stream = port.streams.obtain(0)
1903    stream_list = port.streams.obtain_multiple(*[0,1,2])
1904
1905    # Remove
1906    # Remove a stream on the port with an explicit stream index.
1907    await port.streams.remove(position_idx=0)
1908
1909    # Description
1910    await stream.comment.set(comment="description")
1911    
1912    resp = await stream.comment.get()
1913    resp.comment
1914
1915    # Test Payload ID
1916    await stream.tpld_id.set(test_payload_identifier=0)
1917    
1918    resp = await stream.tpld_id.get()
1919    resp.test_payload_identifier
1920
1921    # State
1922    await stream.enable.set(state=enums.OnOffWithSuppress.OFF)
1923    await stream.enable.set_off()
1924    await stream.enable.set(state=enums.OnOffWithSuppress.ON)
1925    await stream.enable.set_on()
1926    await stream.enable.set(state=enums.OnOffWithSuppress.SUPPRESS)
1927    await stream.enable.set_suppress()
1928
1929    resp = await stream.enable.get()
1930    resp.state
1931
1932    # Header Protocol Segment
1933    await stream.packet.header.protocol.set(segments=[
1934        enums.ProtocolOption.ETHERNET,
1935        enums.ProtocolOption.VLAN,
1936        enums.ProtocolOption.IP,
1937        enums.ProtocolOption.UDP,
1938    ])
1939
1940    # ETHERNET = 1
1941    # """Ethernet II"""
1942    # VLAN = 2
1943    # """VLAN"""
1944    # ARP = 3
1945    # """Address Resolution Protocol"""
1946    # IP = 4
1947    # """IPv4"""
1948    # IPV6 = 5
1949    # """IPv6"""
1950    # UDP = 6
1951    # """User Datagram Protocol (w/o checksum)"""
1952    # TCP = 7
1953    # """Transmission Control Protocol (w/o checksum)"""
1954    # LLC = 8
1955    # """Logic Link Control"""
1956    # SNAP = 9
1957    # """Subnetwork Access Protocol"""
1958    # GTP = 10
1959    # """GPRS Tunnelling Protocol"""
1960    # ICMP = 11
1961    # """Internet Control Message Protocol"""
1962    # RTP = 12
1963    # """Real-time Transport Protocol"""
1964    # RTCP = 13
1965    # """RTP Control Protocol"""
1966    # STP = 14
1967    # """Spanning Tree Protocol"""
1968    # SCTP = 15
1969    # """Stream Control Transmission Protocol"""
1970    # MACCTRL = 16
1971    # """MAC Control"""
1972    # MPLS = 17
1973    # """Multiprotocol Label Switching"""
1974    # PBBTAG = 18
1975    # """Provider Backbone Bridge tag"""
1976    # FCOE = 19
1977    # """Fibre Channel over Ethernet"""
1978    # FC = 20
1979    # """Fibre Channel"""
1980    # FCOETAIL = 21
1981    # """Fibre Channel over Ethernet (tail)"""
1982    # IGMPV3L0 = 22
1983    # """IGMPv3 Membership Query L=0"""
1984    # IGMPV3L1 = 23
1985    # """IGMPv3 Membership Query L=1"""
1986    # UDPCHECK = 24
1987    # """User Datagram Protocol (w/ checksum)"""
1988    # IGMPV2 = 25
1989    # """Internet Group Management Protocol v2"""
1990    # MPLS_TP_OAM = 26
1991    # """MPLS-TP, OAM Header"""
1992    # GRE_NOCHECK = 27
1993    # """Generic Routing Encapsulation (w/o checksum)"""
1994    # GRE_CHECK = 28
1995    # """Generic Routing Encapsulation (w/ checksum)"""
1996    # TCPCHECK = 29
1997    # """Transmission Control Protocol (w/ checksum)"""
1998    # GTPV1L0 = 30
1999    # """GTPv1 (no options), GPRS Tunneling Protocol v1"""
2000    # GTPV1L1 = 31
2001    # """GTPv1 (w/ options), GPRS Tunneling Protocol v1"""
2002    # GTPV2L0 = 32
2003    # """GTPv2 (no options), GPRS Tunneling Protocol v2"""
2004    # GTPV2L1 = 33
2005    # """GTPv2 (w/ options), GPRS Tunneling Protocol v2"""
2006    # IGMPV1 = 34
2007    # """Internet Group Management Protocol v1"""
2008    # PWETHCTRL = 35
2009    # """PW Ethernet Control Word"""
2010    # VXLAN = 36
2011    # """Virtual eXtensible LAN"""
2012    # ETHERNET_8023 = 37
2013    # """Ethernet 802.3"""
2014    # NVGRE = 38
2015    # """Generic Routing Encapsulation (Network Virtualization)"""
2016    # DHCPV4 = 39
2017    # """Dynamic Host Configuration Protocol (IPv4)"""
2018    # GENEVE = 40
2019    # """Generic Network Virtualization Encapsulation"""
2020
2021    resp = await stream.packet.header.protocol.get()
2022    resp.segments
2023
2024    # Header Value
2025    await stream.packet.header.data.set(
2026        hex_data=Hex("00000000000004F4BC7FFE908100000008004500002A000000007F113BC400000000000000000000000000160000"))
2027    
2028    resp = await stream.packet.header.data.get()
2029    resp.hex_data
2030
2031    # Packet Size
2032    await stream.packet.length.set(length_type=enums.LengthType.FIXED, min_val=64, max_val=64)
2033    await stream.packet.length.set(length_type=enums.LengthType.INCREMENTING, min_val=64, max_val=1500)
2034    await stream.packet.length.set(length_type=enums.LengthType.BUTTERFLY, min_val=64, max_val=1500)
2035    await stream.packet.length.set(length_type=enums.LengthType.RANDOM, min_val=64, max_val=1500)
2036    await stream.packet.length.set(length_type=enums.LengthType.MIX, min_val=64, max_val=64)
2037
2038    resp = await stream.packet.length.get()
2039    resp.length_type
2040    resp.min_val
2041    resp.max_val
2042
2043    # Packet Auto Size
2044    await stream.packet.auto_adjust.set()
2045
2046    # Payload Type
2047    # Pattern string in hex, min = 1 byte, max = 18 bytes
2048    await stream.payload.content.set(payload_type=enums.PayloadType.PATTERN, hex_data=Hex("000102030405060708090A0B0C0D0E0FDEAD"))
2049    await stream.payload.content.set(payload_type=enums.PayloadType.PATTERN, hex_data=Hex("F5"))
2050    
2051    # Patter string ignored for non-pattern types
2052    await stream.payload.content.set(payload_type=enums.PayloadType.INC16, hex_data=Hex("F5"))
2053    await stream.payload.content.set_inc_word("00")
2054    await stream.payload.content.set(payload_type=enums.PayloadType.INC8, hex_data=Hex("F5"))
2055    await stream.payload.content.set_inc_byte("00")
2056    await stream.payload.content.set(payload_type=enums.PayloadType.DEC8, hex_data=Hex("F5"))
2057    await stream.payload.content.set_dec_byte("00")
2058    await stream.payload.content.set(payload_type=enums.PayloadType.DEC16, hex_data=Hex("F5"))
2059    await stream.payload.content.set_dec_word("00")
2060    await stream.payload.content.set(payload_type=enums.PayloadType.PRBS, hex_data=Hex("F5"))
2061    await stream.payload.content.set_prbs("00")
2062    await stream.payload.content.set(payload_type=enums.PayloadType.RANDOM, hex_data=Hex("F5"))
2063    await stream.payload.content.set_random("00")
2064
2065    resp = await stream.payload.content.get()
2066    resp.hex_data
2067    resp.payload_type
2068
2069    # Extended Payload
2070    # Use await port.payload_mode.set_extpl() to set the port's payload mode to Extended Payload.
2071    await stream.payload.extended.set(hex_data=Hex("00110022FF"))
2072    
2073    resp = await stream.payload.extended.get()
2074    resp.hex_data
2075
2076    # Rate Fraction
2077    await stream.rate.fraction.set(stream_rate_ppm=1_000_000)
2078
2079    resp = await stream.rate.fraction.get()
2080    resp.stream_rate_ppm
2081
2082    # Packet Rate
2083    await stream.rate.pps.set(stream_rate_pps=1_000)
2084    
2085    resp = await stream.rate.pps.get()
2086    resp.stream_rate_pps
2087
2088    # Bit Rate L2
2089    await stream.rate.l2bps.set(l2_bps=1_000_000)
2090    
2091    resp = await stream.rate.l2bps.get()
2092    resp.l2_bps
2093
2094    # Packet Limit
2095    await stream.packet.limit.set(packet_count=1_000)
2096    
2097    resp = await stream.packet.limit.get()
2098    resp.packet_count
2099
2100    # Burst Size and Density
2101    await stream.burst.burstiness.set(size=20, density=80)
2102
2103    resp = await stream.burst.burstiness.get()
2104    resp.size
2105    resp.density
2106
2107    # Inter Burst/Packet Gap
2108    await stream.burst.gap.set(inter_packet_gap=30, inter_burst_gap=30)
2109    
2110    resp = await stream.burst.gap.get()
2111    resp.inter_packet_gap
2112    resp.inter_burst_gap
2113
2114    # Priority Flow
2115    await stream.priority_flow.set(cos=enums.PFCMode.ZERO)
2116    await stream.priority_flow.set(cos=enums.PFCMode.ONE)
2117    await stream.priority_flow.set(cos=enums.PFCMode.TWO)
2118    await stream.priority_flow.set(cos=enums.PFCMode.THREE)
2119    await stream.priority_flow.set(cos=enums.PFCMode.FOUR)
2120    await stream.priority_flow.set(cos=enums.PFCMode.FIVE)
2121    await stream.priority_flow.set(cos=enums.PFCMode.SIX)
2122    await stream.priority_flow.set(cos=enums.PFCMode.SEVEN)
2123    await stream.priority_flow.set(cos=enums.PFCMode.VLAN_PCP)
2124
2125    resp = await stream.priority_flow.get()
2126    resp.cos
2127
2128    # IPv4 Gateway Address
2129    await stream.gateway.ipv4.set(gateway=ipaddress.IPv4Address("10.10.10.1"))
2130    
2131    resp = await stream.gateway.ipv4.get()
2132    resp.gateway
2133
2134    # IPv6 Gateway Address
2135    await stream.gateway.ipv6.set(gateway=ipaddress.IPv6Address("::0001"))
2136    
2137    resp = await stream.gateway.ipv6.get()
2138    resp.gateway
2139
2140    # ARP Resolve Peer Address
2141    # You need to make sure either the port has a correct gateway or the stream has a correct destination IP address to ARP resolve the MAC address.
2142    resp = await stream.request.arp.get()
2143    resp.mac_address
2144
2145    # PING Check IP Peer
2146    # You need to make sure either the port has a correct gateway or the stream has a correct destination IP address to ping.
2147    resp = await stream.request.ping.get()
2148    resp.delay
2149    resp.time_to_live
2150
2151    # Custom Data Field
2152    # Use await port.payload_mode.set_cdf() to set the port's payload mode to Custom Data Field.
2153
2154    # Field Offset
2155    await stream.cdf.offset.set(offset=1)
2156    
2157    resp = await stream.cdf.offset.get()
2158    resp.offset
2159
2160    # Byte Count
2161    await stream.cdf.count.set(cdf_count=1)
2162    
2163    resp = await stream.cdf.count.get()
2164    resp.cdf_count
2165
2166    ################################################
2167    #          Stream Modifier                     #
2168    ################################################
2169    
2170    # Create
2171    await stream.packet.header.modifiers.configure(number=1)
2172
2173    # Clear
2174    await stream.packet.header.modifiers.clear()
2175
2176    # Obtain
2177    # Must create modifiers before obtain.
2178    modifier = stream.packet.header.modifiers.obtain(idx=0)
2179    
2180    # Range
2181    await modifier.range.set(min_val=0, step=10, max_val=9)
2182    
2183    resp = await modifier.range.get()
2184    resp.min_val
2185    resp.max_val
2186    resp.step
2187
2188    # Position, Action, Mask
2189    await modifier.specification.set(position=0, mask=Hex("FFFF0000"), action=enums.ModifierAction.INC, repetition=1)
2190    await modifier.specification.set(position=0, mask=Hex("FFFF0000"), action=enums.ModifierAction.DEC, repetition=1)
2191    await modifier.specification.set(position=0, mask=Hex("FFFF0000"), action=enums.ModifierAction.RANDOM, repetition=1)
2192    
2193    resp = await modifier.specification.get()
2194    resp.action
2195    resp.mask
2196    resp.position
2197    resp.repetition
2198
2199    # #################################################
2200    # #           Stream 32-bit Modifier              #
2201    # #################################################
2202
2203    # Create
2204    await stream.packet.header.modifiers_extended.configure(number=1)
2205
2206    # Clear
2207    await stream.packet.header.modifiers_extended.clear()
2208
2209    # Obtain
2210    # Must create modifiers before obtain.
2211    modifier_ext = stream.packet.header.modifiers_extended.obtain(idx=0)
2212
2213    # Range
2214    await modifier_ext.range.set(min_val=0, step=1, max_val=100)
2215    
2216    resp = await modifier_ext.range.get()
2217    resp.max_val
2218    resp.min_val
2219    resp.step
2220
2221    # Position, Action, Mask
2222    await modifier_ext.specification.set(position=0, mask=Hex("FFFFFFFF"), action=enums.ModifierAction.INC, repetition=1)
2223    await modifier_ext.specification.set(position=0, mask=Hex("FFFFFFFF"), action=enums.ModifierAction.DEC, repetition=1)
2224    await modifier_ext.specification.set(position=0, mask=Hex("FFFFFFFF"), action=enums.ModifierAction.RANDOM, repetition=1)
2225
2226    resp = await modifier_ext.specification.get()
2227    resp.action
2228    resp.mask
2229    resp.position
2230    resp.repetition
2231
2232    # #################################################
2233    # #           Stream Error Control                #
2234    # #################################################
2235
2236    # Misorder Error Injection
2237    await stream.inject_err.misorder.set()
2238
2239    # Payload Integrity Error Injection
2240    await stream.inject_err.payload_integrity.set()
2241
2242    # Sequence Error Injection
2243    await stream.inject_err.sequence.set()
2244
2245    # Test Payload Error Injection
2246    await stream.inject_err.test_payload.set()
2247
2248    # Checksum Error Injection
2249    await stream.inject_err.frame_checksum.set()
2250
2251    # Insert Frame Checksum
2252    await stream.insert_packets_checksum.set(on_off=enums.OnOff.ON)
2253    await stream.insert_packets_checksum.set_on()
2254    await stream.insert_packets_checksum.set(on_off=enums.OnOff.OFF)
2255    await stream.insert_packets_checksum.set_off()
2256
2257    resp = await stream.insert_packets_checksum.get()
2258    resp.on_off
2259# endregion
2260
2261# region Network Emulation
2262    #################################################
2263    #              Network Emulation                #
2264    #################################################
2265
2266    # Configure Chimera port
2267    if isinstance(module, modules.ModuleChimera):
2268        port = module.ports.obtain(0)
2269
2270        await port.pcs_pma.link_flap.params.set(duration=100, period=1000, repetition=0)
2271        await port.pcs_pma.link_flap.enable.set_on()
2272        await port.pcs_pma.link_flap.enable.set_off()
2273
2274        await port.pcs_pma.pma_pulse_err_inj.params.set(duration=100, period=1000, repetition=0, coeff=100, exp=-4)
2275        await port.pcs_pma.pma_pulse_err_inj.enable.set_on()
2276        await port.pcs_pma.pma_pulse_err_inj.enable.set_off()
2277
2278        # Enable impairment on the port.
2279        await port.emulate.set_off()
2280        await port.emulate.set_on()
2281
2282        resp = await port.emulate.get()
2283        resp.action
2284
2285        # Set TPLD mode
2286        await port.emulation.tpld_mode.set(mode=enums.TPLDMode.NORMAL)
2287        await port.emulation.tpld_mode.set(mode=enums.TPLDMode.MICRO)
2288
2289        resp = await port.emulation.tpld_mode.get()
2290        resp.mode
2291
2292        # Configure flow's basic filter on a port
2293        # Configure flow properties
2294        flow = port.emulation.flows[1]
2295
2296        await flow.comment.set(comment="Flow description")
2297        
2298        resp = await flow.comment.get()
2299        resp.comment
2300
2301        # Initializing the shadow copy of the filter.
2302        await flow.shadow_filter.initiating.set()
2303
2304        # Configure shadow filter to BASIC mode
2305        await flow.shadow_filter.use_basic_mode()
2306        
2307        # Query the mode of the filter (either basic or extended)
2308        filter = await flow.shadow_filter.get_mode()
2309
2310        if isinstance(filter, misc.BasicImpairmentFlowFilter):
2311            #------------------
2312            # Ethernet subfilter
2313            #------------------
2314            # Use and configure basic-mode shadow filter's Ethernet subfilter
2315            await utils.apply(
2316                filter.ethernet.settings.set(use=enums.FilterUse.AND, action=enums.InfoAction.EXCLUDE),
2317                filter.ethernet.settings.set(use=enums.FilterUse.AND, action=enums.InfoAction.INCLUDE),
2318                filter.ethernet.src_address.set(use=enums.OnOff.ON, value=Hex("AAAAAAAAAAAA"), mask=Hex("FFFFFFFFFFFF")),
2319                filter.ethernet.dest_address.set(use=enums.OnOff.ON, value=Hex("BBBBBBBBBBBB"), mask=Hex("FFFFFFFFFFFF"))
2320            )
2321
2322            #------------------
2323            # Layer 2+ subfilter
2324            #------------------
2325            # Not use basic-mode shadow filter's Layer 2+ subfilter
2326            await filter.l2plus_use.set(use=enums.L2PlusPresent.NA)
2327
2328            # Use and configure basic-mode shadow filter's Layer2+ subfilter (One VLAN tag)
2329            await utils.apply(
2330                filter.l2plus_use.set(use=enums.L2PlusPresent.VLAN1),
2331                filter.vlan.settings.set(use=enums.FilterUse.AND, action=enums.InfoAction.EXCLUDE),
2332                filter.vlan.settings.set(use=enums.FilterUse.AND, action=enums.InfoAction.INCLUDE),
2333                filter.vlan.inner.tag.set(use=enums.OnOff.ON, value=1234, mask=Hex("0FFF")),
2334                filter.vlan.inner.pcp.set(use=enums.OnOff.OFF, value=3, mask=Hex("07")),
2335            )
2336            # Use and configure basic-mode shadow filter's Layer2+ subfilter (Two VLAN tag)
2337            await utils.apply(
2338                filter.l2plus_use.set(use=enums.L2PlusPresent.VLAN2),
2339                filter.vlan.settings.set(use=enums.FilterUse.AND, action=enums.InfoAction.EXCLUDE),
2340                filter.vlan.settings.set(use=enums.FilterUse.AND, action=enums.InfoAction.INCLUDE),
2341                filter.vlan.inner.tag.set(use=enums.OnOff.ON, value=1234, mask=Hex("0FFF")),
2342                filter.vlan.inner.pcp.set(use=enums.OnOff.OFF, value=3, mask=Hex("07")),
2343                filter.vlan.outer.tag.set(use=enums.OnOff.ON, value=2345, mask=Hex("0FFF")),
2344                filter.vlan.outer.pcp.set(use=enums.OnOff.OFF, value=0, mask=Hex("07")),
2345            )
2346            # Use and configure basic-mode shadow filter's Layer2+ subfilter (MPLS)
2347            await utils.apply(
2348                filter.l2plus_use.set(use=enums.L2PlusPresent.MPLS),
2349                filter.mpls.settings.set(use=enums.FilterUse.AND, action=enums.InfoAction.EXCLUDE),
2350                filter.mpls.settings.set(use=enums.FilterUse.AND, action=enums.InfoAction.INCLUDE),
2351                filter.mpls.label.set(use=enums.OnOff.ON, value=1000, mask=Hex("FFFFF")),
2352                filter.mpls.toc.set(use=enums.OnOff.ON, value=0, mask=Hex("07")),
2353            )
2354
2355            #------------------
2356            # Layer 3 subfilter
2357            #------------------
2358            # Not use basic-mode shadow filter's Layer 3 subfilter
2359            await filter.l3_use.set(use=enums.L3Present.NA)
2360            # Use and configure basic-mode shadow filter's Layer 3 subfilter (IPv4)
2361            await utils.apply(
2362                filter.l3_use.set(use=enums.L3Present.IP4),
2363                filter.ip.v4.settings.set(use=enums.FilterUse.AND, action=enums.InfoAction.EXCLUDE),
2364                filter.ip.v4.settings.set(use=enums.FilterUse.AND, action=enums.InfoAction.INCLUDE),
2365                filter.ip.v4.src_address.set(use=enums.OnOff.ON, value=ipaddress.IPv4Address("10.0.0.2"), mask=Hex("FFFFFFFF")),
2366                filter.ip.v4.dest_address.set(use=enums.OnOff.ON, value=ipaddress.IPv4Address("10.0.0.2"), mask=Hex("FFFFFFFF")),
2367                filter.ip.v4.dscp.set(use=enums.OnOff.ON, value=0, mask=Hex("FC")),
2368            )
2369            # Use and configure basic-mode shadow filter's Layer 3 subfilter (IPv6)
2370            await utils.apply(
2371                filter.l3_use.set(use=enums.L3Present.IP6),
2372                filter.ip.v6.settings.set(use=enums.FilterUse.AND, action=enums.InfoAction.EXCLUDE),
2373                filter.ip.v6.settings.set(use=enums.FilterUse.AND, action=enums.InfoAction.INCLUDE),
2374                filter.ip.v6.src_address.set(use=enums.OnOff.ON, value=ipaddress.IPv6Address("2001::2"), mask=Hex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF")),
2375                filter.ip.v6.dest_address.set(use=enums.OnOff.ON, value=ipaddress.IPv6Address("2002::2"), mask=Hex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF")),
2376                filter.ip.v6.traffic_class.set(use=enums.OnOff.ON, value=0, mask=Hex("FC")),
2377            )
2378
2379            #------------------
2380            # Layer 4 subfilter
2381            #------------------
2382            # Use and configure basic-mode shadow filter's Layer 4 subfilter (TCP)
2383            await utils.apply(
2384                filter.tcp.settings.set(use=enums.FilterUse.AND, action=enums.InfoAction.EXCLUDE),
2385                filter.tcp.settings.set(use=enums.FilterUse.AND, action=enums.InfoAction.INCLUDE),
2386                filter.tcp.src_port.set(use=enums.OnOff.ON, value=1234, mask=Hex("FFFF")),
2387                filter.tcp.dest_port.set(use=enums.OnOff.ON, value=80, mask=Hex("FFFF")),
2388            )
2389            # Use and configure basic-mode shadow filter's Layer 4 subfilter (UDP)
2390            await utils.apply(
2391                filter.udp.settings.set(use=enums.FilterUse.AND, action=enums.InfoAction.EXCLUDE),
2392                filter.udp.settings.set(use=enums.FilterUse.AND, action=enums.InfoAction.INCLUDE),
2393                filter.udp.src_port.set(use=enums.OnOff.ON, value=1234, mask=Hex("FFFF")),
2394                filter.udp.dest_port.set(use=enums.OnOff.ON, value=80, mask=Hex("FFFF")),
2395            )
2396
2397            #------------------
2398            # Layer Xena subfilter
2399            #------------------
2400            await utils.apply(
2401                filter.tpld.settings.set(action=enums.InfoAction.EXCLUDE),
2402                filter.tpld.settings.set(action=enums.InfoAction.INCLUDE),
2403                filter.tpld.test_payload_filters_config[0].set(use=enums.OnOff.ON, id = 2),
2404                filter.tpld.test_payload_filters_config[0].set(use=enums.OnOff.OFF, id = 2),
2405                filter.tpld.test_payload_filters_config[1].set(use=enums.OnOff.ON, id = 4),
2406                filter.tpld.test_payload_filters_config[1].set(use=enums.OnOff.OFF, id = 4),
2407                filter.tpld.test_payload_filters_config[2].set(use=enums.OnOff.ON, id = 6),
2408                filter.tpld.test_payload_filters_config[2].set(use=enums.OnOff.OFF, id = 6),
2409                filter.tpld.test_payload_filters_config[3].set(use=enums.OnOff.ON, id = 8),
2410                filter.tpld.test_payload_filters_config[3].set(use=enums.OnOff.OFF, id = 8),
2411                filter.tpld.test_payload_filters_config[4].set(use=enums.OnOff.ON, id = 10),
2412                filter.tpld.test_payload_filters_config[4].set(use=enums.OnOff.OFF, id = 10),
2413                filter.tpld.test_payload_filters_config[5].set(use=enums.OnOff.ON, id = 20),
2414                filter.tpld.test_payload_filters_config[5].set(use=enums.OnOff.OFF, id = 20),
2415                filter.tpld.test_payload_filters_config[6].set(use=enums.OnOff.ON, id = 40),
2416                filter.tpld.test_payload_filters_config[6].set(use=enums.OnOff.OFF, id = 40),
2417                filter.tpld.test_payload_filters_config[7].set(use=enums.OnOff.ON, id = 60),
2418                filter.tpld.test_payload_filters_config[7].set(use=enums.OnOff.OFF, id = 60),
2419                filter.tpld.test_payload_filters_config[8].set(use=enums.OnOff.ON, id = 80),
2420                filter.tpld.test_payload_filters_config[8].set(use=enums.OnOff.OFF, id = 80),
2421                filter.tpld.test_payload_filters_config[9].set(use=enums.OnOff.ON, id = 100),
2422                filter.tpld.test_payload_filters_config[9].set(use=enums.OnOff.OFF, id = 100),
2423                filter.tpld.test_payload_filters_config[10].set(use=enums.OnOff.ON, id = 102),
2424                filter.tpld.test_payload_filters_config[10].set(use=enums.OnOff.OFF, id = 102),
2425                filter.tpld.test_payload_filters_config[11].set(use=enums.OnOff.ON, id = 104),
2426                filter.tpld.test_payload_filters_config[11].set(use=enums.OnOff.OFF, id = 104),
2427                filter.tpld.test_payload_filters_config[12].set(use=enums.OnOff.ON, id = 106),
2428                filter.tpld.test_payload_filters_config[12].set(use=enums.OnOff.OFF, id = 106),
2429                filter.tpld.test_payload_filters_config[13].set(use=enums.OnOff.ON, id = 108),
2430                filter.tpld.test_payload_filters_config[13].set(use=enums.OnOff.OFF, id = 108),
2431                filter.tpld.test_payload_filters_config[14].set(use=enums.OnOff.ON, id = 110),
2432                filter.tpld.test_payload_filters_config[14].set(use=enums.OnOff.OFF, id = 110),
2433                filter.tpld.test_payload_filters_config[15].set(use=enums.OnOff.ON, id = 200),
2434                filter.tpld.test_payload_filters_config[15].set(use=enums.OnOff.OFF, id = 200),
2435            )
2436
2437            #------------------
2438            # Layer Any subfilter
2439            #------------------
2440            await utils.apply(
2441                filter.any.settings.set(use=enums.FilterUse.AND, action=enums.InfoAction.EXCLUDE),
2442                filter.any.settings.set(use=enums.FilterUse.AND, action=enums.InfoAction.INCLUDE),
2443                filter.any.config.set(position=0, value=Hex("112233445566"), mask=Hex("112233445566"))
2444            )
2445
2446        # Apply the filter so the configuration data in the shadow copy is committed to the working copy automatically.
2447        await flow.shadow_filter.enable.set_off()
2448        await flow.shadow_filter.enable.set_on()
2449        await flow.shadow_filter.apply.set()
2450
2451        # Configure flow's extended filter on a port
2452        # Configure flow properties
2453        flow = port.emulation.flows[1]
2454        await flow.comment.set("Flow description")
2455
2456        # Initializing the shadow copy of the filter.
2457        await flow.shadow_filter.initiating.set()
2458
2459        # Configure shadow filter to EXTENDED mode
2460        await flow.shadow_filter.use_extended_mode()
2461
2462        # Query the mode of the filter (either basic or extended)
2463        filter = await flow.shadow_filter.get_mode()
2464
2465        if isinstance(filter, misc.ExtendedImpairmentFlowFilter):
2466
2467            await filter.use_segments(
2468                enums.ProtocolOption.VLAN
2469                )
2470            protocol_segments = await filter.get_protocol_segments()
2471            await protocol_segments[0].value.set(value=Hex("AAAAAAAAAAAABBBBBBBBBBBB8100"))
2472            await protocol_segments[0].mask.set(masks=Hex("0000000000000000000000000000"))
2473            await protocol_segments[1].value.set(value=Hex("0064FFFF"))
2474            await protocol_segments[1].mask.set(masks=Hex("00000000"))
2475
2476            await protocol_segments[1].get()
2477
2478        # Configure impairment - Drop
2479        # Fixed Burst distribution for impairment Drop
2480        await utils.apply(
2481            flow.impairment_distribution.drop_type_config.fixed_burst.set(burst_size=5),
2482            flow.impairment_distribution.drop_type_config.schedule.set(duration=1, period=5), #repeat (duration = 1, period = x)
2483            flow.impairment_distribution.drop_type_config.schedule.set(duration=1, period=0), #one shot
2484        )
2485
2486        # Random Burst distribution for impairment Drop
2487        await utils.apply(
2488            flow.impairment_distribution.drop_type_config.random_burst.set(minimum=1, maximum=10, probability=10_000),
2489            flow.impairment_distribution.drop_type_config.schedule.set(duration=1, period=1), # repeat pattern
2490            flow.impairment_distribution.drop_type_config.schedule.set(duration=0, period=0), #continuous
2491        )
2492
2493        # Fixed Rate distribution for impairment Drop
2494        await utils.apply(
2495            flow.impairment_distribution.drop_type_config.fixed_rate.set(probability=10_000),
2496            flow.impairment_distribution.drop_type_config.schedule.set(duration=1, period=1),# repeat pattern
2497            flow.impairment_distribution.drop_type_config.schedule.set(duration=0, period=0), #continuous
2498        )
2499
2500        # Bit Error Rate distribution for impairment Drop
2501        await utils.apply(
2502            flow.impairment_distribution.drop_type_config.bit_error_rate.set(coef=1, exp=1),
2503            flow.impairment_distribution.drop_type_config.schedule.set(duration=1, period=1),# repeat pattern
2504            flow.impairment_distribution.drop_type_config.schedule.set(duration=0, period=0), #continuous
2505        )
2506
2507        # Random Rate distribution for impairment Drop
2508        await utils.apply(
2509            flow.impairment_distribution.drop_type_config.random_rate.set(probability=10_000),
2510            flow.impairment_distribution.drop_type_config.schedule.set(duration=1, period=1),# repeat pattern
2511            flow.impairment_distribution.drop_type_config.schedule.set(duration=0, period=0), #continuous
2512        )
2513
2514        # Gilbert Elliot distribution for impairment Drop
2515        await utils.apply(
2516            flow.impairment_distribution.drop_type_config.ge.set(good_state_prob=0, good_state_trans_prob=0, bad_state_prob=0, bad_state_trans_prob=0),
2517            flow.impairment_distribution.drop_type_config.schedule.set(duration=1, period=1),# repeat pattern
2518            flow.impairment_distribution.drop_type_config.schedule.set(duration=0, period=0), #continuous
2519        )
2520
2521        # Uniform distribution for impairment Drop
2522        await utils.apply(
2523            flow.impairment_distribution.drop_type_config.uniform.set(minimum=1, maximum=1),
2524            flow.impairment_distribution.drop_type_config.schedule.set(duration=1, period=1),# repeat pattern
2525            flow.impairment_distribution.drop_type_config.schedule.set(duration=0, period=0), #continuous
2526        )
2527
2528        # Gaussian distribution for impairment Drop
2529        await utils.apply(
2530            flow.impairment_distribution.drop_type_config.gaussian.set(mean=1, std_deviation=1),
2531            flow.impairment_distribution.drop_type_config.schedule.set(duration=1, period=1),# repeat pattern
2532            flow.impairment_distribution.drop_type_config.schedule.set(duration=0, period=0), #continuous
2533        )
2534
2535        # Poisson distribution for impairment Drop
2536        await utils.apply(
2537            flow.impairment_distribution.drop_type_config.poisson.set(mean=9),
2538            flow.impairment_distribution.drop_type_config.schedule.set(duration=1, period=1), # repeat pattern
2539            flow.impairment_distribution.drop_type_config.schedule.set(duration=0, period=0), #continuous
2540        )
2541
2542        # Gamma distribution for impairment Drop
2543        await utils.apply(
2544            flow.impairment_distribution.drop_type_config.gamma.set(shape=1, scale=1),
2545            flow.impairment_distribution.drop_type_config.schedule.set(duration=1, period=1), # repeat pattern
2546            flow.impairment_distribution.drop_type_config.schedule.set(duration=0, period=0), #continuous
2547        )
2548
2549        # Custom distribution for impairment Drop
2550        data_x=[0, 1] * 256
2551        await port.custom_distributions.assign(0)
2552        await port.custom_distributions[0].comment.set(comment="Example Custom Distribution")
2553        await port.custom_distributions[0].definition.set(linear=enums.OnOff.OFF, symmetric=enums.OnOff.OFF, entry_count=len(data_x), data_x=data_x)
2554        await utils.apply(
2555            flow.impairment_distribution.drop_type_config.custom.set(cust_id=0),
2556            flow.impairment_distribution.drop_type_config.schedule.set(duration=1, period=1),
2557            flow.impairment_distribution.drop_type_config.schedule.set(duration=0, period=0), #continuous
2558        )
2559
2560        # Set distribution and start impairment Drop
2561        await flow.impairment_distribution.drop_type_config.enable.set_on()
2562        await flow.impairment_distribution.drop_type_config.enable.set_off()
2563        
2564        # Configure impairment - Misordering
2565
2566        # Fixed Burst distribution for impairment Misordering
2567        # dist = distributions.misordering.FixedBurst(burst_size=1)
2568        # dist.repeat(period=5)
2569        # dist.one_shot()
2570
2571        # Fixed Burst distribution for impairment Drop
2572        await utils.apply(
2573            flow.impairment_distribution.misorder_type_config.fixed_burst.set(burst_size=5),
2574            flow.impairment_distribution.misorder_type_config.schedule.set(duration=1, period=5), #repeat
2575            flow.impairment_distribution.misorder_type_config.schedule.set(duration=1, period=0), #one shot
2576        )
2577
2578        # Fixed Rate distribution for impairment Drop
2579        await utils.apply(
2580            flow.impairment_distribution.misorder_type_config.fixed_rate.set(probability=10_000),
2581            flow.impairment_distribution.misorder_type_config.schedule.set(duration=1, period=1), # repeat pattern
2582            flow.impairment_distribution.misorder_type_config.schedule.set(duration=0, period=0), #continuous
2583        )
2584
2585        # Set distribution and start impairment Misordering
2586        await flow.misordering.set(depth=1)
2587        await flow.impairment_distribution.misorder_type_config.enable.set_on()
2588        await flow.impairment_distribution.misorder_type_config.enable.set_off()
2589
2590        # Configure impairment - Latency & Jitter
2591        # Fixed Burst distribution for impairment Latency & Jitter
2592        await flow.impairment_distribution.latency_jitter_type_config.constant_delay.set(delay=100)
2593
2594        # Random Burst distribution for impairment Latency & Jitter
2595        await utils.apply(
2596            flow.impairment_distribution.latency_jitter_type_config.accumulate_and_burst.set(delay=1300),
2597            flow.impairment_distribution.latency_jitter_type_config.schedule.set(duration=1, period=1), #repeat (duration = 1, period = x)
2598            flow.impairment_distribution.latency_jitter_type_config.schedule.set(duration=1, period=0), #one shot
2599        )
2600
2601        # Step distribution for impairment Latency & Jitter
2602        await utils.apply(
2603            flow.impairment_distribution.latency_jitter_type_config.step.set(low=1300, high=77000),
2604            flow.impairment_distribution.latency_jitter_type_config.schedule.set(duration=0, period=0), #continuous
2605        )
2606        await flow.impairment_distribution.corruption_type_config.off.set()
2607
2608        # Uniform distribution for impairment Latency & Jitter
2609        await utils.apply(
2610            flow.impairment_distribution.latency_jitter_type_config.uniform.set(minimum=1, maximum=1),
2611            flow.impairment_distribution.latency_jitter_type_config.schedule.set(duration=0, period=0), #continuous
2612        )
2613
2614        # Gaussian distribution for impairment Latency & Jitter
2615        await utils.apply(
2616            flow.impairment_distribution.latency_jitter_type_config.gaussian.set(mean=1, std_deviation=1),
2617            flow.impairment_distribution.latency_jitter_type_config.schedule.set(duration=0, period=0), #continuous
2618        )
2619
2620        resp = await flow.latency_range.get()
2621        resp.
2622        
2623
2624        # Poisson distribution for impairment Latency & Jitter
2625        await utils.apply(
2626            flow.impairment_distribution.latency_jitter_type_config.poisson.set(mean=1),
2627            flow.impairment_distribution.latency_jitter_type_config.schedule.set(duration=0, period=0), #continuous
2628        )
2629
2630        # Gamma distribution for impairment Latency & Jitter
2631        await utils.apply(
2632            flow.impairment_distribution.latency_jitter_type_config.gamma.set(shape=1, scale=1),
2633            flow.impairment_distribution.latency_jitter_type_config.schedule.set(duration=0, period=0), #continuous
2634        )
2635
2636        # Custom distribution for impairment Latency & Jitter
2637        data_x=[0, 1] * 256
2638        await port.custom_distributions.assign(0)
2639        await port.custom_distributions[0].comment.set(comment="Example Custom Distribution")
2640        await port.custom_distributions[0].definition.set(linear=enums.OnOff.OFF, symmetric=enums.OnOff.OFF, entry_count=len(data_x), data_x=data_x)
2641        await utils.apply(
2642            flow.impairment_distribution.latency_jitter_type_config.custom.set(cust_id=0),
2643            flow.impairment_distribution.latency_jitter_type_config.schedule.set(duration=0, period=0), #continuous
2644        )
2645
2646        # Set distribution and start impairment Latency & Jitter
2647        await flow.impairment_distribution.latency_jitter_type_config.enable.set_on()
2648        await flow.impairment_distribution.latency_jitter_type_config.enable.set_off()
2649
2650        # Configure impairment - Duplication
2651
2652        # Fixed Burst distribution for impairment Duplication
2653        # dist.one_shot()
2654        await utils.apply(
2655            flow.impairment_distribution.duplication_type_config.fixed_burst.set(burst_size=1300),
2656            flow.impairment_distribution.duplication_type_config.schedule.set(duration=1, period=1), #repeat (duration = 1, period = x)
2657            flow.impairment_distribution.duplication_type_config.schedule.set(duration=1, period=0), #one shot
2658        )
2659
2660        # Random Burst distribution for impairment Duplication
2661        await utils.apply(
2662            flow.impairment_distribution.duplication_type_config.random_burst.set(minimum=1, maximum=1, probability=10_0000),
2663            flow.impairment_distribution.duplication_type_config.schedule.set(duration=1, period=1),# repeat pattern
2664            flow.impairment_distribution.duplication_type_config.schedule.set(duration=0, period=0), #continuous
2665        )
2666
2667        # Fixed Rate distribution for impairment Duplication
2668        await utils.apply(
2669            flow.impairment_distribution.duplication_type_config.fixed_rate.set(probability=10_000),
2670            flow.impairment_distribution.duplication_type_config.schedule.set(duration=1, period=1), # repeat pattern
2671            flow.impairment_distribution.duplication_type_config.schedule.set(duration=0, period=0), #continuous
2672        )
2673
2674        # Bit Error Rate distribution for impairment Duplication
2675        await utils.apply(
2676            flow.impairment_distribution.duplication_type_config.bit_error_rate.set(coef=1, exp=1),
2677            flow.impairment_distribution.duplication_type_config.schedule.set(duration=1, period=1),# repeat pattern
2678            flow.impairment_distribution.duplication_type_config.schedule.set(duration=0, period=0), #continuous
2679        )
2680
2681        # Random Rate distribution for impairment Duplication
2682        await utils.apply(
2683            flow.impairment_distribution.duplication_type_config.random_rate.set(probability=10_000),
2684            flow.impairment_distribution.duplication_type_config.schedule.set(duration=1, period=1),# repeat pattern
2685            flow.impairment_distribution.duplication_type_config.schedule.set(duration=0, period=0), #continuous
2686        )
2687
2688        # Gilbert Elliot distribution for impairment Duplication
2689        await utils.apply(
2690            flow.impairment_distribution.duplication_type_config.ge.set(good_state_prob=0, good_state_trans_prob=0, bad_state_prob=0, bad_state_trans_prob=0),
2691            flow.impairment_distribution.duplication_type_config.schedule.set(duration=1, period=1),# repeat pattern
2692            flow.impairment_distribution.duplication_type_config.schedule.set(duration=0, period=0), #continuous
2693        )
2694
2695        # Uniform distribution for impairment Duplication
2696        await utils.apply(
2697            flow.impairment_distribution.duplication_type_config.uniform.set(minimum=1, maximum=1),
2698            flow.impairment_distribution.duplication_type_config.schedule.set(duration=1, period=1),# repeat pattern
2699            flow.impairment_distribution.duplication_type_config.schedule.set(duration=0, period=0), #continuous
2700        )
2701
2702        # Gaussian distribution for impairment Duplication
2703        await utils.apply(
2704            flow.impairment_distribution.duplication_type_config.gaussian.set(mean=1, std_deviation=1),
2705            flow.impairment_distribution.duplication_type_config.schedule.set(duration=1, period=1),# repeat pattern
2706            flow.impairment_distribution.duplication_type_config.schedule.set(duration=0, period=0), #continuous
2707        )
2708
2709        # Poisson distribution for impairment Duplication
2710        await utils.apply(
2711            flow.impairment_distribution.duplication_type_config.poisson.set(mean=9),
2712            flow.impairment_distribution.duplication_type_config.schedule.set(duration=1, period=1), # repeat pattern
2713            flow.impairment_distribution.duplication_type_config.schedule.set(duration=0, period=0), #continuous
2714        )
2715
2716        # Gamma distribution for impairment Duplication
2717        await utils.apply(
2718            flow.impairment_distribution.duplication_type_config.gamma.set(shape=1, scale=1),
2719            flow.impairment_distribution.duplication_type_config.schedule.set(duration=1, period=1), # repeat pattern
2720            flow.impairment_distribution.duplication_type_config.schedule.set(duration=0, period=0), #continuous
2721        )
2722
2723        # Custom distribution for impairment Duplication
2724        data_x=[0, 1] * 256
2725        await port.custom_distributions.assign(0)
2726        await port.custom_distributions[0].comment.set(comment="Example Custom Distribution")
2727        await port.custom_distributions[0].definition.set(linear=enums.OnOff.OFF, symmetric=enums.OnOff.OFF, entry_count=len(data_x), data_x=data_x)
2728        await utils.apply(
2729            flow.impairment_distribution.duplication_type_config.custom.set(cust_id=0),
2730            flow.impairment_distribution.duplication_type_config.schedule.set(duration=1, period=1),
2731            flow.impairment_distribution.duplication_type_config.schedule.set(duration=0, period=0), #continuous
2732        )
2733
2734        # Set distribution and start impairment Duplication
2735        await flow.impairment_distribution.duplication_type_config.enable.set_on()
2736        await flow.impairment_distribution.duplication_type_config.enable.set_off()
2737
2738        # Configure impairment - Corruption
2739
2740        # Fixed Burst distribution for impairment Corruption
2741        await utils.apply(
2742            flow.impairment_distribution.corruption_type_config.fixed_burst.set(burst_size=1300),
2743            flow.impairment_distribution.corruption_type_config.schedule.set(duration=1, period=1), #repeat (duration = 1, period = x)
2744            flow.impairment_distribution.corruption_type_config.schedule.set(duration=1, period=0), #one shot
2745        )
2746        # Random Burst distribution for impairment Corruption
2747        await utils.apply(
2748            flow.impairment_distribution.corruption_type_config.random_burst.set(minimum=1, maximum=1, probability=10_0000),
2749            flow.impairment_distribution.corruption_type_config.schedule.set(duration=1, period=1),# repeat pattern
2750            flow.impairment_distribution.corruption_type_config.schedule.set(duration=0, period=0), #continuous
2751        )
2752
2753        # Fixed Rate distribution for impairment Corruption
2754        await utils.apply(
2755            flow.impairment_distribution.corruption_type_config.fixed_rate.set(probability=10_000),
2756            flow.impairment_distribution.corruption_type_config.schedule.set(duration=1, period=1), # repeat pattern
2757            flow.impairment_distribution.corruption_type_config.schedule.set(duration=0, period=0), #continuous
2758        )
2759
2760        # Bit Error Rate distribution for impairment Corruption
2761        await utils.apply(
2762            flow.impairment_distribution.corruption_type_config.bit_error_rate.set(coef=1, exp=1),
2763            flow.impairment_distribution.corruption_type_config.schedule.set(duration=1, period=1),# repeat pattern
2764            flow.impairment_distribution.corruption_type_config.schedule.set(duration=0, period=0), #continuous
2765        )
2766
2767        # Random Rate distribution for impairment Corruption
2768        await utils.apply(
2769            flow.impairment_distribution.corruption_type_config.random_rate.set(probability=10_000),
2770            flow.impairment_distribution.corruption_type_config.schedule.set(duration=1, period=1),# repeat pattern
2771            flow.impairment_distribution.corruption_type_config.schedule.set(duration=0, period=0), #continuous
2772        )
2773
2774        # Gilbert Elliot distribution for impairment Corruption
2775        await utils.apply(
2776            flow.impairment_distribution.corruption_type_config.ge.set(good_state_prob=0, good_state_trans_prob=0, bad_state_prob=0, bad_state_trans_prob=0),
2777            flow.impairment_distribution.corruption_type_config.schedule.set(duration=1, period=1),# repeat pattern
2778            flow.impairment_distribution.corruption_type_config.schedule.set(duration=0, period=0), #continuous
2779        )
2780
2781        # Uniform distribution for impairment Corruption
2782        await utils.apply(
2783            flow.impairment_distribution.corruption_type_config.uniform.set(minimum=1, maximum=1),
2784            flow.impairment_distribution.corruption_type_config.schedule.set(duration=1, period=1),# repeat pattern
2785            flow.impairment_distribution.corruption_type_config.schedule.set(duration=0, period=0), #continuous
2786        )
2787
2788        # Gaussian distribution for impairment Corruption
2789        await utils.apply(
2790            flow.impairment_distribution.corruption_type_config.gaussian.set(mean=1, std_deviation=1),
2791            flow.impairment_distribution.corruption_type_config.schedule.set(duration=1, period=1),# repeat pattern
2792            flow.impairment_distribution.corruption_type_config.schedule.set(duration=0, period=0), #continuous
2793        )
2794
2795        # Poisson distribution for impairment Corruption
2796        await utils.apply(
2797            flow.impairment_distribution.corruption_type_config.poisson.set(mean=9),
2798            flow.impairment_distribution.corruption_type_config.schedule.set(duration=1, period=1), # repeat pattern
2799            flow.impairment_distribution.corruption_type_config.schedule.set(duration=0, period=0), #continuous
2800        )
2801
2802        # Gamma distribution for impairment Corruption
2803        await utils.apply(
2804            flow.impairment_distribution.corruption_type_config.gamma.set(shape=1, scale=1),
2805            flow.impairment_distribution.corruption_type_config.schedule.set(duration=1, period=1), # repeat pattern
2806            flow.impairment_distribution.corruption_type_config.schedule.set(duration=0, period=0), #continuous
2807        )
2808
2809
2810        # Custom distribution for impairment Corruption
2811        data_x=[0, 1] * 256
2812        await port.custom_distributions.assign(0)
2813        await port.custom_distributions[0].comment.set(comment="Example Custom Distribution")
2814        await port.custom_distributions[0].definition.set(linear=enums.OnOff.OFF, symmetric=enums.OnOff.OFF, entry_count=len(data_x), data_x=data_x)
2815        await utils.apply(
2816            flow.impairment_distribution.corruption_type_config.custom.set(cust_id=0),
2817            flow.impairment_distribution.corruption_type_config.schedule.set(duration=1, period=1),
2818            flow.impairment_distribution.corruption_type_config.schedule.set(duration=0, period=0), #continuous
2819        )
2820
2821        # Set distribution and start impairment Corruption
2822        await flow.corruption.set(corruption_type=enums.CorruptionType.OFF)
2823        await flow.corruption.set(corruption_type=enums.CorruptionType.ETH)
2824        await flow.corruption.set(corruption_type=enums.CorruptionType.IP)
2825        await flow.corruption.set(corruption_type=enums.CorruptionType.TCP)
2826        await flow.corruption.set(corruption_type=enums.CorruptionType.UDP)
2827        await flow.corruption.set(corruption_type=enums.CorruptionType.BER)
2828        await flow.impairment_distribution.corruption_type_config.enable.set_on()
2829        await flow.impairment_distribution.corruption_type_config.enable.set_off()
2830
2831        await flow.impairment_distribution.corruption_type_config.enable.set_on()
2832
2833        resp = await flow.impairment_distribution.corruption_type_config.one_shot_status.get()
2834        resp.one_shot_status
2835
2836        # Configure bandwidth control - Policer
2837
2838        await flow.bandwidth_control.policer.set(on_off=enums.OnOff.ON, mode=enums.PolicerMode.L1, cir=10_000, cbs=1_000)
2839        await flow.bandwidth_control.policer.set(on_off=enums.OnOff.ON, mode=enums.PolicerMode.L2, cir=10_000, cbs=1_000)
2840
2841
2842        # Configure bandwidth control - Shaper
2843
2844        # Set and start bandwidth control Shaper
2845        await flow.bandwidth_control.shaper.set(on_off=enums.OnOff.ON, mode=enums.PolicerMode.L1, cir=10_000, cbs=1_000, buffer_size=1_000)
2846        await flow.bandwidth_control.shaper.set(on_off=enums.OnOff.ON, mode=enums.PolicerMode.L2, cir=10_000, cbs=1_000, buffer_size=1_000)
2847
2848        # Flow statistics
2849
2850        rx_total = await flow.statistics.rx.total.get()
2851        rx_total.byte_count
2852        rx_total.packet_count
2853        rx_total.l2_bps
2854        rx_total.pps
2855
2856        tx_total = await flow.statistics.tx.total.get()
2857        tx_total.byte_count
2858        tx_total.packet_count
2859        tx_total.l2_bps
2860        tx_total.pps
2861
2862        flow_drop_total = await flow.statistics.total.drop_packets.get()
2863        flow_drop_total.pkt_drop_count_total
2864        flow_drop_total.pkt_drop_count_programmed
2865        flow_drop_total.pkt_drop_count_bandwidth
2866        flow_drop_total.pkt_drop_count_other
2867        flow_drop_total.pkt_drop_ratio_total
2868        flow_drop_total.pkt_drop_ratio_programmed
2869        flow_drop_total.pkt_drop_ratio_bandwidth
2870        flow_drop_total.pkt_drop_ratio_other
2871
2872        flow_corrupted_total = await flow.statistics.total.corrupted_packets.get()
2873        flow_corrupted_total.fcs_corrupted_pkt_count
2874        flow_corrupted_total.fcs_corrupted_pkt_ratio
2875        flow_corrupted_total.ip_corrupted_pkt_count
2876        flow_corrupted_total.ip_corrupted_pkt_ratio
2877        flow_corrupted_total.tcp_corrupted_pkt_count
2878        flow_corrupted_total.tcp_corrupted_pkt_ratio
2879        flow_corrupted_total.total_corrupted_pkt_count
2880        flow_corrupted_total.total_corrupted_pkt_ratio
2881        flow_corrupted_total.udp_corrupted_pkt_count
2882        flow_corrupted_total.udp_corrupted_pkt_ratio
2883
2884        flow_delayed_total = await flow.statistics.total.latency_packets.get()
2885        flow_delayed_total.pkt_count
2886        flow_delayed_total.ratio
2887
2888        flow_jittered_total = await flow.statistics.total.jittered_packets.get()
2889        flow_jittered_total.pkt_count
2890        flow_jittered_total.ratio
2891
2892        flow_duplicated_total = await flow.statistics.total.duplicated_packets.get()
2893        flow_duplicated_total.pkt_count
2894        flow_duplicated_total.ratio
2895
2896        flow_misordered_total = await flow.statistics.total.mis_ordered_packets.get()
2897        flow_misordered_total.pkt_count
2898        flow_misordered_total.ratio
2899
2900        await flow.statistics.tx.clear.set()
2901        await flow.statistics.rx.clear.set()
2902        await flow.statistics.clear.set()
2903        
2904        # Port statistics
2905        port_drop = await port.emulation.statistics.drop.get()
2906        port_drop.pkt_drop_count_total
2907        port_drop.pkt_drop_count_programmed
2908        port_drop.pkt_drop_count_bandwidth
2909        port_drop.pkt_drop_count_other
2910        port_drop.pkt_drop_ratio_total
2911        port_drop.pkt_drop_ratio_programmed
2912        port_drop.pkt_drop_ratio_bandwidth
2913        port_drop.pkt_drop_ratio_other
2914
2915        port_corrupted = await port.emulation.statistics.corrupted.get()
2916        port_corrupted.fcs_corrupted_pkt_count
2917        port_corrupted.fcs_corrupted_pkt_ratio
2918        port_corrupted.ip_corrupted_pkt_count
2919        port_corrupted.ip_corrupted_pkt_ratio
2920        port_corrupted.tcp_corrupted_pkt_count
2921        port_corrupted.tcp_corrupted_pkt_ratio
2922        port_corrupted.total_corrupted_pkt_count
2923        port_corrupted.total_corrupted_pkt_ratio
2924        port_corrupted.udp_corrupted_pkt_count
2925        port_corrupted.udp_corrupted_pkt_ratio
2926
2927        port_delayed = await port.emulation.statistics.latency.get()
2928        port_delayed.pkt_count
2929        port_delayed.ratio
2930
2931        port_jittered = await port.emulation.statistics.jittered.get()
2932        port_jittered.pkt_count
2933        port_jittered.ratio
2934
2935        port_duplicated = await port.emulation.statistics.duplicated.get()
2936        port_duplicated.pkt_count
2937        port_duplicated.ratio
2938
2939        port_misordered = await port.emulation.statistics.mis_ordered.get()
2940        port_misordered.pkt_count
2941        port_misordered.ratio
2942
2943        await port.emulation.clear.set()
2944# endregion