私はPythonを使用してPOXコントローラでTRWアルゴリズムを書いています。ここで、送信者が実際に初めて送信するときにホストに期間を割り当てていますTRWアルゴリズムは、内部ホストから外部ホストに送信された最初のパケットは、フロールールをインストールせずに宛先に送信されると言います。私はそれを行うための関数を書きました
localhostrecord{}
class FCC_Queue_Entry (object):
"""this class object will be kept into FCC_Queue list of IntHostEntry class object"""
whenInitiated=0
dip=0
status=0
protocol=0
def __init__ (self,whenInitiated,dip,status,protocol):
self.whenInitiated = whenInitiated
self.dip = dip
self.status = status
self.protocol = protocol
と
class IntHostEntry (object):
likelihood=0.0
credit=0
zeroCreditTime=0
PCH=[]
FCC_Queue=[]
"""PCH は、以前に受信者と通信したすべてのホスト アドレスを保持します""" "
"" FCC_Queue_Entry クラスのオブジェクトを保持します"""
def __init__ (self,likelihood,credit,zeroCreditTime):
self.likelihood = likelihood
self.credit = credit
self.zeroCreditTime = zeroCreditTime
その後、パケットを次のように送信するコードを記述しました
def send_Packet(event, ip_packet, ip_protocol, dpidstr, buffer_id, src_port, out_port):
src = ip_packet.srcip
dst = ip_packet.dstip
if src not in localhostrecord:
log.info("local host %s is sending for the firsr time" %(src))
t = datetime.time(0, 0, 0)
newIntHost = IntHostEntry(1.0,10,t.second)
localhostrecord[src] = newIntHost
if dst not in localhostrecord[src].PCH:
localhostrecord[src].PCH.append(dst)
newEntry = FCC_Queue_Entry(time.clock(),dst,status[0],ip_protocol)
localhostrecord[src].FCC_Queue.append(newEntry)
、しばらくして、タイムアウトをチェックしています
if(time.clock() - localhostrecord[address].FCC_Queue[index].whenInitiated>=timeout):
どこ
localhostrecord[address].FCC_Queue[index].whenInitiated =time.clock()
他の関数で書かれた
私はエラーが発生しています
TypeError: unsupported operand type(s) for -: 'float' and 'builtin_function_or_method'
その問題を解決する方法