Linux API/network2019. 7. 3. 13:30

음.. 두개는 연관이 없는 건가? 헷갈림

 

raw socket

sd = socket(PF_INET, SOCK_RAW, IPPROTO_UDP);

[링크 : https://www.tenouk.com/Module43a.html]

[링크 : http://naver.pages.kr/140042345641]

 

#define IPPROTO_TCP 6

#define IPPROTO_UDP 17

[링크 : https://unix.superglobalmegacorp.com/BSD4.4/newsrc/netinet/in.h.html]

 

promiscous mode

s = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL))

[링크 : https://sangchul.kr/530]

[링크 : https://stackoverflow.com/questions/114804/reading-from-a-promiscuous-network-device]

 

#define ETH_P_ALL 0x0003 /* Every packet (be careful!!!) */

[링크 : https://github.com/spotify/linux/blob/master/include/linux/if_ether.h]

 

 

PF_*, AF_* 차이(없다)

[링크 : http://blog.naver.com/PostView.nhn?blogId=l18400&logNo=60109296392]

 

AF_INET is used, if you want to communicate using Internet protocols: TCP or UDP.

AF_PACKET is used if you want to play with packets at the protocol level, i.e. you are implementing your own protocol. Only processes with effective UID 0 [root] or the capability CAP_NET_RAW may open packet sockets.

[링크 : https://www.quora.com/Whats-the-difference-between-the-AF_PACKET-and-AF_INET-in-python-socket]

'Linux API > network' 카테고리의 다른 글

TCP timeout  (0) 2020.09.29
UDS (Unix Domain Socket)  (0) 2020.09.01
리눅스 UDP 소켓  (0) 2019.05.24
리눅스 TCP 소켓  (0) 2019.05.24
linux udp cpp example  (0) 2019.05.16
Posted by 구차니