本文整理汇总了Python中Packet.Packet.server_ack方法的典型用法代码示例。如果您正苦于以下问题:Python Packet.server_ack方法的具体用法?Python Packet.server_ack怎么用?Python Packet.server_ack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packet.Packet
的用法示例。
在下文中一共展示了Packet.server_ack方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: store
# 需要导入模块: from Packet import Packet [as 别名]
# 或者: from Packet.Packet import server_ack [as 别名]
def store(self, time, packet):
#print ("TYPE:" + self.type, "FLAG:" + str(packet.flag), "STATE: " + self.STATE + "\n")
#print ("\n")
if packet.body:
self.buffer = packet.body
print (self.buffer)
if self.type == "SERVER":
#Client sent out ACK, now server is fully connected
if packet.flag == "ACK" and self.STATE == __SYN_RCVD__:
print ("ACK-RCVD")
print (__SYN_RCVD__, "->", __ESTABLISHED__)
self.STATE = __ESTABLISHED__
a = self
self.accept_handler(self.current_time(), a)
elif packet.flag == "ACK" and self.STATE == __ESTABLISHED__:
pack = Packet(None, self.remote)
pack.flag = "ACK"
self.STATE == __CLOSE_WAIT__
self.cache[pack.key] = pack
self.sched.add(self.current_time(), pack, self.send_data)
elif packet.flag == "ACK" and self.STATE == __LAST_ACK__:
self.STATE == __CLOSED__
print (__LAST_ACK__, "->", __CLOSED__)
return
elif packet.flag == None and self.STATE == __ESTABLISHED__:
#s = raw_input(str(packet.seq_number) + " : " + str(self.packet_number))
if self.packet_number == packet.seq_number:
#print (self.packet_number, packet.seq_number, packet.length)
#s = raw_input("self.packet_number == packet.seq_number")
pack = Packet(None, self.remote)
pack.flag = "ACK"
#print (packet.seq_number)
pack.server_ack = packet.seq_number + packet.length
self.packet_number = pack.server_ack
self.cache[pack.key] = pack
#print ("Packet Number: " + str(self.packet_number))
print ("<- ack " + str(pack.server_ack))
self.sched.add(self.current_time(), self.buffer, self.recv_handler)
self.sched.add(self.current_time(), pack, self.send_data)
else:
#print (self.packet_number, packet.seq_number, packet.length)
#s = input("self.packet_number !!!= packet.seq_number")
self.cache[packet.seq_number] = packet
pack = Packet(None, self.remote)
pack.flag = "ACK"
#print (packet.seq_number)
self.cache[pack.key] = pack
pack.server_ack = self.packet_number
self.packet_number = pack.server_ack
print ("<- ack " + str(pack.server_ack))
self.sched.add(self.current_time(), self.buffer, self.recv_handler)
self.sched.add(self.current_time(), pack, self.send_data)
elif packet.flag == "FIN" and self.STATE == __ESTABLISHED__:
pack1 = Packet(None, self.remote)
pack1.flag = "ACK"
self.STATE = __CLOSE_WAIT__
print (__ESTABLISHED__, "->", __CLOSE_WAIT__)
pack1.set_key("ACK")
self.cache[pack1.key] = pack1
self.sched.add(self.current_time(), pack1, self.send_data)
pack2 = Packet(None, self.remote)
pack2.flag = "FIN"
self.STATE = __LAST_ACK__
pack2.set_key("FIN")
self.cache[pack2.key] = pack2
print (__CLOSE_WAIT__, "->", __LAST_ACK__)
self.sched.add(self.current_time(), pack2, self.send_data)
elif packet.flag == "SYN" and self.STATE == __CLOSED__:
self.STATE = __SYN_RCVD__
pack = Packet(None, self.remote)
pack.flag = "SYNACK"
print ("SYN-RCVD -> SYN+ACK")
pack.set_key('SYNACK')
self.cache[pack.key] = pack
self.sched.add(self.current_time(), pack, self.send_data)
'''
pass
'''
#Must be a client
else:
#.........这里部分代码省略.........