⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 app_util.pc

📁 无线网络仿真工具Glomosim2.03
💻 PC
📖 第 1 页 / 共 2 页
字号:
/* * GloMoSim is COPYRIGHTED software.  Release 2.02 of GloMoSim is available  * at no cost to educational users only. * * Commercial use of this software requires a separate license.  No cost, * evaluation licenses are available for such purposes; please contact * info@scalable-networks.com * * By obtaining copies of this and any other files that comprise GloMoSim2.02, * you, the Licensee, agree to abide by the following conditions and * understandings with respect to the copyrighted software: * * 1.Permission to use, copy, and modify this software and its documentation *   for education and non-commercial research purposes only is hereby granted *   to Licensee, provided that the copyright notice, the original author's *   names and unit identification, and this permission notice appear on all *   such copies, and that no charge be made for such copies. Any entity *   desiring permission to use this software for any commercial or *   non-educational research purposes should contact:  * *   Professor Rajive Bagrodia  *   University of California, Los Angeles  *   Department of Computer Science  *   Box 951596  *   3532 Boelter Hall  *   Los Angeles, CA 90095-1596  *   rajive@cs.ucla.edu * * 2.NO REPRESENTATIONS ARE MADE ABOUT THE SUITABILITY OF THE SOFTWARE FOR ANY *   PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. * * 3.Neither the software developers, the Parallel Computing Lab, UCLA, or any *   affiliate of the UC system shall be liable for any damages suffered by *   Licensee from the use of this software. */// Use the latest version of Parsec if this line causes a compiler error./* * $Id: app_util.pc,v 1.20 2001/02/15 03:17:26 mineo Exp $ * utilities used by application to send packet to transport layer * and open a connection. */#include <stdio.h>#include <stdlib.h>#include <string.h>#include <assert.h>#include "api.h"#include "structmsg.h"#include "message.h"#include "fileio.h"#include "transport.h"#include "ip.h"#define noDEBUG/*  * FUNCTION: AppUdpSendNewData * PURPOSE:    allocate a new GLOMO message and send to UDP. * PARAMETERS: node - node that is sending the data. *             appType - application type, to be used as destination port. *             destAddr - the destination node Id data is sent to.              *             payload  - pointer to the data. *             payloadSize - size of the data in bytes. *             delay - send the data after this delay. */voidAppUdpSendNewData(GlomoNode *node, APP_TYPE appType, NODE_ADDR destAddr,                  char *payload, int payloadSize, clocktype delay)                 {    Message *msg;    AppToUdpSend *info;    msg = GLOMO_MsgAlloc (node, GLOMO_TRANSPORT_LAYER,                          TRANSPORT_PROTOCOL_UDP, MSG_TRANSPORT_FromAppSend);    GLOMO_MsgPacketAlloc (node, msg, payloadSize);    memcpy(msg->packet, payload, payloadSize);     GLOMO_MsgInfoAlloc (node, msg, sizeof(AppToUdpSend));    info = (AppToUdpSend *) msg->info;    info->sourceAddr = node->nodeAddr;    info->sourcePort = appType;    info->destAddr = destAddr;    info->destPort = appType;    info->priority = NON_REAL_TIME;    GLOMO_MsgSend(node, msg, delay);}/*  * FUNCTION: AppUdpSendNewDataWithPriority * PURPOSE:    allocate a new GLOMO message and send to UDP. * PARAMETERS: node - node that is sending the data. *             appType - application type, to be used as destination port. *             destAddr - the destination node Id data is sent to.              *             payload  - pointer to the data. *             payloadSize - size of the data in bytes. *             priority - priority of data. *             delay - send the data after this delay. */voidAppUdpSendNewDataWithPriority(GlomoNode *node,                               APP_TYPE appType,                              NODE_ADDR destAddr,                               char *payload,                               int payloadSize,                               NetworkQueueingPriorityType priority,                               clocktype delay){    Message *msg;    AppToUdpSend *info;    msg = GLOMO_MsgAlloc (node, GLOMO_TRANSPORT_LAYER,                          TRANSPORT_PROTOCOL_UDP, MSG_TRANSPORT_FromAppSend);    GLOMO_MsgPacketAlloc (node, msg, payloadSize);    memcpy(msg->packet, payload, payloadSize);     GLOMO_MsgInfoAlloc (node, msg, sizeof(AppToUdpSend));    info = (AppToUdpSend *) msg->info;    info->sourceAddr = node->nodeAddr;    info->sourcePort = appType;    info->destAddr = destAddr;    info->destPort = appType;    info->priority = priority;    GLOMO_MsgSend(node, msg, delay);}/*  * FUNCTION: AppUdpSendNewHeaderData * PURPOSE:    allocate a new GLOMO message and send to UDP. * PARAMETERS: node - node that is sending the data. *             appType - application type, to be used as destination port. *             destAddr - the destination node Id data is sent to. *             header - header of the payload. *             headerSize - size of the header.q *             payload  - pointer to the data. *             payloadSize - size of the data in bytes. *             delay - send the data after this delay. */voidAppUdpSendNewHeaderData(GlomoNode *node, APP_TYPE appType, NODE_ADDR destAddr,                        char *header, int headerSize, char *payload,                         int payloadSize, clocktype delay){    Message *msg;    AppToUdpSend *info;    msg = GLOMO_MsgAlloc (node, GLOMO_TRANSPORT_LAYER,                          TRANSPORT_PROTOCOL_UDP, MSG_TRANSPORT_FromAppSend);    GLOMO_MsgPacketAlloc (node, msg, payloadSize);    memcpy(msg->packet, payload, payloadSize);    GLOMO_MsgAddHeader(node, msg, headerSize);    memcpy(msg->packet, header, headerSize);     GLOMO_MsgInfoAlloc (node, msg, sizeof(AppToUdpSend));    info = (AppToUdpSend *) msg->info;    info->sourceAddr = node->nodeAddr;    info->sourcePort = appType;    info->destAddr = destAddr;    info->destPort = appType;    info->priority = NON_REAL_TIME;    GLOMO_MsgSend(node, msg, delay);}/*  * FUNCTION: AppUdpSendNewHeaderDataWithPriority * PURPOSE:    allocate a new GLOMO message and send to UDP. * PARAMETERS: node - node that is sending the data. *             appType - application type, to be used as destination port. *             destAddr - the destination node Id data is sent to. *             header - header of the payload. *             headerSize - size of the header.q *             payload  - pointer to the data. *             payloadSize - size of the data in bytes. *             priority - priority of data. *             delay - send the data after this delay. */voidAppUdpSendNewHeaderDataWithPriority(GlomoNode *node,                                     APP_TYPE appType,                                     NODE_ADDR destAddr,                                    char *header,                                     int headerSize,                                     char *payload,                                     int payloadSize,                                     NetworkQueueingPriorityType priority,                                     clocktype delay){    Message *msg;    AppToUdpSend *info;    msg = GLOMO_MsgAlloc (node, GLOMO_TRANSPORT_LAYER,                          TRANSPORT_PROTOCOL_UDP, MSG_TRANSPORT_FromAppSend);    GLOMO_MsgPacketAlloc (node, msg, payloadSize);    memcpy(msg->packet, payload, payloadSize);    GLOMO_MsgAddHeader(node, msg, headerSize);    memcpy(msg->packet, header, headerSize);     GLOMO_MsgInfoAlloc (node, msg, sizeof(AppToUdpSend));    info = (AppToUdpSend *) msg->info;    info->sourceAddr = node->nodeAddr;    info->sourcePort = appType;    info->destAddr = destAddr;    info->destPort = appType;    info->priority = priority;    GLOMO_MsgSend(node, msg, delay);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -