添加MAC帧首部的过程

因为要用到MAC帧首部,细细研究了仿真中帧首部的添加及使用环节。只写出结果,找到这个结果耗费了很长时间,过程就不写了。

一、添加环节

1. https://blog.csdn.net/zhang1806618/article/details/107753611中写到了调用QueueUpIpFragmentForMacLayer发送数据。在该函数中调用NetworkIpOutputQueueInsert()函数,将一个消息插入输出队列,然后调用MAC_NetworkLayerHasPacketToSend()发送消息。

static void 
QueueUpIpFragmentForMacLayer(
    Node *node,
    Message *msg,
    int interfaceIndex,
    NodeAddress nextHop,
    int incomingInterface)
{
    NetworkDataIp *ip = (NetworkDataIp *) node->networkData.networkVar;
    Scheduler *scheduler = ip->interfaceInfo[interfaceIndex]->scheduler;
    IpHeaderType* ipHeader = (IpHeaderType *) MESSAGE_ReturnPacket(msg);
    NetworkDataIcmp *icmp = (NetworkDataIcmp*) ip->icmpStruct;
    BOOL queueIsFull;
    BOOL queueWasEmpty;
    NetworkType netType = NETWORK_IPV4;
    {
        queueWasEmpty = NetworkIpOutputQueueIsEmpty(node, interfaceIndex);
    }
    NetworkIpOutputQueueInsert(node,
                               interfaceIndex,
                               msg,
                               nextHop,
                               ipHeader->ip_dst,
                               NETWORK_PROTOCOL_IP,
                               &queueIsFull);
    if (queueWasEmpty)
    {
        {
            if (!NetworkIpOutputQueueIsEmpty(node, interfaceIndex))
            {
                MAC_NetworkLayerHasPacketToSend(node, interfaceIndex);
            }
        }
    }
}

2. 函数NetworkIpOutputQueueInsert()调用NetworkIpQueueInsert()函数将消息插入队列。

void
NetworkIpOutputQueueInsert(
    Node *node,
    int outgoingInterface,
    Message *msg,
    NodeAddress nextHopAddress,
    NodeAddress destinationAddress,
    int networkType,
    BOOL *queueIsFull)
{
    NetworkDataIp *ip = (NetworkDataIp *) node->networkData.networkVar;
    Scheduler *scheduler = NULL;    
    scheduler = ip->interfaceInfo[outgoingInterface]->scheduler;
    NetworkIpQueueInsert(node,
                         scheduler,
                         msg,
                         nextHopAddress,
                         destinationAddress,
                         outgoingInterface,
                         networkType,
                         queueIsFull,
        
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值