1. 程式人生 > 其它 >RENIX_Python_如何實現調速——網路測試儀實操

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()



#獲取根節點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__)

​