返回信息流from scapy.all import *
#import libopencflow as ofc
#_______________________________________you can set the switch and port information here_______________
sw_type = ["010","111","000","101","100"]
f = ["0010000010","1111111111","0000000000","1100101000","1010101010"]
w = ["101","100","000","111","001"]
port_no = 4#how to change it?
#____________________________________________________________________________________________________
class sw():
def __init__(self, sw_type, f, w, port_no):
self.sw_type = sw_type
self.f = f
self.w = w
self.port_no =port_no
#_______________________________________________
type_ip = sw_type[port_no][0]
type_otn = sw_type[port_no][1]
type_wave = sw_type[port_no][2]
#______________port_info________________________
OFPST_FIBER = f[port_no][0] # 1<<15 can switch circuits based on SM/MM fiber
OFPST_WAVE = f[port_no][1] # 1<<14 can switch circuits based on ITU-T lambdas
OFPST_T_OTN = f[port_no][2] # 1<<13 can switch circuits based on OTN standard
OFPST_T_SDH = f[port_no][3] # 1<<12 can switch circuits based on SDH standard
OFPST_T_SONET = f[port_no][4] # 1<<11 can switch circuits based on SONET standard
OFPST_ETH = f[port_no][5] # 1<<4 can switch packets based on ETH headers
OFPST_VLAN = f[port_no][6] # 1<<3 can switch packets based on VLAN tags
OFPST_MPLS = f[port_no][7] # 1<<2 can switch packets based on MPLS labels
OFPST_IP = f[port_no][8] # 1<<1 can switch packets based on IP headers
OFPST_L4 = f[port_no][9] # 1<<0 can switch packets based on TCP/UDP headers
#________________wave sw________________________
center_freq_lmda = w[port_no][0]
num_lmda = w[port_no][1]
freq_space_lmda = w[port_no][2]
#______________________________________________________________________________________________________
#we creat switch by using the function below.
def creat_sw(port_no):
def __init__(self,port_no):
self.port_no = port_no
new_sw = sw(sw_type, f, w, port_no)
return new_sw
#______________________________________________________________________________________________________
if __name__ == '__main__':
pass
这是一条镜像帖。来源:北邮人论坛 / communications / #23143同步于 2013/9/25
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Communications机器人发帖
【python】类的参数怎么一直提示没有定义
lc10210103
2013/9/25镜像同步1 回复
订阅后,新回复会通过你的通知中心匿名送达。
1 条回复
调用的时候是使用creat_sw(port_no)去实现的,但是奇怪的是,sw()里面的参数好像都是实参,必须先定义,就像已经使用的f,w,一样。如何才能把参数传进去呢?求大神!