Questions tagged [raw-sockets]

An internet socket that allows direct sending and receiving of raw network packets that contain all headers. They differ from protocols like TCP/IP or UDP.

Raw sockets differ from standard sockets where the payload is encapsulated according to the transport layer protocol (TCP, UDP, HTTP, ..). Raw sockets can be used to implement completely new transport-layer protocols or to send messages through some less common protocol like ICMP.

Most socket APIs, especially those based on Berkeley sockets, support raw sockets. Support under Windows XP is intentionally limited due security concerns.

490 questions
6
votes
0 answers

Frontend raw TCP/UDP sockets in a browser, any way at all in 2021?

I've seen many questions about using raw TCP/UDP sockets in web browsers using JavaScript/Html5 however they are all old like this one posted 5 years ago. It is now 2021 and I'm wondering if there is any possibility at all to avoid using WebSockets…
NaturalBornCamper
  • 3,675
  • 5
  • 39
  • 58
6
votes
1 answer

How to flush raw AF_PACKET socket to get correct filtered packets

sock = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); setsockopt(sock, SOL_SOCKET, SO_ATTACH_FILTER, &f, sizeof (f)) With this simple BPF/LPF attach code, when I try to receive packet on the socket, will get some wrong packets that doesn't match…
Rider
  • 63
  • 2
6
votes
0 answers

PACKET_MMAP TX_RING Issues on subsequent send() calls

Thanks for taking the time to look at this. It's an issue I've been dealing with for a week or so now, and I'm dumbfounded. Any input would be great. I am currently using PACKET_MMAP TX_RING V3 (I've tried V2 and V1, but I have the same problem with…
Dauie
  • 86
  • 5
6
votes
1 answer

MacOS SO_REUSEADDR/SO_REUSEPORT not consistent with Linux?

Consider this code: #include #include #include #include #include #include #include #include #define SERVADDR "::1" #define PORT 12345 int main() { …
lukash
  • 725
  • 6
  • 19
6
votes
3 answers

Writing a basic traceroute script in C

I have to write a trceroute script but I'm not sure if my attempts are correct. Right now I'm doing it like that (please correct me if I'm doing wrong or clumsy): Got an struct for ip- and udpheader A checksum function Opening 2 sockets: One for…
d.hill
  • 669
  • 3
  • 9
  • 16
6
votes
3 answers

Low level networking in assembler (x86 compatible)

I wish to write a bootable program in assembler that would be capable of sending and receiving network packets. I do not wish to use any libraries, I'd like to create it all by myself (and also learn while doing so). Unfortunately, I was unable to…
Neo_b
  • 231
  • 5
  • 9
6
votes
2 answers

Capturing performance with pcap vs raw socket

When capturing network traffic for debugging, there seem to be two common approaches: Use a raw socket. Use libpcap. Performance-wise, is there much difference between these two approaches? libpcap seems a nice compatible way to listen to a real…
PeterM
  • 2,534
  • 6
  • 31
  • 38
6
votes
0 answers

TCP socket and Web Socket on playframework server?

My service already uses Websockets to communicate with an HTML5 in-browser client. The client is served by the same server from a normal http request. Now I would like to offer the same service/app but out of the browser, and I would like to offer…
le-doude
  • 3,345
  • 2
  • 25
  • 55
5
votes
2 answers

Raw Socket Help: Why UDP packets created by raw sockets are not being received by kernel UDP?

I am studying raw sockets. I used the IP_HDRINCL option to build my own IP headers. After the IP header, I am building a UDP header. Then I am sending the packet to my system's loopback address. I have another program running which will catch the…
pflz
  • 1,891
  • 4
  • 26
  • 32
5
votes
2 answers

How to bind a Raw Socket to a specific port?

I am currently working on a programming assignment. The assignment is to implement a client,network emulator, and server. The client passes packets to a network emulator, and the network emulator passes to the server. Vice-versa applies as well. The…
user614885
  • 141
  • 2
  • 2
  • 9
5
votes
2 answers

how to embed C code in python program?

i want to write a program using multi-threading, raw sockets, to scan the ports in python i have a C code for injection of raw socket. i want to perform a ACK scan so need a raw socket. So please help me. thank you
AJINKYA
  • 741
  • 2
  • 9
  • 20
5
votes
0 answers

How to add a new custom layer 4 protocol (a new Raw socket) in linux kernel?

i am trying adding my own customized layer 4 protocol in linux (ubuntu 14.04) - IPPROTO_MYPROTO as a loadable kernel module. I have done all necessary steps to register the protocol. Here i am sharing my code. When i am trying to send a mesage from…
Abhishek Sagar
  • 1,189
  • 4
  • 20
  • 44
5
votes
3 answers

C++ TCP socket sending speed

I'm sending messages to remote server using simple locking TCP socket and the problem I have is that for each message it takes very different time to send it. And here what I get (some example): Bytes Sent: 217, Time: 34.3336 usec Bytes Sent: …
Artem
  • 91
  • 1
  • 4
5
votes
2 answers

How to send modified IPv6 packet through RAW socket?

I'm trying to send a custom IPv6 header through a RAW socket in C Linux. I already succeded in IPv4 using the IP_HDRINCL socket option, however, there's not an equivalent for IPv6. I found a workaround here suggesting to use socket(AF_INET6,…
Pepedou
  • 787
  • 1
  • 13
  • 35
5
votes
1 answer

reading Ethernet data packet from raw sockets using recvfrom() in MSG_DONTWAIT mode

I am using raw sockets to send and receive Ethernet data packets in C using recvFrom(). I want to read in non blocking mode so I am using MSG_DONTWAIT. But the recvFrom() is always returning -1 even if packet is received or not. I am new to C…
Tejzeratul
  • 343
  • 6
  • 15
1 2
3
32 33