RENIX_Python_如何实现调速——网络测试仪实操
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()#獲取根節點SysEntrysys_entry = get_sys_entry()#預約測試儀10.0.11.106槽位1上的的端口1和端口2port_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下創建流量s1s1 = StreamTemplate(upper=port1)print(port1.__dict__)#指定端口的負載模式——Base On Portstream_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__)
總結
以上是生活随笔為你收集整理的RENIX_Python_如何实现调速——网络测试仪实操的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Redis之Centos6安装使用及Wi
- 下一篇: Python:Selenium + Ch