RENIX_Python_如何实现调速

本文关键词:数通一体化测试、流量测试、协议仿真、端口调速、流调速。

Renix测试软件介绍

Renix 是信而泰推出的适用于研发测试场景的数通一体化测试软件,该软件配合适当的信而泰机箱和接口卡,可对 DUT(被测设备)执行流量测试、协议仿真和性能测试。适用于复杂网络设备在研发阶段的测试,如交换机、路由器、防火墙等。本文我们将为您介绍脚本如何实现流调速。

 

一、Renix如何进行调速

Renix通过两种方式对流量进行调速一种是基于端口调速(Base On Port),一种是基于流调速(Base On Stream)。

1Base On Port

基于端口调速。这种调速方式的单位和数值是统一在端口上进行配置,端口下的流量均分负载。

img1

2Base On Stream

基于流调速。这种调速方式的单位和数值是在每一条流量上去配置,端口下所有流量的负载之和不能大于端口线速。因为不同的流量可以选择不同的单位,所以选择该调速方式时,还需要先选择一个换算的标准(Frames per Second/ Bytes per Second),这样有利于计算端口的总负载。

img2

img3

 

二、基于端口调速涉及的API

InterFrameGapProfile

img4

这个API的作用就是进行端口调速,通过该API对端口速率进行配置,修改数值和单位。

img5

 

StreamPortConfig

img6

这个API的对于调速的作用就是选择调速方式:Base On Port/Base On Stream,默认的调速方式就是Base On Port;它的‘lower’就是‘InterFrameGapProfile’,也就是端口调速要用到的API。

img7

注意:

StreamPortConfig的‘upper’是Port,只有当端口上线成功时,StreamPortConfig的‘lower’才有‘InterFrameGapProfile’;当端口上线失败时,StreamPortConfig的‘lower’为‘[ ]’,是空的。

三、基于流调速涉及的API

StreamTemplateLoadProfile

img8

这个API的作用就是进行流调速,通过该API对每一条流量的速率进行配置,修改数值和单位

img9

StreamLoadProfile

img10

这个API的作用就是选择一个换算的标准(Frames per Second/ Bytes per Second)。因为不同的流量可以选择不同的单位,有不同的负载值,有一个基准的换算单位,便于计算端口的总负载。

(建议客户就使用Frames per Second或者 Bytes per Second,Percent是内部使用,兼容时用到,不建议使用)

img11

StreamPortConfig

img12

这个API的对于调速的作用就是选择调速方式:Base On Port/Base On Stream,基于流的调速需要将LoadProfileType改为Base On Stream;它的‘lower’就是‘StreamLoadProfile’,是基于流调速会涉及到的API。

img13

四、脚本示例(Python)

基于端口调速

from renix_py_api.renix import *
initialize()

#获取根节点SysEntry
sys_entry = get_sys_entry()

#预约测试仪10.0.11.106槽位1上的的端口1和端口2
port_location = ('//10.0.11.106/1/15','//10.0.11.106/1/16')
port1 = Port(upper=sys_entry,Location=port_location[0])
port2 = Port(upper=sys_entry,Location=port_location[1])
bring_port_online_cmd = BringPortsOnlineCommand(PortList=[port1.handle,port2.handle])
bring_port_online_cmd.execute()
assert port1.Online

#在端口1下创建流量s1
s1 = StreamTemplate(upper=port1)
print(port1.__dict__)

#指定端口的负载模式——Base On Port
stream_port_config = port1.get_children('StreamPortConfig')[0]
stream_port_config.get()
print(stream_port_config.__dict__)

inter_frame_gap_profile = stream_port_config.get_children('InterFrameGapProfile')[0]
print(inter_frame_gap_profile.__dict__)

#修改端口速率的单位和数值(先修改单位,再修改数值,单位和数值不要同时修改,否则配置会不生效)
inter_frame_gap_profile.edit(Unit=EnumFrameGapUnit.FRAME_PER_SEC)
inter_frame_gap_profile.edit(Rate=200)
inter_frame_gap_profile.get()
print(inter_frame_gap_profile.__dict__)

 

基于流调速

from renix_py_api.renix import *
initialize()

#获取根节点SysEntry
sys_entry = get_sys_entry()

#预约测试仪10.0.11.106槽位1上的的端口1和端口2
port_location = ('//10.0.11.106/1/15','//10.0.11.106/1/16')
port1 = Port(upper=sys_entry,Location=port_location[0])
port2 = Port(upper=sys_entry,Location=port_location[1])
bring_port_online_cmd = BringPortsOnlineCommand(PortList=[port1.handle,port2.handle])
bring_port_online_cmd.execute()
assert port1.Online

#在端口1下创建流量s1
s1 = StreamTemplate(upper=port1)
print(port1.__dict__)

#查看StreamPortConfig的信息
stream_port_config = port1.get_children('StreamPortConfig')[0]
stream_port_config.get()
print(stream_port_config.__dict__)

#修改端口的负载模式——Base On Stream
stream_port_config.edit(LoadProfileType=EnumLoadProfileType.STREAM_BASE)
stream_port_config.get()
print(stream_port_config.__dict__)

#选择换算的基准单位(不同的流量有不同的单位和数值,要计算端口总负载,需要选择一个基准单位)
stream_load_profile = stream_port_config.get_children('StreamLoadProfile')[0]
stream_load_profile.get()
print(stream_load_profile.__dict__)

stream_load_profile.edit(Unit=EnumRateUnit.BYTE_PER_SEC)
print(s1.get_children())
print(stream_load_profile.__dict__)


#修改端口速率的单位和数值(先修改单位,再修改数值,单位和数值不要同时修改,否则配置会不生效)
stream_template_load_profile = s1.get_children('StreamTemplateLoadProfile')[0]
print(stream_template_load_profile.__dict__ )

stream_template_load_profile.edit(Unit=EnumFrameLoadUnit.FRAME_PER_SEC)
print(stream_template_load_profile.__dict__)

stream_template_load_profile.edit(Rate=10000)
print(stream_template_load_profile.__dict__)

 

2020年4月28日 19:13