ethernet(arp) 패킷 전송 관련 질문입니다!

espoirnoa09의 이미지

안녕하세요!

개발 환경은 칼리 리눅스이며, 제가 이더넷(arp) 패킷을 전송하고싶습니다.

제가 구현한 방법으로는

제가 보낼 packet에 해당하는 배열(u_int8_t packet[])을 그대로 전송 하고싶습니다.

이 패킷안에는 dest mac src mac 등 모든 패킷의 구성에 맞게 데이터가 저장되어 있는상태인데

이 패킷을 네트워크로 흘려보내기만 하면 되는데 어떻게 해야할 지 몰라 질문드립니다!

제가 생각한 방법으로는 send()함수를 이용하여 네트워크 패킷을 흘려 보내는 방법인데,

send함수를 쓰기위해선 socket()함수를 이용하여 디스크립터를 할당 받아야 합니다.

그곳의 인자중 domain에 해당하는 부분에 이더넷 패킷(arp)을 지칭하는 address family가 없는 것 같아 질문 드립니다!

위의 내용 중 제가 잘못생각한 것이 있다면 어떤 것인지, domain에 arp를 지칭하는 이름이 무엇인지가 궁금합니다!

espoirnoa09의 이미지

sendto를 사용하려고 했으나 invalid argument 가 나오는데 어떻게 해야할까요??

int packetLen = sizeof(struct ether_header)+sizeof(ether_arp);

소켓은 int sock=socket(PF_PACKET,SOCK_RAW,htons(ETH_P_ARP));

struct sockaddr_ll dest;

memset(&dest,0,sizeof(dest));
dest.sll_family=htons(PF_PACKET);
dest.sll_protocol=htons(ETH_P_ARP);
dest.sll_halen=packetLen;
dest.sll_ifindex=htonl(if_nametoindex(device));
memcpy(dest.sll_addr,sender_Mac,6);

f(sendto(sock,arpReply,packetLen,0,(struct sockaddr*)&dest,sizeof(sockaddr))==-1)
cout<

이때 argument 오류가 납니다. arpReply는 실제 보낼 패킷의 내용이 들어가있고 구성은 ether_header + arp 로 되어있습니다.

arpReply는 packetlen길이의 u_int8_t입니다.

실제 각 구조체에서 arpReply배열로의 값 저장은

memcpy(arpReply,&ep,sizeof(struct ether_header));
memcpy(&arpReply[sizeof(struct ether_header)],&arp,sizeof(struct ether_arp));

이와같이 메모리 복사를 이용하였고 값에대한 출력결과는 실제 제가 보내야하는 패킷의 구성과 일치하였습니다.

이때 어떤 오류때문에 sendto의 명령어가 실패하는지 잘 모르겠습니다.

espoirnoa09의 이미지

개발환경은 칼리리눅스이며, 64비트 운영체제 입니다.

보내고자 하는 패킷은 ARP reply에 대한 패킷입니다.

댓글 달기

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