ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

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

2022-05-16 14:00:15  阅读:198  来源: 互联网

标签:profile stream get Python 端口 调速 实操 RENIX port


1.Renix如何进行调速

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

1.1Base On Port

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

​编辑

 1.2Base On Stream

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

​编辑

​编辑

 

2.基于端口调速涉及的API

2.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__)

​

标签:profile,stream,get,Python,端口,调速,实操,RENIX,port
来源: https://www.cnblogs.com/xinertel/p/16276723.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有