2013-10-23 1 views

답변

-3

나는 그렇게 위의 점과 개발/업데이트 도구를 조사 하였다. Obj C/C에서 그렇게해야합니다.
+2

요점은 중요하지 않지만 내 답변을 받아들이지 않고 받아들이는 것은 꽤 어렵습니다. 개발 된/업데이트 된 도구가 내 도구의 직접적인 찢김이라고 생각하면됩니다. Bravo는 오픈 소스의 힘을 발휘합니다. 너 같은 사람들은 내 소식통을 공개하고 싶지 않아. – Technologeeks

8

매우 쉽지만 간단합니다 : 문서화되지 않은 "com.apple.network.statistics"에 시스템 소켓 (PF_SYSTEM)을 등록하면 프로세스 통계를 얻을 수 있습니다. 소켓이 시작되기 전까지 얼마나 많은 rx/tx가 있었는지 모를 것입니다.

사용자 모드 헤더가 없지만 해당 사이트에서 lsock.h를 사용하거나 xnu의 소스 (q.v. xnu-2422.1.72/bsd/net/ntstat.h)에서 정의를 추출 할 수 있습니다. 관련 부분은 다음과 같습니다이 거의 유일한 프로그램 API 수출 그래서

,NSTAT_MSG_TYPE_SRC_COUNTS    = 10004 
    typedef struct nstat_counts 
    { 
      /* Counters */ 
      u_int64_t  nstat_rxpackets __attribute__((aligned(8))); 
      u_int64_t  nstat_rxbytes __attribute__((aligned(8))); 
      u_int64_t  nstat_txpackets __attribute__((aligned(8))); 
      u_int64_t  nstat_txbytes __attribute__((aligned(8))); 

      u_int32_t  nstat_rxduplicatebytes; 
      u_int32_t  nstat_rxoutoforderbytes; 
      u_int32_t  nstat_txretransmit; 

      u_int32_t  nstat_connectattempts; 
      u_int32_t  nstat_connectsuccesses; 

      u_int32_t  nstat_min_rtt; 
      u_int32_t  nstat_avg_rtt; 
      u_int32_t  nstat_var_rtt; 
    } nstat_counts; 

typedef struct nstat_msg_src_counts 
{ 
     nstat_msg_hdr   hdr; 
     nstat_src_ref_t   srcref; 
     nstat_counts   counts; 
} nstat_msg_src_counts 

이, 덧붙여 말하자면, 또한 액티비티 모니터는 "네트워크"보기에서 10.9으로 그렇게하는 방법입니다. 이 사이트의 "프로세스 탐색기"도구는 동일한 방식으로 프로세스 별 통계도 제공합니다. https://github.com/sotrosh/lsock

+0

답변 해 주셔서 감사합니다. 거기에 코드 예제가 있습니까? – Sergio

관련 문제