简体   繁体   English

无法在应用层获取网络地址? 真的吗? (全网++)

[英]No way to get the network address at the application layer? really? (omnet++)

How can I check if the current node is the intended destination for these packets (has the same network address (IP addr) as in its wlan[0] (only) interface)?如何检查当前节点是否是这些数据包的预期目的地(与 wlan[0](仅)接口具有相同的网络地址(IP 地址))?

The packet will be passed to the application layer of a node if and only if the destination IP address matches the IP address of this node.当且仅当目标 IP 地址与该节点的 IP 地址匹配时,数据包才会传递到节点的应用层。 Therefore, one may be sure that a packet received in an application layer has the same address as IP address of one of its interface.因此,可以确定在应用层接收到的数据包具有与其接口之一的 IP 地址相同的地址。
However, if you still need the IP address of the node feel free to use one of methods from L3AddressResolver , for example addressOf() :但是,如果您仍然需要节点的 IP 地址,请随意使用L3AddressResolver中的一种方法,例如addressOf()

cModule * host = getContainingNode(this);
L3Address addr = L3AddressResolver().addressOf(host);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM