本文整理汇总了Python中Network.l3_sendto方法的典型用法代码示例。如果您正苦于以下问题:Python Network.l3_sendto方法的具体用法?Python Network.l3_sendto怎么用?Python Network.l3_sendto使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Network
的用法示例。
在下文中一共展示了Network.l3_sendto方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: l4_sendto
# 需要导入模块: import Network [as 别名]
# 或者: from Network import l3_sendto [as 别名]
def l4_sendto(node, dest_nid, data):
# get port table for this node and set values for destination target
PortTable = node.GetPortTable()
for link in PortTable:
info = PortTable[link]
if info[0] == dest_nid:
dest_port = info[2]
# get md5 hash of data for checksum
m = hashlib.md5()
m.update(data)
checksum = m.hexdigest()
# build datagram
frame = {}
frame['source_nid'] = node.GetNID()
frame['source_port'] = node.GetPort()
frame['destination_nid'] = dest_nid
frame['destination_port'] = dest_port
frame['sequence_number'] = 1
frame['ack_number'] = 1
frame['window_size'] = 15
frame['checksum'] = checksum
frame['data'] = data
# encode payload
payload = json.dumps(frame)
Network.l3_sendto(node, dest_nid, payload)
示例2: l4_sendto
# 需要导入模块: import Network [as 别名]
# 或者: from Network import l3_sendto [as 别名]
def l4_sendto(node, dest_nid, data):
segment = data
Network.l3_sendto(node, dest_nid, segment)