프로그램에 두 줄의 함수 호출만 추가하여
std i/o를  redirection하는 함수를 만들려다..
결국 만들었습니다!!
아..재밌는데 더 하긴 귀찮네요.

// redirection_in.cc
// redirection in을 간단히 사용하기 위한 함수를 정의
// 키보드 입력을 파일로 대체!

#include <fcntl.h>
#include <sys/io.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>
#include <sys/wait.h>

int redirect_original_stdin;

int redirect_stdin_to_file( char * fname )
{
    // stdin을 keyboard에서 read pipe로 대체하는 함수
   
    // 1. pipe 초기화
    // 2. fork로 자식 프로세스 생성
    //    부모 - stdin(키보드)을 복제, stdin을 read pipe로 대체, read pipe 닫기, 0을 리턴
    // 여기서부턴 자식 프로세스만
    // 3. 파일 오픈
    // 4. 파일 내용을 write pipe에 기록
    // 5. 파일 닫고
    // 6. write pipe 닫고
    // 7. 종료(return 말고 exit)
   
    int pid, result;
    int redirect_fdpipe[2];
   
    if( pipe(redirect_fdpipe) == -1 )
        return 0;
       
    pid = fork();
    if( pid>0 )
    {
        close( redirect_fdpipe[1] );
        redirect_original_stdin = dup( STDIN_FILENO );
        dup2( redirect_fdpipe[0], STDIN_FILENO );
        close( redirect_fdpipe[0] );

        return 0;
    }
    else if( pid==0 )
    {
        // 이 자식 프로세스가 입력 파일을 읽어서
        // 부모 프로세스의 stdin에게 전달한다.
       
        int n,i;
        const int BUFFSIZE = 100;
        char buf[BUFFSIZE];
       
        close( redirect_fdpipe[0] );
       
        FILE * file;   

        file = fopen( fname, "r" );
        if( file==NULL )
            exit(0);
       
        i = 0;
        while( (n=fread(buf,1,BUFFSIZE,file))>=0 )
        {
            if( n>0 )
            {
                write( redirect_fdpipe[1], buf, n );
                i = 0;
            }
            else
            {
                if( ++i>10 )
                    break;
            }
        }
       
        close( redirect_fdpipe[1] );
        exit(0);
    }
}

int redirect_stdin_restore()
{
    // stdin을 read pipe에서 keybooard로 복구하는 함수
   
    // 1. 버퍼에 있는 데이터들 전부 처리(fflush)
    // 2. stdin (파이프) 닫기
    // 3. 백업한 stdin의 descriptor을 이용해 stdin을 키보드로 복구(dup2)
   
    int result;
   
    fflush( stdin );    // 이거없음 곤란한 경우 가끔 발생
       
    result = close( STDIN_FILENO );
    if( result<0 )
        return -1;

    result = dup2( redirect_original_stdin, STDIN_FILENO );   
    if( result<0 )
        return -1;
       
    return 0;
}

int main(int argc, char **argv)
{
    int result;
   
    // 예제 1
    // file을 stdin 입력으로-
    result = redirect_stdin_to_file( "input.dat" );
    if( result<0 )
    {
        printf("redirect_stdin_to_file error\n");
        return 0;
    }
   
    // 아래 fork는 redirection이 아니라 서브 프로그램을 실행하기 위한 절차
    int pid = fork();
    if( pid==0 )
    {
        execl( "./sinout", "/sinout", NULL );
        exit(0);
    }
    else if( pid>0 )
    {
        int status;
        wait( &status );
    }
    else
    {
        // error!
    }
   
    result = redirect_stdin_restore();
    if( result<0 )
    {
        printf("redirect_stdin_restore error\n");
        return 0;
    }
   
    return 0;
}

Posted by 배트
,

프로그램에 두 줄의 함수 호출만 추가하여
std i/o를  redirection하는 함수를 만들려다..
결국 만들었습니다!!
아..재밌는데 더 하긴 귀찮네요.

// redirection_out.cc
// redirection out을 간단히 사용하기 위한 함수를 정의

#include <fcntl.h>
#include <sys/io.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>
#include <sys/wait.h>

int redirect_original_stdout;
FILE * redirect_stream;

int redirect_stdout_to_file( char * fname, int append=0 )
{
    // stdout을 screen에서 file로 대체하는 함수
   
    // 1. 파일 열기(open)
    // 2. stdout의 descriptor 백업(dup)
    // 3. stdout을 file로 대체(dup2)
    // 4. 파일 닫기(close)
   
   
    int result;
    char openflag[5];
   
    if( append )
        strcpy( openflag, "a" );
    else
        strcpy( openflag, "w+" );

    redirect_stream = fopen( fname, openflag );
    if( redirect_stream==NULL )
        return -1;
   
    if( append )
        fseek( redirect_stream, 0, SEEK_END );           
   
    redirect_original_stdout = dup( STDOUT_FILENO );
    if( redirect_original_stdout<0 )
        return -1;
   
    result = dup2( fileno( redirect_stream ), STDOUT_FILENO );
    if( result<0 )
        return -1;
   
    result = fclose( redirect_stream );
    if( result!=0 )
        return -1;
   
    return 0;
}

int redirect_stdout_restore()
{
    // stdout을 file에서 screen으로 복구하는 함수
   
    // 1. 버퍼에 있는 데이터들 모두 처리(fflush)
    // 2. stdout (파일) 닫기
    // 3. 백업한 stdout의 descriptor을 이용해 stdout을 화면으로 복구(dup2)
   
    int result;
   
    fflush( stdout );    // 이거없음 곤란한 경우 가끔 발생
           
    result = close( STDOUT_FILENO );
    if( result<0 )
        return -1;

    result = dup2( redirect_original_stdout, STDOUT_FILENO );   
    if( result<0 )
        return -1;
       
    return 0;
}

int main(int argc, char **argv)
{
    int result;
    int appendmode;
   
    if( argc==2 && atoi(argv[1])==1 )
        appendmode = 1;
    else
        appendmode = 0;

    // 예제 1
    // stdout으로의 출력을 file로-
    result = redirect_stdout_to_file( "output.txt", appendmode );
    if( result<0 )
    {
        printf("redirect_stdout_to_file error\n");
        return 0;
    }
   
    // 파일에 쓰기 1
    printf( "this is file output 1 (buffered)\n" );
   
    // 파일에 쓰기 2
    char * msg = "this is file output 2 (direct)\n";
    write( STDOUT_FILENO, msg, strlen(msg) );
   
    result = redirect_stdout_restore();
    if( result<0 )
    {
        printf("redirect_stdout_restore error\n");
        return 0;
    }
   
    return 0;
}

Posted by 배트
,

dup, dup2

開發 - Computer/Linux 2009. 4. 10. 12:04

문득 궁금해져서...새벽에 삽질했습니다.

부모 프로세스가 stdin또는 stdout을 다른 I/O로 redirection 했다면,
fork로 만든 자식 프로세스나 exec로 실행한 서브 프로그램도
stdin, stdout을 redirection한 I/O를 유지하고 있을까?
-> yes!



// dupout.cc
// 자식/서브 프로세스가 부모 프로세스의 stdin/stdout의 특성을 물려받는지 알아보기 위한 테스트

#include <fcntl.h>
#include <io.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>
#include <sys/wait.h>

int main(int argc, char **argv)
{
    //int fd = open("flist.cc", O_RDONLY);
    int fd = open( "a.txt", _O_CREAT|_O_RDWR|_O_TRUNC, S_IRWXU|S_IRWXG|S_IRWXO );
    if( fd<=0 )
    {
        char * errmsg = "Cannot created file\n";
        write( STDOUT_FILENO, errmsg, strlen(errmsg) );
        return 0;
    }

    // 예제 1
    // STDOUT_FILENO의 입력을 File로

    // STDOUT_FILENO으로의 입력을 fd로 redirection
    int tempFd = dup(STDOUT_FILENO);
    dup2( fd, STDOUT_FILENO );

    // STDOUT_FILENO에 기록 - fd에 기록된다
    char * msg1 = "this is file output\n";
    write( STDOUT_FILENO, msg1, strlen(msg1) );
   
    // 자식 프로세스 생성
    // fork로 생성한 자식 프로세스가 부모 프로세스의 stdin/stdout 성질을 물려받는가?
    int pid = fork();
    if( pid>0 )
    {
        // parent
        int stat=0;
        wait(&stat);
    }
    else if( pid==0 )
    {
        // child
        char * msgch = "this is message from the child\n";
        write( STDOUT_FILENO, msgch, strlen(msgch) );

        // 한번 더 자식 프로세스 생성, 증손이네ㅋㅋ       
        // execl로 실행한 서브 프로세스가 부모 프로세스의 stdin/stdout 성질을 물려받는가?
        int pid = fork();
        if( pid==0 )
            // Child
            execl( "/bin/ls", "/bin/ls", NULL );
        return 0;
    }
    else
    {
        // error
    }
   
    close( fd );

    // STDOUT_FILENO 복구
    dup2( tempFd, STDOUT_FILENO );
    close( tempFd );
   
    // STDOUT_FILENO에 기록 - 화면에 출력된다
    char * msg2 = "this is screen output\n";
    write( STDOUT_FILENO, msg2, strlen(msg2) );
   
    return 0;
}

Posted by 배트
,

ns-2 Full-TCP and Wireless

This is a hack to allow the use of Full-TCP in wireless simulations using DSDV routing. The basic problem is that the IP header is added at the wireless network layer and also accounted for at the Full-TCP transport layer. This code just checks a flag to see if the IP header should be added at the network layer.

To use this, just add Agent/DSDV set fulltcp_ 1 to your TCL script (before you do node-config) once you've made the following changes to the ns source and re-compiled.

Files Changed

  • dsdv/dsdv.cc
  • dsdv/dsdv.h
  • tcl/mobility/dsdv.tcl

    Note: These diffs are based on the ns-2.29 release.

    dsdv/dsdv.cc

    Index: dsdv.cc
    *** dsdv.cc     13 Jul 2005 03:51:24 -0000      1.25
    --- dsdv.cc     7 Mar 2006 15:26:16 -0000
    ***************
    *** 1009,1015 ****
          /*
           * Add the IP Header
           */
    !     cmh->size() += IP_HDR_LEN;    
          iph->ttl_ = IP_DEF_TTL;
        }
        /*
    --- 1009,1017 ----
          /*
           * Add the IP Header
           */
    !         if (!fulltcp_) {
    !                 cmh->size() += IP_HDR_LEN;    
    !         }
          iph->ttl_ = IP_DEF_TTL;
        }
        /*
    ***************
    *** 1080,1086 ****
        periodic_callback_ (0), be_random_ (1), 
        use_mac_ (0), verbose_ (1), trace_wst_ (0), lasttup_ (-10), 
        alpha_ (0.875),  wst0_ (6), perup_ (15), 
    !   min_update_periods_ (3)     // constants
       {
        table_ = new RoutingTable ();
        helper_ = new DSDV_Helper (this);
    --- 1082,1088 ----
        periodic_callback_ (0), be_random_ (1), 
        use_mac_ (0), verbose_ (1), trace_wst_ (0), lasttup_ (-10), 
        alpha_ (0.875),  wst0_ (6), perup_ (15), 
    !   min_update_periods_ (3), fulltcp_(0)        // constants
       {
        table_ = new RoutingTable ();
        helper_ = new DSDV_Helper (this);
    ***************
    *** 1095,1100 ****
    --- 1097,1104 ----
        bind ("min_update_periods_", &min_update_periods_);
        bind ("verbose_", &verbose_);
        bind ("trace_wst_", &trace_wst_);
    +   // MCW  2006Feb02
    +   bind ("fulltcp_", &fulltcp_);
        //DEBUG
        address = 0;
    
    dsdv/dsdv.h
    Index: dsdv.h
    *** dsdv.h      20 Aug 1999 18:03:16 -0000      1.6
    --- dsdv.h      7 Mar 2006 15:16:21 -0000
    ***************
    *** 137,142 ****
    --- 137,145 ----
        int    min_update_periods_;    // 3 we must hear an update from a neighbor
        // every min_update_periods or we declare
        // them unreachable
    + 
    +       // MCW 2006Feb02
    +       int fulltcp_;
        
        void output_rte(const char *prefix, rtable_ent *prte, DSDV_Agent *a);
    
    tcl/mobility/dsdv.tcl
    Index: dsdv.tcl
    *** dsdv.tcl    23 Dec 2003 17:36:35 -0000      1.14
    --- dsdv.tcl    7 Mar 2006 15:18:37 -0000
    *** 49,54 ****
    --- 49,57 ----
      Agent/DSDV set verbose_      0        ;# 
      Agent/DSDV set trace_wst_    0        ;# 
      
    + # MCW  2006Feb02
    + Agent/DSDV set fulltcp_ 0
    + 
      set opt(ragent)               Agent/DSDV
      set opt(pos)          NONE                    ;# Box or NONE
    

    Michele C. Weigle
    Last modified: Wed Sep 13 02:31:03 UTC+0900 2006

  • 출처 : http://www.cs.odu.edu/~mweigle/research/netsim/fulltcp-wlan.html
    Posted by 배트
    ,

    네트워크 시뮬레이션을 위해 트래픽 모델과 시뮬레이션들을 찾던 와중에 좋은 자료를 발견했습니다.
    대부분 기존 시뮬레이터에 네트워크 트래픽 모듈을 붙이기만 하면 돌아가는 것들입니다.
    특히 PackMIME은 ns-2 ver2.2x 부터 정식 포함되어있는 모듈이기도 하죠.
    네트워크 시뮬레이션을 하기에 유용한 자료들입니다.

    출처 : The ICSI 홈페이지, http://www.icir.org/models/trafficgenerators.html

    Traffic Generators for Internet Traffic

    • Henning's web page on traffic generators.

    • D-ITG's web page on traffic generators.

    • Polly Huang's traffic generator in NS:
      Anja Feldmann, Anna C. Gilbert, Polly Huang and Walter Willinger. Dynamics of IP Traffic: A Study of the Role of Variability and the Impact of Control, SIGCOMM'99, Boston, MA, Sep 1999.
      "During a Web session, a user usually requests several Web pages and each page may contain several web objects. To capture this hierarchical structure and its inherent variability, we allow for different probability distributions for the following user/session attributes: inter-session time, pages per session, inter-page time, objects per page, inter-object time, and object size... We base our choice of distributions on the work surrounding SURGE... and upon [Feldman99, Mogel97]."

    • The NSWEB traffic generator for NS-2.29.

    • The PackMime-HTTP traffic generator in NS:
      J. Cao, W.S. Cleveland, Y. Gao, K. Jeffay, F.D. Smith, and M.C. Weigle, Stochastic Models for Generating Synthetic HTTP Source Traffic, IEEE INFOCOM, March 2004.
      ``New source-level models for aggregated HTTP traffic ... are built and validated using two large-scale collections of TCP/IP packet header traces." The TCP connections are modeled ``in terms of connection establishment rates and the sizes and timing of exchanges of request and response data."
      The PackMime-HTTP traffic generator requires the use of Full-TCP in NS.

    • The tmix traffic generator.
      M. Weigle, P. Adurthi, F. Hernandez-Campos, K. Jeffay and F. D. Smith, Tmix: A Tool for Generating Realistic TCP Application Workloads in ns-2, CCR, July 2006.
      "The system takes as input a packet header trace taken from a network link of interest. The trace is reverse compiled into a source-level characterization of each TCP connection present in the trace."

    • NETI@home:
      NETI@home collects network performance statistics from end-systems. The related work includes models of user behavior.

    • The Swing traffic generator:
      K. Viashwanath and A. Vahdat, Realistic and Responsive Network Traffic Generation, SIGCOMM 2006.
      "Starting from observed traffic at a single point in the network, Swing automatically extracts distributions for user, application, and network behavior."

    • D-ITG, Distributed Internet Traffic Generator for testbeds:
      D-ITG produces traffic "accurately replicating appropriate stochastic processes for both IDT (Inter Departure Time) and PS (Packet Size)", and is capable of generating traffic at the network, transport, and application layers. Includes DCCP support. Updated 2006.

    • The Harpoon traffic generator for testbeds:
      J. Sommers and P. Barford, Self-Configuring Network Traffic Generation, IMC 2004.
      Harpoon is an application-independent tool for generating representative packet traffic at the IP flow level. Harpoon can also self-configure from Netflow logs. December 2005.

    • The Surge traffic generator for testbeds:
      Paul Barford and Mark Crovella. Generating Representative Web Workloads for Network and Server Performance Evaluation. In Proceedings of the ACM SIGMETRICS, pages 151-160, Madison WI, November 1998. ACM.

    • RAMP:
      Kun-chan Lan and John Heidemann, Rapid Model Parameterization from Traffic Measurements, ISI-RF-561, August 2002.
      "We describe approaches and tools that support rapid parameterization of traffic models from live network measurements."

    • IPB:
      B. Mah, P. Sholander, L. Martinez, and L. Tolendino. IPB; an Internet Protocol Benchmark using Simulated Traffic. Proceedings of MASCOTS '98, Montreal, Canada, August 1998. IEEE.
      "We have developed an IP Benchmark (IPB), which uses synthetic, simulated traffic to measure the peformance across an IP network or internetwork."

    • The trafgen traffic generator:
      Rigoberto Chinchilla, John Hoag, David Koonce, Hans Kruse, Shawn Ostermann, and Yufei Wang, Characterization of Internet Traffic and User Classification: Foundations for the Next Generation of Network Emulation, Proceedings of the 10th International Conference on Telecommunication Systems, Modeling and Analysis (ICTSM10), 2002.
      "Currently, we model traffic based on applications, such as a web browser or a file transfer application. In the present upgrade, we are modeling the way users utilize multiple applications."

    • Web servers:
      Benchmarking of Web-Server Systems:
      Michele Colajanni, Mauro Andreolini, and Valeria Cardellini, Benchmarking of Locally and Geographically Distributed Web-Server Systems, Half-day tutorial at 12th International World Wide Web Conference (WWW2003), Budapest, Hungary, May 20th, 2003.

    • GenSyn is a Java-based, traffic generator generating TCP connections and UDP streams. From 2000.

    • httperf "provides a flexible facility for generating various HTTP workloads and for measuring server performance." From 1998.

    • Modeling Peer-to-Peer Traffic.

    • Modeling Traffic from Online Games.

    • Modeling DDoS Attacks.

    • Methodologies:
      • M. Yuksel, B. Sikdar, K. S. Vastola, and B. Szymanski. Workload Generation for NS Simulations of Wide Area Networks and the Internet. Proceedings of Communication Networks and Distributed Systems Modeling and Simulation Conference (CNDS) part of Western Multi-Conference (WMC), pages 93-98, San Diego, CA, 2000.
        "We introduce methodologies for implementing realistic workload generators for wide area networks which (1) maintain the proper composition of the aggregate traffic resulting from the mix of various applications supported by the network and (2) are capable of generating long range dependent or self-similar traffic."

      • F. Hernandez Campos, K. Jeffay, F.D. Smith, S. Marron, and A. Nobel, Methodology For Developing Empirical Models of TCP-Based Applications, 2001.
        "We report on a large-scale empirical study to create application-level models for TCP traffic generation in simulations and network test-beds."

      • F. Hernandez-Campos, K. Jeffay, and F. Donelson Smith, Tracking the Evolution of Web Traffic: 1995-2003, MASCOTS 2003.
        "These results demonstrate that usage of the web by both consumers and content providers has evolved significantly and make a compelling case for continual monitoring of web traffic and updating of models of web traffic."

    • Why Traffic Models Matter:
      Y. Joo, V. Ribeiro, A. Feldmann, A. C. Gilbert, and W. Willinger, TCP/IP Traffic Dynamics and Network Performance: A Lesson in Workload Modeling, Flow Control, and Trace-driven Simulations. CCR, April 2001.
      "The main objective of this paper is to demonstrate in the context of a simple TCP/IP-based network that depending on the underlying assumptions about the inherent nature of the dynamics of network traffic, very different conclusions can be derived for a number of well-studied and apparently well-understood problems in the area of performance evaluation. For example, a traffic workload can either completely ignore the empirically observed high variability at the TCP connection level (i.e., assume "infinite sources") or explicitly account for it with the help of heavy-tailed distributions for TCP connection sizes or durations."

    • Usage Patterns in Wireless Networks:

    • Packet replay engines include TCPivo and tcpreplay.

    • Commercial traffic generators:

    • Trace libraries:
      • Crawdad, an archive for wireless data.

    Thanks to Senthilkumar Ayyasamy for contributions to this page. Proposed additions to this page can be sent to Sally Floyd.
    This material is based upon work supported by the National Science Foundation under Grant No. 0230921. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.
    Last modified: February 2008
    Posted by 배트
    ,
    출처 : http://alones.byus.net/moniwiki/wiki.php/c_cpp_windows_tip_excel?action=show

    목차

    1 Excel Automation without MFC
    2 CAloExcelAuto.h
    3 CAloExcelAuto.cpp
    4 Example code
    5 Binary
    5.1 source code
    5.2 chm file
    6 References


     

    1 Excel Automation without MFC #

    MFC에서 MS Office의 excel을 이용해서 자동 생성된 코드로 엑셀 (excel)을 자동화 (ole autoamtion) 하는 방법을 정리 하고 이 것을 class로 만들어 보았습니다.
    즉, Win32로 엑셀을 자동화하는 클래스입니다.
    실제 자료를 찾아 보면 excel의 몇 몇 기초적인 기능들을 사용하기 위한 예제 코드를 찾기가 쉽지 않기도 해서 정리해보았습니다.
    우선 MFC를 이용하지 않고 Win32를 이용해서 엑셀을 자동화하면 다음과 같은 이점들이 있을 것입니다.

    • 원하는 것을 정확히 수행할 수 있습니다.
    • 코드가 MFC를 이용한 것 보다 작고 빠릅니다.
    • 디버깅 하기 쉽습니다.
    • 가장 큰 이유는 오피스 버전에 종속되지 않아도 되는 것입니다.
      • 실제로 이게 가장 큰 이유인 것 같습니다. Office 2003에서 MFC를 이용해서 자동화 코드를 만들었다면 하위 버전에서 동작하지 않아서 힘든 경우가 많았습니다.

    ※ VB 등으로 쉽게 엑셀을 핸들링 할 수도 있겠지만 -_-;;

    2 CAloExcelAuto.h #


    /**
     * @file        AloExcelAuto.h
     * @brief   CAloExcelAuto class 
     * @author      alones
     * @date initial version: 2007.07.22 
     */
    
    #include "ole2.h"               // OLE2 Definitions
    
    /**
     * @class CAloExcelAuto
     * @brief excel automation class
     */
    class CAloExcelAuto
    {
    private:
            bool            m_bCOMInited;   /**< check if com ini*/
            bool            m_bInit ;               /**< check if excel init */
    
            struct PROPERTIES
            {
                    IDispatch *pXlApp;              /**< Excel.exe */
                    IDispatch *pXlBooks;    /**< Ptr To MainFrame -> Can open new Workbooks */
                    IDispatch *pXlBook;     /**< A Workbook. Has more Sheets (Z-Layers) */
                    IDispatch *pXlSheet;    /**< What U see. Has X and Y*/
            } m_instance;
    
    public:
            /**
             * @brief make excel app visible or not
             * @param[in]   bVisible(bool) if true, make excel app visibile
             * @return      int     if success 1, otherwise negative number
            */
            int SetVisible(bool bVisible);
    
            /**
             * @brief open excel file 
             * @return              int     if success 1, otherwise negative number
             */
            int Open(const char* file);
    
            /**
             * @brief set active sheet to read and to write
             */
            int SetActiveSheet(int nSheet);
    
            /**
             * @brief               get cell data on current active sheet
             * @param[in]   pPos (char*)    cell position e.g. B4
             * @param[out]  pData (char*)   cell data. string
             */
            bool GetData(char* pPos, char* pData);
    
            /**
             * @brief               set cell data on current active sheet
             * @param[in]   pPos (char*)    cell position e.g. B4
             * @param[in]   pData (char*)   cell data. string
             */
            bool SetData(char* pPos, char* pData);
    
            /**
             * @brief save workbook
             */
            void Save();
    
            /**
             * @brief close workbook
             */
            void Close();
    
    protected:
            /**
             * @brief Open a new Excel Window and create a new worksheet
             */
            int Init();
    
            /**
             * @brief       check if excel init
             * @return      if excel init, return true, otherwise false
             */
            bool CheckExcelInit(){return m_bInit;};
    
            // constructor & destructor
    public:
            /**
             * @brief constructor
             */
            CAloExcelAuto();
    
            /**
             * @brief destructor
             */
            virtual ~CAloExcelAuto();
    
    };
    
    
    
    //


    3 CAloExcelAuto.cpp #


    /**
     * @file        AloExcelAuto.cpp
     * @brief   CAloExcelAuto class impl.
     * @author      alones
     * @date initial version: 2007.07.22
     */
    
    #include "AloExcelAuto.h"
    #include "stdio.h"
    #include <comdef.h>
    
    /**
     * @brief Automation helper function
     */
    HRESULT AutoWrap(int autoType, VARIANT *pvResult, IDispatch *pDisp, LPOLESTR ptName, int cArgs...)
    {
        // Begin variable-argument list...
        va_list marker;
        va_start(marker, cArgs);
    
        if(!pDisp)
            {
            MessageBox(NULL, "NULL IDispatch passed to AutoWrap()", "Error", 0x10010);
            _exit(0);
        }
    
        // Variables used...
        DISPPARAMS dp = { NULL, NULL, 0, 0 };
        DISPID dispidNamed = DISPID_PROPERTYPUT;
        DISPID dispID;
        HRESULT hr;
        char buf[200];
        char szName[200];
    
    
        // Convert down to ANSI
        WideCharToMultiByte(CP_ACP, 0, ptName, -1, szName, 256, NULL, NULL);
    
        // Get DISPID for name passed...
        hr = pDisp->GetIDsOfNames(IID_NULL, &ptName, 1, LOCALE_USER_DEFAULT, &dispID);
        if(FAILED(hr))
            {
            sprintf(buf, "IDispatch::GetIDsOfNames(\"%s\") failed w/err 0x%08lx", szName, hr);
            MessageBox(NULL, buf, "AutoWrap()", 0x10010);
            _exit(0);
            return hr;
        }
    
        // Allocate memory for arguments...
        VARIANT *pArgs = new VARIANT[cArgs+1];
        // Extract arguments...
        for(int i=0; i<cArgs; i++)
            {
            pArgs[i] = va_arg(marker, VARIANT);
        }
    
        // Build DISPPARAMS
        dp.cArgs = cArgs;
        dp.rgvarg = pArgs;
    
        // Handle special-case for property-puts!
        if(autoType & DISPATCH_PROPERTYPUT)
            {
            dp.cNamedArgs = 1;
            dp.rgdispidNamedArgs = &dispidNamed;
        }
    
        // Make the call!
        hr = pDisp->Invoke(dispID, IID_NULL, LOCALE_SYSTEM_DEFAULT, autoType, &dp, pvResult, NULL, NULL);
        if(FAILED(hr))
            {
                    sprintf(buf, "IDispatch::Invoke(\"%s\"=%08lx) failed w/err 0x%08lx",
                            szName, dispID, hr);
                    MessageBox(NULL, buf, "AutoWrap()", 0x10010);
                    switch(hr)
                    {
                    case DISP_E_BADPARAMCOUNT:
                            MessageBox(NULL, "DISP_E_BADPARAMCOUNT", "Error:", 0x10010);
                            break;
                    case DISP_E_BADVARTYPE:
                            MessageBox(NULL, "DISP_E_BADVARTYPE", "Error:", 0x10010);
                            break;
                    case DISP_E_EXCEPTION:
                            MessageBox(NULL, "DISP_E_EXCEPTION", "Error:", 0x10010);
                            break;
                    case DISP_E_MEMBERNOTFOUND:
                            MessageBox(NULL, "DISP_E_MEMBERNOTFOUND", "Error:", 0x10010);
                            break;
                    case DISP_E_NONAMEDARGS:
                            MessageBox(NULL, "DISP_E_NONAMEDARGS", "Error:", 0x10010);
                            break;
                    case DISP_E_OVERFLOW:
                            MessageBox(NULL, "DISP_E_OVERFLOW", "Error:", 0x10010);
                            break;
                    case DISP_E_PARAMNOTFOUND:
                            MessageBox(NULL, "DISP_E_PARAMNOTFOUND", "Error:", 0x10010);
                            break;
                    case DISP_E_TYPEMISMATCH:
                            MessageBox(NULL, "DISP_E_TYPEMISMATCH", "Error:", 0x10010);
                            break;
                    case DISP_E_UNKNOWNINTERFACE:
                            MessageBox(NULL, "DISP_E_UNKNOWNINTERFACE", "Error:", 0x10010);
                            break;
                    case DISP_E_UNKNOWNLCID:
                            MessageBox(NULL, "DISP_E_UNKNOWNLCID", "Error:", 0x10010);
                            break;
                    case DISP_E_PARAMNOTOPTIONAL:
                            MessageBox(NULL, "DISP_E_PARAMNOTOPTIONAL", "Error:", 0x10010);
                            break;
                    }
                    // _exit(0);
                    return hr;
            }
        // End variable-argument section...
        va_end(marker);
    
        delete [] pArgs;
    
        return hr;
    }
    
    
    /**
     * @brief constructor
     */
    CAloExcelAuto::CAloExcelAuto()
    {
            // initialize COM for this thread...
            if(CoInitialize(NULL)!=S_OK)
                    m_bCOMInited = false;
            else
                    m_bCOMInited = true;
    }
    
    /**
     * @brief destructor
     */
    CAloExcelAuto::~CAloExcelAuto()
    {
            // Uninitialized COM for this thread...
            if (m_bCOMInited)
                    CoUninitialize();
    }
    
    /**
     * @brief Open a new Excel Window and create a new worksheet
     */
    int CAloExcelAuto::Init()
    {
            // Get CLSID for our server...
       CLSID clsid;
       HRESULT hr = CLSIDFromProgID(L"Excel.Application", &clsid);
    
       if(FAILED(hr))
       {
          ::MessageBox(NULL, "CLSIDFromProgID() failed", "Error", 0x10010);
          return -1;
       }
    
       // Start server and get IDispatch...   
       hr = CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER, IID_IDispatch, (void **)&m_instance.pXlApp);
       if(FAILED(hr))
       {
          ::MessageBox(NULL, "Excel not registered properly", "Error", 0x10010);
          return -2;
       }
    
       // Get Workbooks collection
       VARIANT result;
       VariantInit(&result);
       AutoWrap(DISPATCH_PROPERTYGET, &result, m_instance.pXlApp, L"Workbooks", 0);
       m_instance.pXlBooks = result.pdispVal;
    
       m_bInit = true;
    
       return 1;
    }
    
    /**
     * @brief make excel app visible or not
     */
    int CAloExcelAuto::SetVisible(bool bVisible)
    {
            if( !CheckExcelInit() )
            {
                    ::MessageBox(NULL, "Excel is not initialzed", "Error", 0x10010);
                    return -1;
            }
    
            // Make it visible (i.e. app.visible = 1)       
            VARIANT x;
            x.vt = VT_I4;
            x.lVal = bVisible ? 1 : 0;
            HRESULT hr = AutoWrap(DISPATCH_PROPERTYPUT, NULL, m_instance.pXlApp, L"Visible", 1, x);
            if( FAILED(hr))
            {
                    return -1;
            }
    
            return 1;
    }
    
    /**
     * @brief opne excel file 
     * @param[in]   file (const char*) the full path of the excel file to open 
     * @return              int     if success 1, otherwise negative number  
     */
    int CAloExcelAuto::Open(const char* file)
    {
            if( Init() < 0)
            {
                    ::MessageBox(NULL, "Fail to init excel", "Error", 0x10010);
                    return -1;
            }
    
            if( !CheckExcelInit() )
            {
                    ::MessageBox(NULL, "Excel is not initialzed", "Error", 0x10010);
                    return -1;
            }
    
            if( file == NULL)
            {
                    ::MessageBox(NULL, "file name is null", "Error", 0x10010);
                    return -1;
            }
    
            VARIANT result;
            VariantInit(&result);
    
            _bstr_t str = file;
    
            VARIANT vaPath;
            vaPath.vt = VT_BSTR;
            vaPath.bstrVal = ::SysAllocString(str);
    
            AutoWrap(DISPATCH_METHOD, &result, m_instance.pXlBooks, L"Open", 1, vaPath);
            m_instance.pXlBook = result.pdispVal;
            SysFreeString(vaPath.bstrVal);
    
            return 1;
    }
    
    /**
     * @brief set active sheet
     */
    int CAloExcelAuto::SetActiveSheet(int nSheet)
    {
            // Get ActiveSheet object
    
    
            VARIANT result;
            VariantInit(&result);
    
            VARIANT vaSheet;
            vaSheet.vt = VT_I4;
            vaSheet.lVal = nSheet;
    
            AutoWrap(DISPATCH_PROPERTYGET, &result, m_instance.pXlApp, L"Worksheets", 1, vaSheet);
            m_instance.pXlSheet = result.pdispVal;
    
            return 1;
    
    }
    
    /**
     * @brief save workbook
     */
    void CAloExcelAuto::Save()
    {
            // Set .Saved property of workbook to 'Saved'
            //VARIANT x;
            //x.vt = VT_I4;
            //x.lVal = bAsk ? 1 : 0;
            //AutoWrap(DISPATCH_PROPERTYPUT, NULL, m_instance.pXlBook, L"Saved", 1, x);     
    
            AutoWrap(DISPATCH_METHOD, NULL, m_instance.pXlApp, L"Save", 0);
    
    }
    
    /**
     * @brief close workbook
     */
    void CAloExcelAuto::Close()
    {
            //Save();       
            // Tell Excel to quit (i.e. App.Quit)
            AutoWrap(DISPATCH_METHOD, NULL, m_instance.pXlApp, L"Quit", 0);
            m_instance.pXlSheet->Release();
            m_instance.pXlBook->Release();
            m_instance.pXlBooks->Release();
            m_instance.pXlApp->Release();
    
            // Tell Excel to quit (i.e. App.Quit)
            //AutoWrap(DISPATCH_METHOD, NULL, m_instance.pXlApp, L"Close", 0);      
    }
    
    /**
     * @brief               get cell data on current active sheet
     * @param[in]   pPos (char*)    cell position e.g. B4
     * @param[out]  pData (char*)   cell data. string
     */
    bool CAloExcelAuto::GetData(char* pPos, char* pData)
    {
            if( pPos == NULL || pData == NULL)
                    return false;
    
            // Get Range object for the Range A1:O15...
            _bstr_t str;
            str=pPos; // BSTR
            str+=":";
            str+=pPos;
    
            IDispatch *pXlRange;
            {
                    VARIANT parm;
                    parm.vt = VT_BSTR;
                    parm.bstrVal = ::SysAllocString(str);
                    VARIANT result;
                    VariantInit(&result);
                    AutoWrap(DISPATCH_PROPERTYGET, &result, m_instance.pXlSheet, L"Range", 1, parm);
                    VariantClear(&parm);
                    pXlRange = result.pdispVal;
            }
    
            VARIANT tmp;
            tmp.vt=VT_BSTR;
            AutoWrap(DISPATCH_PROPERTYGET, &tmp, pXlRange, L"Value", 0, 0);
    
            if (tmp.vt==VT_EMPTY)
            {
                    pData[0]='\0';
            }
            else
            {
                    VariantChangeType(&tmp, &tmp, VARIANT_NOUSEROVERRIDE, VT_BSTR);
                    str=tmp.bstrVal;
                    strcpy(pData, str);
            }
            // Release references...
            pXlRange->Release();
            return true;
    }
    
    /**
     * @brief               set cell data on current active sheet
     * @param[in]   pPos (char*)    cell position e.g. B4
     * @param[in]   pData (char*)   cell data. string
     */
    bool CAloExcelAuto::SetData(char* pPos, char* pData)
    {
            if( pPos == NULL || pData == NULL)
                    return false;
    
            _bstr_t str=pData;
    
            VARIANT tmp;
            tmp.vt=VT_BSTR;
            tmp.bstrVal=::SysAllocString(str);
    
            // Get Range object for the Range       
            str=pPos;
            str+=":";
            str+=pPos;
    
            IDispatch *pXlRange;
            {
                    VARIANT parm;
                    parm.vt = VT_BSTR;
                    parm.bstrVal = ::SysAllocString(str);
                    VARIANT result;
                    VariantInit(&result);
                    AutoWrap(DISPATCH_PROPERTYGET, &result, m_instance.pXlSheet, L"Range", 1, parm);
                    VariantClear(&parm);
    
                    pXlRange = result.pdispVal;
            }
    
            // Set range with our safearray...
            AutoWrap(DISPATCH_PROPERTYPUT, NULL, pXlRange, L"Value", 1, tmp);//     
    
            // Release references...
            pXlRange->Release();
    
    
            return true;
    }
    
    
    //


    4 Example code #


    #include "windows.h"
    #include "AloExcelAuto.h"
    #include <iostream>
    
    void main()
    {
            CAloExcelAuto excel;
    
    
            // 1. open an excel file
            excel.Open("C:\\source\\Test\\ExcelAutomation\\test.xls");
    
            // 2. set visible 굳이 필요하진 않습니다. 쇼용?
            excel.SetVisible(true);
    
            // 3. set active sheet. 2번 째 시트의 값을 읽고 쓰기 위해서
            excel.SetActiveSheet(2);
    
            // 4. get data C4의 값을 가져와보기
            char pData[256];
            excel.GetData("C4", pData);
            std::cout<<"data: "<<pData<<std::endl;
    
            // set data. C5에 쓰기
            memset(pData, 0x00, 256);
            strcpy( pData, "테스트");
            excel.SetData("C5", pData);
    
            // save
            excel.Save();
    
            // close
            excel.Close();
    }
    
    
    //


    5 Binary #


    5.1 source code #


    6 References #

    Posted by 배트
    ,
    1.트레이아이콘 생성을  위한 준비

    (1)트레이아이콘의 행위를 정의하기위한 사용자 정의 메시지만들기

    -사용자 정의 메시지 id 부여
        ex) #define  UM_TRAYICON WM_USER + 1

    생성방법:트레이아이콘의 메시지를 받을 윈도우에 멤버함수로 사용자정의메시지수신시 호출될 함수 정의

    -함수의 정의내용 - 트레이아이콘에 대해서 어떤 버튼을 눌렀을 때 무슨 일을 하게 할 것인가를 정의하는 것이다.

    ex)
    LONG CCTrayIconTestDlg::TrayIconMessage(WPARAM wParam,LPARAM lParam)
    {
        if(lParam == WM_LBUTTONDOWN) //트레이아이콘을 한 번클릭시
        {
            //메뉴를 로드한다.
            CMenu menu, *pMenu;
            CPoint pt;

            menu.LoadMenu(IDR_MENU1);
            pMenu = menu.GetSubMenu(0);//첫번째 주메뉴를 호출한다.
            GetCursorPos(&pt);
            pMenu->TrackPopupMenu(TPM_RIGHTALIGN,pt.x,pt.y,this); //트레이아이콘의 메뉴를 X,Y위치에 뛰운다.
        }

        //트레이 아이콘을 더블클릭했을때 윈도우가 보여지게 한다.
        if(lParam == WM_LBUTTONDBLCLK)
        {
            ShowWindow(SW_SHOW); //윈도우를 보여준다.
        }

    -메시지루프에 등록
        ON_MESSAGE(UM_TRAYICON,TrayIconMessage)

     
    (2)트레이 아이콘이 사용할 메뉴만들기

    -메인메뉴를 그대로 사용한다면 상관없지만 ,메인메뉴가 없는 프로그램이라면 리소스에서 메뉴를 만들고 각각의 메뉴에 대해서 이벤트를 생성하자.

    (3)트레이아이콘 리소스 만들기

    -트레이아이콘 리소스를 만들고 그에 대한 컨트롤 아이디값을 부여하자.
        ex)IDI_TRAY와 같이


    2.트레이아이콘 생성하기

    (1)생성위치

    -프로그램 초기화시가 적당하다.

    (2)생성방법

    NOTIFYICONDATA nid;
    nid.cbSize = sizeof(nid);
    nid.hWnd = m_hWnd;    //트레이아이콘과 통신할 윈도우 핸들
    nid.uID = IDI_TRAY;   //트레이아이콘의 리소스ID(Data측면)
    nid.uFlags = NIF_MESSAGE|NIF_ICON|NIF_TIP;
    nid.uCallbackMessage = UM_TRAYICON; //트레이아이콘의 메시지가 수신시 수신윈도우가 처리할 메시지
    nid.hIcon = AfxGetApp()->LoadIcon(IDI_TRAY);//아이콘리소스(UI측면)
    lstrcpy(nid.szTip,"트레이아이콘"); // 툴팁
    // taskBar상태영역에 아이콘 추가,삭제,수정할때 시스템에 메시지 전달
    Shell_NotifyIcon(NIM_ADD,&nid); //구조체내용으로 트레이아이콘을 등록한다.(Data측면)

    SendMessage(WM_SETICON,(WPARAM)TRUE,(LPARAM)nid.hIcon);//트레이화면에 붙이기(UI측면)

     
    3.생성후 고려사항

    (1)메시지처리

    메시지처리는 트레이아이콘과 연결된 윈도우가 수신시 TrayIconMessage가 호출되어 LPARM으로 전달된 트레이 아이콘의 행위에 따른 동작을 실시하면 된다.

     
    (2) X버튼 클릭시

    X버튼 클릭시 프로그램을 닫아버리면 트레이아이콘을 사용하는프로그램으로서의 가치가 없다.
    따라서 다음과 같이 처리하는 것이 정석이다.

    void CCTrayIconTestDlg::OnClose()
    {
        // TODO: 여기에 메시지 처리기 코드를 추가 및/또는 기본값을 호출합니다.
        ShowWindow(SW_HIDE);//트레이아이콘으로만 표시되게한다.
        //CDialog::OnClose(); //WM_CLOSE의 자동생성코드인 이 부분을 주석처리한다.
    }
     

    (3)종료처리

    -우선 트레이아이콘메뉴에 종료처리메뉴를 둔다

    -WM_DESTORY메시지처리부분은 다음과 같이 처리한다.


    void CCTrayIconTestDlg::OnDestroy()
    {
        CDialog::OnDestroy();

        //리소스 해제
        NOTIFYICONDATA nid;
        nid.cbSize = sizeof(nid);
        nid.hWnd = m_hWnd;
        nid.uID = IDR_MENU1;

        Shell_NotifyIcon(NIM_DELETE,&nid);//삭제플래그를 준다.
    }

    -종료처리메뉴 클릭시 WM_DESTORY메시지를 호출되도록 PostQuitMessage(0);을 호출한다.

    //(4)프로그램 종료후에도 트레이아이콘의 잔상이 남는 경우의 처리

    //메인의 소멸자부분에서

    //AfxGetApp()->LoadIcon(IDI_TRAY);/

    [출처] [MFC]트레이아이콘 만들기|작성자 붉은바다
    Posted by 배트
    ,
    13.4 Commands at a glance

    The following is a list of error-model related commands commonly used in simulation scripts:
    set em [new ErrorModel]
    $em unit pkt
    $em set rate_ 0.02
    $em ranvar [new RandomVariable/Uniform]
    $em drop-target [new Agent/Null]

    This is a simple example of how to create and configure an error model. The commands to place the error-model in a simple link will be shown next.

    $simplelink errormodule <args>
    This commands inserts the error-model before the queue object in simple link. However in this case the error-model’s drop-target points to the link’s drophead_ element.

    $ns_ lossmodel <em> <src> <dst>
    This command places the error-model before the queue in a simplelink defined by the <src> and <dst> nodes. This is basically a wrapper for the above method.

    $simplelink insert-linkloss <args>
    This inserts a loss-module after the queue, but right before the delay link_ element in the simple link. This is because nam can visualize a packet drop only if the packet is on the link or in the queue. The error-module’s drop-target points to the link’s drophead_ element.

    $ns_ link-lossmodel <em> <src> <dst>
    This too is a wrapper method for insert-linkloss method described above. That is this inserts the error-module right after the queue element in a simple link (src-dst).

    출처 : The ns Manual 129~130p
    Posted by 배트
    ,
    다이얼로그 기반의 투명한 윈도우는 세련되고 구현이 쉽다.
    간단한 생활 어플리케이션은 이 기능으로 예쁘게 만들 수 있다.

    1. 윈도우 스타일에 WS_EX_LAYERED를 추가

    2. 투명도 설정

    SetWindowLong(hwnd, GWL_EXSTYLE,GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
    SetLayeredWindowAttributes( 0, (255 * 30) / 100, LWA_ALPHA );

    MFC8 에서는 SetLayeredWindowAttributes가 기본으로 include, link되지만
    VC6 에선 user32.dll에서 직접 로드해야하고, 함수 기본형도 다르다.
    VC6 에서는 아래와 같이 한다.

    // 함수 선언
    BOOL SetLayeredWindowAttributes(
        HWND hwnd,           // handle to the layered window
        COLORREF crKey,      // specifies the color key
        BYTE bAlpha,         // value for the blend function
        DWORD dwFlags        // action
    );

    // 상수 선언
    #define WS_EX_LAYERED 0x00080000
    #define LWA_ALPHA     0x00000002

    // DLL에서 함수를 호출하기 위한 함수 선언
    typedef BOOL(WINAPI *SLWA)(HWND, COLORREF, BYTE, DWORD);

    // 함수포인터 선언
    SLWA pSetLayeredWindowAttributes = NULL;

    // DLL을 로드하여 함수에 대한 포인터를 가져옴
    HINSTANCE hmodUSER32 = LoadLibrary("USER32.DLL");
    pSetLayeredWindowAttributes =
    (SLWA)GetProcAddress(hmodUSER32,"SetLayeredWindowAttributes");

    HWND hwnd = this->m_hWnd; //다이얼로그의 핸들
    // 다이알로그의 스타일 변경
    SetWindowLong(hwnd, GWL_EXSTYLE,GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
    // 다이알로그의 투명도를 30%로 변경
    pSetLayeredWindowAttributes(hwnd, 0, (255 * 30) / 100, LWA_ALPHA);

    [출처] [MFC] 투명한 다이알로그 |작성자 견우


    이렇게 하면 ㅇㅋ
    Posted by 배트
    ,
    간접출처
    http://overegoz.tistory.com/669

    References

    [1] http://4ellene.net/tt/1075


    This revised trace support is backwards compatible with the old trace formatting and can be enabled by the following command:


    $ns use-newtrace


    This command should be called before the universal trace command $ns trace-all trace-fd. Primitive use-newtrace sets up new format for wireless tracing by setting a simulator variable called newTraceFormat. Currently this new trace support is available for wireless simulations only and shall be extended to rest of in the near future.




    Event type : 이벤트

    In the traces above, the first field (as in the older trace format) describes the type of event taking place at the node and can be one of the four types:

    S : send / r : receive / d : drop / f : forward


    General tag

    The second field starting with "-t" may stand for time or global setting

    -t : time / -t : * (global setting)


    Node property tags

    This field denotes the node properties like node-id, the level at which tracing is being done like agent, router or MAC. The tags start with a leading "-N" and are listed as below:

    -Ni: node id

    -Nx: node's x-coordinate

    -Ny: node's y-coordinate

    -Nz: node's z-coordinate

    -Ne: node energy level

    -Nl: trace level, such as AGT, RTR, MAC

    -Nw: reason for the event. The different reasons for dropping a packet are given below:

    "END" DROP_END_OF_SIMULATION

    "COL" DROP_MAC_COLLISION

    "DUP" DROP_MAC_DUPLICATE

    "ERR" DROP_MAC_PACKET_ERROR

    "RET" DROP_MAC_RETRY_COUNT_EXCEEDED

    "STA" DROP_MAC_INVALID_STATE

    "BSY" DROP_MAC_BUSY

    "NRTE" DROP_RTR_NO_ROUTE i.e no route is available.

    "LOOP" DROP_RTR_ROUTE_LOOP i.e there is a routing loop

    "TTL" DROP_RTR_TTL i.e TTL has reached zero.

    "TOUT" DROP_RTR_QTIMEOUT i.e packet has expired.

    "CBK" DROP_RTR_MAC_CALLBACK

    "IFQ" DROP_IFQ_QFULL i.e no buffer space in IFQ.

    "ARP" DROP_IFQ_ARP_FULL i.e dropped by ARP

    "OUT" DROP_OUTSIDE_SUBNET i.e dropped by base stations on receiving routing updates from nodes outside its domain.

    Packet information at IP level

    The tags for this field start with a leading "-I" and are listed along with their explanations as following:

    -Is: source address.source port number

    -Id: dest address.dest port number

    -It: packet type

    -Il: packet size

    -If: flow id

    -Ii: unique id

    -Iv: ttl value

    Next hop info

    This field provides next hop info and the tag starts with a leading "-H".

    -Hs: id for this node

    -Hd: id for next hop towards the destination.

    Packet info at MAC level

    This field gives MAC layer information and starts with a leading "-M" as shown below:

    -Ma: duration

    -Md: dst's ethernet address

    -Ms: src's ethernet address

    -Mt: ethernet type

    Packet info at "Application level"

    The packet information at application level consists of the type of application like ARP, TCP, the type of adhoc routing protocol like DSDV, DSR, AODV etc being traced. This field consists of a leading "-P" and list of tags for different application is listed as below:

    -P arp

    Address Resolution Protocol. Details for ARP is given by the following tags:

    -Po: ARP Request/Reply

    -Pm: src mac address

    -Ps: src address

    -Pa: dst mac address

    -Pd: dst address

    -P dsr

    This denotes the adhoc routing protocol called Dynamic source routing. Information on DSR is represented by the following tags:

    -Pn: how many nodes traversed

    -Pq: routing request flag

    -Pi: route request sequence number

    -Pp: routing reply flag

    -Pl: reply length

    -Pe: src of srcrouting->dst of the source routing

    -Pw: error report flag ?

    -Pm: number of errors

    -Pc: report to whom

    -Pb: link error from linka->linkb

    -P cbr

    Constant bit rate. Information about the CBR application is represented by the following tags:

    -Pi: sequence number

    -Pf: how many times this pkt was forwarded

    -Po: optimal number of forwards

    -P tcp

    Information about TCP flow is given by the following subtags:

    -Ps: seq number

    -Pa: ack number

    -Pf: how many times this pkt was forwarded

    -Po: optimal number of forwards

    This field is still under development and new tags shall be added for other applications as they get included along the way.


    s -t 0.267662078 -Hs 0 -Hd -1 -Ni 0 -Nx 5.00 -Ny 2.00 -Nz 0.00 –Ne -1.000000 -Nl RTR -Nw --- -Ma 0 -Md 0 -Ms 0 -Mt 0 –Ii 20 -Is 0.255 -Id -1.255 –It


    -S : 이벤트 ex) sent

    -t 0.267662078 : 시간

    -Hs 0 : 소스 노드(Hs) 0 에서

    -Hd -1 : 목적지 노드(Hd) 1

    -Ni 0 : 소스 노드 ID 는 0

    -Nx 5.00 : x-co-ordinate는 5.00

    -Ny 2.00 : s y-co-ordinate 은 2.00

    -Nz 0.00 : z-co-ordinate은 0.00

    –Ne -1.000000 : 에너지 레벨은 1.000000

    -Nl RTR : 트레이스 레벨은 RTR

    -Nw --- : 노드 이벤트는 없음

    -Ma 0 : The MAC level information is given by duration (Ma) 0

    -Md 0 : 목적지 이더넷 주소 (Md)0

    -Ms 0 : 발신지 이더넷 주소(Ms)0

    -Mt 0 : 이더넷 종류 0

    –Ii 20 : The IP packet level information like packet id (Ii)

    -Is 0.255 : 발신자 주소.발신자 포트번호

    -Id -1.255 : 목적지 주소.목적지 포트번호

    –It

    Here, we see that a packet was sent (s) at time (t) 0.267662078 sec, 
    from source node (Hs) 0 to destination node (Hd) 1.
    The source node id (Ni) is 0, it's x-co-ordinate (Nx) is 5.00,
    it's y-co-ordinate (Ny) is 2.00, it's z-co-ordinate (Nz) is 0.00,
    it's energy level (Ne) is 1.000000, the trace level (Nl) is
    RTR and the node event (Nw) is blank. The MAC level information is
    given by duration (Ma) 0, destination Ethernet address (Md) 0,
    the source Ethernet address (Ms) is 0 and Ethernet type (Mt) is 0.
    The  IP packet level information like packet id (Ii), 
    source address.source port number is given by (Is) while the destination address.
    destination port number is (Id).
    Posted by 배트
    ,