void AppCCNNodeInit(Node* node, NodeRole role, const NodeInput *nodeInput) { char str[MAX_STRING_LENGTH]; BOOL wasFound = FALSE; if(global_node_data == NULL) { global_node_data = new GlobalNodeData(); } global_node_data->setMaxNodeId(node->nodeId); // nodeDataポインタをnodeに保存 // nodeDataはノードでのccnMsgの取り扱いを担う NodeData* nodeData; nodeData = (NodeData*) node->appData.nodeData; if(nodeData == NULL) { nodeData = new NodeData(node, nodeInput); node->appData.nodeData = nodeData; } nodeData->node_role = role; //FIB input nodeData->fibMapInput(node, "fib.conf"); // ハンドラの登録 APP_RegisterNewApp(node, APP_CCN_HOST, nodeData); // TCP受信準備 Address node_addr; node_addr = MAPPING_GetDefaultInterfaceAddressInfoFromNodeId(node, node->nodeId, NETWORK_IPV4); APP_TcpServerListen(node, APP_CCN_HOST, node_addr, (short) APP_CCN_LISTEN_PORT); std::ofstream ofs(nodeData->name_logFile.c_str()); ofs << "node->getNodeTime()" << ", " << "generateToRecv_Delay" << ", " << "sendToRecv_Delay" << ", " << "ccnMsg->msg_chunk_num" << std::endl; // ノードの役割ごとに初期設定 switch(role) { // クライアント case CLIENT: { // timer message送信 // ライブストリーミング if(nodeData->ccn_method != NO_VIDEO) { APP_SetTimer(node, APP_CCN_CLIENT, 0, APP_CCN_LISTEN_PORT, APP_TIMER_SEND_PKT, 800 * MILLI_SECOND); } // 通常コンテンツ APP_SetTimer(node, APP_CCN_CLIENT, 0, APP_CCN_LISTEN_PORT, APP_TIMER_REGULAR_SEND_PKT, 1 * SECOND + 10 * MILLI_SECOND * node->nodeId); break; } // 中継ノード case RELAY_NODE: { break; } // ソースノード case SERVER: { source_node_id = node->nodeId; uint32_t chunk_num; clocktype generateTime; generateTime = 0; double randNum; for(chunk_num = 0; chunk_num < 100000; chunk_num++) { generateTime += nodeData->return_packetRandomGenerateTime(); nodeData->dataGenerateTime_map.insert(pair<uint32_t, clocktype>(chunk_num, generateTime)); randNum = (double) (1.0 / (RAND_MAX + 1.0)) * rand(); nodeData->randomNum_map.insert(pair<uint32_t, double>(chunk_num, randNum)); } break; } default: ERROR_ReportError(""); } }