pcap_sendpacket 함수 시간 측정값이 왜 들쭉날쭉할까요. ;; ㅠ

imleemin의 이미지

네이버 카페에도 질문을 했었는데..;
여기에도 적게 되네요. 흐흐;;

페도라 리눅스 11를 사용하고 있고,

kernel 은 2.6.31.12 리얼타임 패치를 적용하였습니다. (config_preemt_rt)

현재 네트워크에서 패킷 전송에 관련된 시간을 측정하는 프로젝트를 하고 있는데,

지금은 단순히 패킷을 전송하는 함수의 시간을 측정하고 있습니다. ;

측정할 때 clock_gettime() 함수를 사용하고 있고,

패킷 전송 함수로 libpcap의 pcap_sendpacket() 함수를 쓰고 있습니다.

스케줄링은 SCHED_RR을 사용하고 Priority는 49를 주었습니다.

측정시 단순히 loop을 돌면서 시간을 측정하게 되는데요,

코드는 아래와 같습니다.


for(i=0; i<30; i++){
 
    clock_gettime(CLOCK_MONOTONIC, &inter_time[i]);
 
 
 
    temp = pcap_sendpacket(adhanle, sendbuf, 60);
 
    if(temp != 0){
         printf("sending error\n");
         exit(-1);
    }
 
    clock_gettime(CLOCK_MONOTONIC, &inter_time2[i]);
 
}
 
for(i=0; i<30; i++)
   printf(" %d sending time : %09d\n", i, inter_time2[i].tv_nsec-inter_time[i].tv_nsec);
 
 

이렇게 측정을 하고 있는데, 측정값이 좀 이상하게 나오네요;

전 그래도 일정하게 나올 거라고 생각하고 있었는데, 차이가 좀 심하게 나는 경우도 있어서..

원인이 뭔지 모르겠습니다. ;;

아래는 결과 값들 중 하나입니다.

[0] sending time : 000031698

[1] sending time : 000004844

[2] sending time : 000031213

[3] sending time : 000004228

[4] sending time : 000017681

[5] sending time : 000004382

[6] sending time : 000017310

[7] sending time : 000004243

[8] sending time : 000017145

[9] sending time : 000003946

[10] sending time : 000016142

[11] sending time : 000004757

[12] sending time : 000017186

[13] sending time : 000003807

[14] sending time : 000016660

[15] sending time : 000004683

[16] sending time : 000017088

[17] sending time : 000003849
[18] sending time : 000016180

[19] sending time : 000004852

[20] sending time : 000017040

[21] sending time : 000003868

[22] sending time : 000016341

[23] sending time : 000004671

[24] sending time : 000016927

[25] sending time : 000026348

[26] sending time : 000003931

[27] sending time : 000016431

[28] sending time : 000004889

[29] sending time : 000017726

측정 값은 나노세컨드 단위로 표시가 되어 있구요..

보시면 아시겠지만, 값이 들쭉날쭉합니다. ;;

마이크로 세컨드 단위로 보자면,

3에서 5미만의 값이 나왔다가 16~31 마이크로 로 껑충 뛰는데요..

특히 첫 번째 호출할 때 항상 값이 가장 크게 나오네요;;

내부적으로 버퍼할당하고 해제 하는 문제 때문일까요;

도통 이유를 모르겠습니다. ㅠㅠ

혹시 왜 이런지 아시겠어요?;;;;

커널 디버깅을 해봐야만 될까요.. ;;

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.