接上文https://blog.csdn.net/zhang1806618/article/details/107856736
2.3 网络层
NETWORK_ReceivePacketFromMacLayer函数区分网络层协议调用相应协议处理。对IPv4协议,调用NetworkIpReceivePacketFromMacLayer()函数,该函数又直接调用NetworkIpReceivePacket()函数。在NetworkIpReceivePacket()函数中,判断是否是发送给本节点的包,如果不是,直接转发;如果是,经由背板处理,另外判断是否多播包,多播包还需转发。
void NetworkIpReceivePacket(
Node *node,
Message *msg,
NodeAddress previousHopAddress,
int incomingInterface)
{
NetworkType netType = NETWORK_IPV4;
//是发送给本节点的包
if (IsMyPacket(node, ipHeader->ip_dst) || IsIgmpPacket(node, ipHeader->ip_p))
{
BOOL isMulticast = NetworkIpIsMulticastAddress(node, ipHeader->ip_dst);
Message* sendMessage = msg;
if (isMulticast)
{
sendMessage = MESSAGE_Duplicate(node, msg)