1 / 8

Using Timer on Application Layer

Using Timer on Application Layer. 2012.6.4. Prof. Park Yoon Young. Introduction. Application 레이어에 새로운 타이머를 등록하여 매 초마다 호출되어 전송된 CBR 패킷 수를 출력한다 . 새로운 메시지 등록 CBR 패킷을 출력하는 함수 작성 Init 함수에 새로운 Timer 초기 등록 Event 처리 함수에서 발생된 메시지를 처리하는 부분 작성. (step 1) 새로운 메시지 등록.

mimis
Télécharger la présentation

Using Timer on Application Layer

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Using Timer on Application Layer 2012.6.4. Prof. Park Yoon Young UBILAB by yypark

  2. Introduction • Application 레이어에 새로운 타이머를 등록하여 매 초마다 호출되어 전송된 CBR 패킷 수를 출력한다. • 새로운 메시지 등록 • CBR 패킷을 출력하는 함수 작성 • Init함수에 새로운 Timer 초기 등록 • Event 처리 함수에서 발생된 메시지를 처리하는 부분 작성 UBILAB by yypark

  3. (step 1)새로운 메시지 등록 • Include 디렉토리에api.h함수에 메시지 등록한다. // /** // ENUM :: MESSAGE/EVENT // DESCRIPTION :: Event/message types exchanged in the simulation // **/ enum { /* Special message types used for internal design. */ MSG_SPECIAL_Timer = 0, … //StartIERP ROUTING_IerpRouteRequestTimeExpired, ROUTING_IerpFlushTimeOutRoutes, //EndIERP //Start User Timer MSG_APP_SecondPrint, //End User Timer //InsertPatch EVENT_TYPES … } UBILAB by yypark

  4. (step 2) 출력함수 작성-1 • Libraries\developer\src디렉토리에app_cbr.h파일에 함수 정의(definition)를 추가한다. void AppCbrClientPrintStatsCMD(Node *node, AppDataCbrClient *clientPtr); UBILAB by yypark

  5. (step 3) 출력함수 작성-2 • Libraries\developer\src디렉토리에app_cbr.cpp 파일에 함수를 추가한다. void AppCbrClientPrintStatsCMD(Node *node, AppDataCbrClient *clientPtr) { char timeStr[MAX_STRING_LENGTH]; TIME_PrintClockInSecond(*(node->currentTime), timeStr); printf(“CBRClient | Node %d, NumPacket %d at %s \n”, node->nodeId, clientPtr->numPktsSent, timeStr); } UBILAB by yypark

  6. (step 4)init함수에 초기 Timer 등록 • $QUALNET_HOME\libraries\developer\src디렉토리의app_cbr.cpp • AppCbrClientInit() 함수에 초기 타이머를 등록한다. timer->sourcePort = clientPtr->sourcePort; timer->type = APP_TIMER_SEND_PKT; AppTimer *tempTimer; Message *newMsg; newMsg = MESSAGE_Alloc(node, APP_LAYER, APP_CBR_CLIENT, MSG_APP_SecondPrint); MESSAGE_InfoAlloc(node, newMsg, sizeof(AppTimer)); tempTimer = (AppTimer *)MESSAGE_ReturnInfo(newMsg); tempTimer->sourcePort = clientPtr->sourcePort; MESSAGE_Send(node, newMsg, 1000000000); // 나노초단위로입력 #ifdef DEBUG … UBILAB by yypark

  7. (step 5) Event 처리 함수에 새로운 이벤트를 처리하는 함수 작성 • Libraries\developer\src디렉토리의app_cbr.cpp • AppLayerCbrClient() 함수에 MSG_APP_SecondPrint이벤트를 처리하는 부분을 추가하여준다. … switch (msg->eventType) { case MSG_APP_SecondPrint: { AppTimer *timer, *tempTimer; timer = (AppTimer *)MESSAGE_ReturnInfo(msg); clientPtr = AppCbrClientGetCbrClient(node, timer->sourcePort); AppCbrClientPrintStatsCMD(node, clientPtr); Message *newMsg; newMsg = MESSAGE_Alloc(node, APP_LAYER, APP_CBR_CLIENT, MSG_APP_SecondPrint); MESSAGE_InfoAlloc(node, newMsg, sizeof(AppTimer)); tempTimer = (AppTimer *)MESSAGE_ReturnInfo(newMsg); tempTimer->sourcePort=clientPtr->sourcePort; MESSAGE_Send(node, newMsg, 1000000000); break; } case MSG_APP_TimerExpired: … } UBILAB by yypark

  8. (step 6) 시나리오 작성 및 테스트 • GUI 환경에서 간단한 시나리오를 작성한다. • PHY, MAC은 802.11b를 사용한다. • APP에서 CBR 데이터를 전송한다. • > cd main • > nmake • > cd $QUALNETHOME\scenarios\default • > qualnetdefault.config UBILAB by yypark

More Related