打印

RENIX_Python_如何实现调速——网络测试仪实操

[复制链接]
581|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
se, ST, pi, ni, TE
本帖最后由 teletest 于 2022-5-16 14:00 编辑

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

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

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


2.基于端口调速涉及的API2.1InterFrameGapProfile
这个API的作用就是进行端口调速,通过该API对端口速率进行配置,修改数值和单位。

2.2StreamPortConfig

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

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


3.基于流调速涉及的API
3.1StreamTemplateLoadProfile

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


3.2StreamLoadProfile

这个API的作用就是选择一个换算的标准(Frames per Second/ Bytes per Second)。因为不同的流量可以选择不同的单位,有不同的负载值,有一个基准的换算单位,便于计算端口的总负载。
(建议客户就使用Frames per Second或者 Bytes per Second,Percent是内部使用,兼容时用到,不建议使用)

3.3StreamPortConfig

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



4.脚本示例(Python)
4.1基于端口调速
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__)

4.2基于流调速
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__)



使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

145

主题

152

帖子

0

粉丝