0
pcap을 사용하여 패킷 스니퍼를 만듭니다.스니핑 된 패킷의 인쇄 순서 번호
가 가typedef struct TSP_header{
unsigned short int sport;
unsigned short int dport;
unsigned int seqnum;
unsigned int acknum;
unsigned char reserved:4, offset:4;
unsigned int
tcp_res1:4, //little-endian
tcph_hlen:4, //length of tcp header in 32-bit words
tcph_fin:1, //Finish flag "fin"
tcph_syn:1, //Synchronize sequence numbers to start a connection
tcph_rst:1, //Reset flag
tcph_psh:1, //Push, sends data to the application
tcph_ack:1, //acknowledge
tcph_urg:1, //urgent pointer
tcph_res2:2;
unsigned short int tcph_win;
unsigned short int tcph_chksum;
unsigned short int tcph_urgptr;
}TSP_header;
가
은 내가 어떻게 일련 번호를 인쇄 할 수 있습니다 :
내가이 TCP 구조를 가지고?
htons (sequence_number)를 사용해야합니까 ?? 이 방법으로 작동하지 않기 때문에 !!
내 다른 질문은 변수 선언 다음에 오는 숫자는 무엇입니까?
4는 tcph_hlen에서 4를 의미합니다. 4
ntohl()은 음수 시퀀스와 확인 번호를 제공하기 때문에 작동하지 않는다고 생각합니다. – scatman
ntohl은 * unsigned * 정수를 매개 변수로 사용하고 결과적으로 * 부호없는 정수를 생성합니다. 따라서, ntohl의 결과를 * signed * int로 넣는 큰 실수를하지 않았다면, 음수는 발생할 수 없습니다. 코드를 보여주십시오. – bortzmeyer
나는 유용한 조언을 해준다 : 문서를 읽는다. 'man 3 printf'는 "d, i int 인수가 부호있는 10 진수 표기법으로 변환됩니다."라고 알려줍니다. 나는 서명되지 않은 자에게 필요한 것을 너 자신에게 보게한다. – bortzmeyer