VIAVI TestCenter-Automation: Configure DSCP and ECN using native API
Knowledge Base - FAQ
VIAVI TestCenter-Automation: Configure DSCP and ECN using native API
There are two ways to configure this attributes using the Native API, however, in ether way, you have to delete the "tos" object to avoid issues (there should only be either tos or diffserv):
Directly into the "diffServ" object (binary perspective):
sb = stc.create("streamblock", under=port1)
ipv4 = stc.get(sb, 'children-ipv4:ipv4')
tosdiffserv = stc.get(ipv4, 'children-tosdiffserv')
tos = stc.get(tosdiffserv, 'children-tos')
stc.delete(tos)
diffserv = stc.create('diffserv', under=tosdiffserv,
dscpHigh=7, # First 3 bits of DSCP
dscpLow=7, # Last 3 bits of DSCP
reserved=11) # ECN setting (2 bits)
Using a Range modifier (hex value):
sb = stc.create("streamblock", under=port1)
ipv4 = stc.get(sb, 'children-ipv4:ipv4')
ipv4_name = stc.get(ipv4, 'name')
tosdiffserv = stc.get(ipv4, 'children-tosdiffserv')
tos = stc.get(tosdiffserv, 'children-tos')
stc.delete(tos)
diffserv = stc.create('diffserv', under=tosdiffserv)
stc.create("RangeModifier", under=sb,
EnableStream='TRUE',
Data='f9',
StepValue='1',
Mask='ff',
RecycleCount=1,
RepeatCount=0,
DataType='BYTE',
OffsetReference=f'{ipv4_name}.tosDiffserv.diffServ')
In HLTAPI you need to use the “ip_dscp” and “ip_ecn” attributes of the “traffic_config” command
Note: "ip_ecn" is not implemented in old versions, see the example of the "invoke" method to configure ECN using the Native API
sth.traffic_config(mode='create',
port_handle=port_handle[0],
l3_protocol='ipv4',
ip_dscp=0, # DSCP in decimal representation (from 0 t0 64)
ip_ecn='01') # ECN {00|01|10|11}
# "ip_ecn" is not implemented in old versions, you need to use "invoke"
sth.invoke('stc::config streamblock1.ipv4:ipv4.tosdiffserv.diffserv -reserved 11')