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

📄 application.pc

📁 simulator for ad hoc
💻 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: application.pc,v 1.45 2001/02/15 03:17:26 mineo Exp $ * * This file contains initialization function, message processing * function, and finalize function used by application layer.  */#include <stdlib.h>#include <stdio.h>#include <string.h>#include <assert.h>#include "api.h"#include "fileio.h"#include "main.h"#include "message.h"#include "application.h"#include "ftp_client.h"#include "ftp_server.h"#include "telnet_client.h"#include "telnet_server.h"#ifdef NSTELNET_STUFF#include "nstelnet_client.h"#include "nstelnet_server.h"#endif#include "cbr_client.h"#include "cbr_server.h"#include "gen_ftp_server.h"#include "gen_ftp_client.h"#include "http_server.h"#include "http_client.h"#include "bellmanford.h"#include "wrp.h"#include "nsdsdv.h"#include "static_routing.h"#include "fisheye.h"//#include "rumorsim/include/Limit.h"//extern void AppRumorInit(GlomoNode *nodePtr, const GlomoNodeInput *);//extern void AppLayerRumor(GlomoNode *node, Message *msg);#define noDEBUG/* * NAME:        GLOMO_AppInit. * PURPOSE:     start applications on nodes according to user's  *              specification.  * PARAMETERS:  node - pointer to the node,  *              nodeInput - configuration information. * RETURN:      none.  */voidGLOMO_AppInit(GlomoNode *node, const GlomoNodeInput *nodeInput){    BOOL retVal;    char buf[GLOMO_MAX_STRING_LENGTH];              /*      * Initialize application layer information.     * note that the starting ephemeral port number is 1024.      */    node->appData.appPtr = NULL;    node->appData.nextPortNum = 1024;     node->appData.numAppTcpFailure = 0;    /*     * Check if statistics needs to be printed.     */    retVal = GLOMO_ReadString(node->nodeAddr, nodeInput,                               "APPLICATION-STATISTICS", buf);    if ((retVal == FALSE) || (strcmp(buf, "NO") == 0)) {        node->appData.appStats = FALSE;        }    else if (strcmp(buf, "YES") == 0) {        node->appData.appStats = TRUE;        }    else {        fprintf(stderr, "APPLICATION-STATISTICS not specified in input file.",                buf);        assert(FALSE);    }    retVal = GLOMO_ReadString(node->nodeAddr, nodeInput,                               "ROUTING-STATISTICS", buf);    if (retVal == FALSE) {        fprintf(stderr, "ROUTING-STATISTICS not specified in input file.\n");        assert(FALSE);    }    if (strcmp(buf, "YES") == 0) {        node->appData.routingStats = TRUE;    }    else if (strcmp(buf, "NO") == 0) {        node->appData.routingStats = FALSE;    }    else {        fprintf(stderr, "ROUTING-STATISTICS has unknown value %s.", buf);        assert(FALSE);    }    /*     * Initialize which routing protocol to use.     */    retVal = GLOMO_ReadString(node->nodeAddr, nodeInput,                               "ROUTING-PROTOCOL", buf);    if (retVal == FALSE) {        fprintf(stderr,"ROUTING-PROTOCOL not specified in input file.\n");        assert(FALSE);    }    if (strcmp(buf, "BELLMANFORD") == 0) {        node->appData.routingProtocol = APP_ROUTING_BELLMANFORD;         RoutingBellmanfordInit(node);     }    else if (strcmp(buf, "OSPF") == 0) {        // Protocol is at routing layer.    }    else if (strcmp(buf, "WRP") == 0) {        node->appData.routingProtocol = APP_ROUTING_WRP;        RoutingWrpInit(node, nodeInput);    }    else if (strcmp(buf, "FISHEYE") == 0) {        node->appData.routingProtocol = ROUTING_PROTOCOL_FISHEYE;        RoutingFisheyeInit(node, nodeInput);    }    else if (strcmp(buf, "NS_DSDV") == 0) {        node->appData.routingProtocol = APP_ROUTING_NS_DSDV;        RoutingNsDsdvInit(node);    }        else if (strcmp(buf, "STATIC") == 0) {        node->appData.routingProtocol = APP_ROUTING_STATIC;        RoutingStaticInit(node, nodeInput);    }    else if (strcmp(buf, "LAR1") == 0) {        // Fine, because Lar is at the Network Level    }    else if (strcmp(buf, "AODV") == 0) {    }    else if (strcmp(buf, "DSR") == 0) {    }    else if (strcmp(buf, "ODMRP") == 0) {    }    else if (strcmp(buf, "ZRP") == 0) {    }    else {        assert(FALSE);    }    /* Setting up applications. */        GLOMO_AppInitApplications(node, nodeInput);        AppLayerInitUserApplications(       node, nodeInput, &node->appData.userApplicationData);}/* * NAME:        GLOMO_AppInitApplications. * PURPOSE:     start applications on nodes according to user's *              specification. * PARAMETERS:  node - pointer to the node, *              nodeInput - configuration information. * RETURN:      none. */void GLOMO_AppInitApplications(GlomoNode *node,                               const GlomoNodeInput *nodeInput){    GlomoNodeInput appInput;    char appStr[GLOMO_MAX_STRING_LENGTH];    char clockStr[GLOMO_MAX_STRING_LENGTH];    char *tempStr;    BOOL retVal;    int  i;        retVal = GLOMO_ReadCachedFile(nodeInput, "APP-CONFIG-FILE", &appInput);    if (retVal == FALSE) {        fprintf(stderr, "Application: Needs APP-CONFIG-FILE.\n");        assert(FALSE); abort();    }    node->appData.uniqueId = 0;    for (i = 0; i < appInput.numLines; i++) {        sscanf(appInput.inputStrings[i], "%s", appStr);        #ifdef DEBUG            printf("Application type is %s\n", appStr);        #endif        if (strcmp(appStr, "FTP") == 0) {            NODE_ADDR sourceAddr, destAddr;            int itemSize;            int itemsToSend;            clocktype startTime;            char startTimeStr[GLOMO_MAX_STRING_LENGTH];            retVal = sscanf(appInput.inputStrings[i],                            "%s %d %d %d %s",                            appStr,                            &sourceAddr,                            &destAddr,                            &itemsToSend,                            startTimeStr);            if (retVal != 5) {                fprintf(stderr,                        "Wrong FTP configuration format!\n"                        "FTP <src> <dest> <items to send> <start time>\n");                assert(0); abort();            }            if (node->nodeAddr == sourceAddr) {                startTime = GLOMO_ConvertToClock(startTimeStr);                #ifdef DEBUG                    printf("Starting FTP client with:\n");                    printf(" source: %u\n", node->nodeAddr);                    printf(" destination: %u\n", destAddr);                    printf(" items to send: %d\n", itemsToSend);                    ctoa(startTime, clockStr);                    printf(" start time string: %s\n", clockStr);                #endif                AppFtpClientInit(node, destAddr, itemsToSend, startTime);            }            else if (node->nodeAddr == destAddr) {                AppFtpServerInit(node);            }        }        else if (strcmp(appStr, "FTP/GENERIC") == 0) {            NODE_ADDR sourceAddr, destAddr;            int itemsToSend, itemSize;            clocktype startTime, endTime;            char startTimeStr[GLOMO_MAX_STRING_LENGTH];            char endTimeStr[GLOMO_MAX_STRING_LENGTH];            retVal = sscanf(appInput.inputStrings[i],                            "%s %ld %ld %ld %ld %s %s",                            appStr, &sourceAddr, &destAddr,                            &itemsToSend, &itemSize,                            startTimeStr, endTimeStr);            if (retVal != 7) {                fprintf(stderr,                        "Wrong FTP/GENERIC configuration format!\n"                        "FTP/GENERIC <src> <dest> <items to send> "                        "<item size> <start time> <end time>\n");                assert(0); abort();            }            if (sourceAddr == destAddr) {                fprintf(stderr,                        "Application: FTP/GENERIC configuration "                        "has same source/dest (node %ld) pair!\n", sourceAddr);                assert(0); abort();            }            if (node->nodeAddr == sourceAddr) {                startTime = GLOMO_ConvertToClock(startTimeStr);                endTime = GLOMO_ConvertToClock(endTimeStr);                #ifdef DEBUG                    printf("Starting FTP client with:\n");                    printf(" source: %u\n", node->nodeAddr);                    printf(" destination: %u\n", destAddr);                    printf(" items to send: %ld\n", itemsToSend);                    ctoa(startTime, clockStr);                    printf(" start time: %s\n", clockStr);                    ctoa(endTime, clockStr);                    printf(" end time: %s\n", clockStr);                #endif                AppGenFtpClientInit(node, destAddr, itemsToSend, itemSize,                                    startTime, endTime);            }            else if (node->nodeAddr == destAddr) {                AppGenFtpServerInit(node);            }        }        else if (strcmp(appStr, "TELNET") == 0) {            NODE_ADDR sourceAddr, destAddr;            char startTimeStr[GLOMO_MAX_STRING_LENGTH];            char sessDurationStr[GLOMO_MAX_STRING_LENGTH];            clocktype startTime, sessDuration;            retVal = sscanf(appInput.inputStrings[i],                            "%s %ld %ld %s %s",                            appStr, &sourceAddr, &destAddr,                            sessDurationStr, startTimeStr);            if (retVal != 5) {                fprintf(stderr,                        "Wrong TELNET configuration format!\n"                        "TELNET <src> <dest> <session duration> "                        "<start time>\n");                assert(0); abort();            }            if (sourceAddr == destAddr) {                fprintf(stderr, "Application: TELNET configuration "                        "has same source/dest (node %ld) pair!\n", sourceAddr);                assert(0); abort();            }            if (node->nodeAddr == sourceAddr) {                startTime = GLOMO_ConvertToClock(startTimeStr);                sessDuration = GLOMO_ConvertToClock(sessDurationStr);                #ifdef DEBUG                    printf("Starting TELNET client with:\n");                    printf(" source: %u\n", node->nodeAddr);                    printf(" destination: %u\n", destAddr);                    ctoa(sessDuration, clockStr);                    printf(" session duration: %s\n", clockStr);                    ctoa(startTime, clockStr);                    printf(" start time: %s\n", clockStr);                #endif                AppTelnetClientInit(node, destAddr, sessDuration, startTime);            }            else if (node->nodeAddr == destAddr) {                AppTelnetServerInit(node);            }

⌨️ 快捷键说明

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