libpcap으로 PPP 패킷을 스니핑하는 방법은 무엇입니까? (How to sniff PPP packet with libpcap?)


문제 설명

libpcap으로 PPP 패킷을 스니핑하는 방법은 무엇입니까? (How to sniff PPP packet with libpcap?)

eth0 인터페이스에서 패킷을 캡처하고 다음과 같이 ip 패킷을 스니핑할 수 있습니다.

/* IP header */
struct sniff_ip {
    u_char  ip_vhl;                 /* version << 4 | header length >> 2 */
    u_char  ip_tos;                 /* type of service */
    u_short ip_len;                 /* total length */
    u_short ip_id;                  /* identification */
    u_short ip_off;                 /* fragment offset field */
    #define IP_RF 0x8000            /* reserved fragment flag */
    #define IP_DF 0x4000            /* dont fragment flag */
    #define IP_MF 0x2000            /* more fragments flag */
    #define IP_OFFMASK 0x1fff       /* mask for fragmenting bits */
    u_char  ip_ttl;                 /* time to live */
    u_char  ip_p;                   /* protocol */
    u_short ip_sum;                 /* checksum */
    struct  in_addr ip_src,ip_dst;  /* source and dest address */
};

그래서 PPP 인터페이스에서 패킷을 캡처해야 하는 경우 헤더 구조를 정의하는 방법은 무엇입니까?

이 경우 헤더의 길이가 32바이트라는 것을 알았습니다.


참조 솔루션

방법 1:

If, when you capture on the PPP device with libpcap, the pcap_datalink() routine returns DLT_PPP, then you define the header in the fashion indicated by the entry for LINKTYPE_PPP/DLT_PPP in the tcpdump.org link‑layer header types page:

PPP, as per RFC 1661 and RFC 1662; if the first 2 bytes are 0xff and 0x03, it's PPP in HDLC‑like framing, with the PPP header following those two bytes, otherwise it's PPP without framing, and the packet begins with the PPP header.

(by whyuser862787)

참조 문서

  1. How to sniff PPP packet with libpcap? (CC BY‑SA 2.5/3.0/4.0)

#capture #networking #linux #C






관련 질문

Java 제네릭: 캡처를 사용한 컴파일 실패 (Java generics: compilation failure using captures)

Python 함수 호출에서 stdout 출력을 캡처하는 방법은 무엇입니까? (How to capture stdout output from a Python function call?)

캡처한 이미지 캡처 및 공유를 구현하고 싶습니다. (I want to implement capture and sharing captured image)

Ambilight용 Python 화면 캡처(더 적은 리소스 집약적) (Python Screen Capture for Ambilight (less resource intensive))

Windows에서 "비디오 컨트롤러"에 대한 Java 액세스 (Java Access To "Video Controller" In Windows)

libpcap으로 PPP 패킷을 스니핑하는 방법은 무엇입니까? (How to sniff PPP packet with libpcap?)

DVB-T 스틱에서 AVI 파일로 캡처하는 방법 (How to capture from a DVB-T Stick to an AVI-File)

xlib를 사용하여 키 누름 이벤트 캡처 (capture key press event using xlib)

앱에서 HTTPS 트래픽을 캡처하고 싶지만 작동하지 않습니다. (I want to Capture HTTPS Traffic from app but it does not work)

Selenium-wire Python을 사용하여 네트워크 트래픽을 캡처하는 동안 다른 형식의 로그 보기 (Seeing logs in a different format while capturing network traffic using selenium-wire python)

Android 애플리케이션의 특정 프레임 내 자동 촬영 기능 (Auto picturing feature within specific frame in Android application)

안드로이드 스튜디오 캡처 이미지 더 빠르게 (android studio capture image faster)







코멘트