ping 소스에서..

psjcap의 이미지

ping 소스를 보니.. icmp 헤더에 id에 자기 자신의 process id를 넣더군요..
그리고 recvfrom 할 때 id가 자기자신거랑 다르면 그냥 버리던데요..

만약 두 프로세스에서 ping을 쏠 경우..
내가 보낸 ping에 reply가 다른 프로세스로 가 버려서..
내가 못 받는 경우가 생길 수 있나요..??

ping 프로그램을 여러개 띄워놓아도 그런 경우는 생기지 않는거 같은데..

그럼 한수 부탁드립니다..

jyj9782의 이미지

로우소켓으로 받거든요, 로우소켓으로 받는다는것은 두 프로세스이상에서 똑같이 받아들인다는거에요..

즉.. icmp 패킷을 받아 출력하게 한 간단한 소스로요..

두개를 각각 터미날에 켜두죠..

그리고 핑을 날렸을때..

아래와 같은 결과를 얻게됩니다.

프로세스 1
root@testbed:~/socket# ./icmp
ICMP TYPE=8 CODE=0 CHECKSUM=23626
ICMP TYPE=8 CODE=0 CHECKSUM=23625
ICMP TYPE=8 CODE=0 CHECKSUM=23624
ICMP TYPE=8 CODE=0 CHECKSUM=23623

프로세스 2
root@testbed:~/socket# ./icmp
ICMP TYPE=8 CODE=0 CHECKSUM=23626
ICMP TYPE=8 CODE=0 CHECKSUM=23625
ICMP TYPE=8 CODE=0 CHECKSUM=23624
ICMP TYPE=8 CODE=0 CHECKSUM=23623

로우소켓이기 때문에, 각각의 프로세스는 동일한
데이타를 받게 되고, 한쪽의 ping 에서..

id 필드와 프로세스 id 가 다르다면, 즉..
자신(핑)이 보낸 패킷이 아니라면, 무시하는겁니다.

무시한다는건 return; 으로 처리했던데요.

즉 더이상 안받는다는 뜻입니다.

그럼 다른 프로세스도 동일한 데이타를 받을테고..

한쪽에서만 받는다는.. 1:1 연결과는 다르죠..

그래서 드랍되는게 아니라.. 동시에 둘다 받는겁니다..

:=)

힘내세요.

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.