| Post Reply | RetroFed Forums Forum Index » C Programming Language |
| Author | Message | ||
|---|---|---|---|
|
sacred_font
infosec.pub
sacred_font@infosec.pub Joined: 2026-02-23 |
|
||
| 9 Original | |||
Dave.
aussie.zone
dgriffith@aussie.zoneJoined: 2023-09-27 |
Been a while since I've done this kind of thing, but you should be able to create a pool of sockets primed with the first batch of IP addresses, then send the packets. On reply or timeout, you don't destroy the socket and create a new one. Instead you alter the connection information in the socket descriptor in the existing socket to point to the next address to check, and then go again. |
||
| 5 | |||
|
sacred_font
infosec.pub
sacred_font@infosec.pub Joined: 2026-02-23 |
Been a while since I've done this kind of thing, but you should be able to create a pool of sockets primed with the first batch of IP addresses, then send the packets. On reply or timeout, you don't destroy the socket and create a new one. Instead you alter the connection information in the socket descriptor in the existing socket to point to the next address to check, and then go again.
Thank you can’t believe I forgot this |
||
| 1 | |||
|
CameronDev
programming.dev
CameronDev@programming.dev Joined: 2023-06-18 |
The streamlined way to do this is raw sockets. You only need one, and you can just craft all of the ICMP requests and send them continuously. Then in a separate thread you can read all the replies. |
||
| 3 | |||
|
sacred_font
infosec.pub
sacred_font@infosec.pub Joined: 2026-02-23 |
The streamlined way to do this is raw sockets. You only need one, and you can just craft all of the ICMP requests and send them continuously. Then in a separate thread you can read all the replies.
Is there any reason why it has to be a raw socket, rather than a dgram icmp socket? (which allows you to run as non-root) |
||
| 2 | |||
|
CameronDev
programming.dev
CameronDev@programming.dev Joined: 2023-06-18 |
Is there any reason why it has to be a raw socket, rather than a dgram icmp socket? (which allows you to run as non-root) Silly me for not realizing I only needed one socket. Ofc my speed would only be at most 1-2Mbps. I currently track outgoing pings in memory so I would probably need to keep a single large circular array instead for timeout purposes -- not too different from what I'm doing currently.
Dgram would work, I didn't think of that. When you have a hammer... You should be able to go pretty fast, masscan can scan the entire internet in around 5 minutes: https://github.com/robertdavidgraham/masscan |
||
| 1 | |||
|
sacred_font
infosec.pub
sacred_font@infosec.pub Joined: 2026-02-23 |
Dgram would work, I didn't think of that. When you have a hammer... Raw does let you do other scan methods (syn scan, open port scan, etc). Raw may require using bpf filtering. You should be able to go pretty fast, masscan can scan the entire internet in around 5 minutes: https://github.com/robertdavidgraham/masscan
I gave it some further thought and I might be completely misguided to try and max throughput. Datagrams are completely connectionless and therefore can’t know if your router’s send buffer is full or not, unless I’m missing something internal between the kernel and the router that makes sendto block (which AFAIK only happens when the socket’s send buffer is full). Therefore most “extra” datagrams I send would just be dropped anyways. I know ICMP was a dated method of congestion control but have no idea if it would still be in use for simple pings. Edit: apparently source quench is a thing but still, no clue if the kernel intercepts this or if it is even sent in 2026 due to deprecation |
||
| 2 | |||
|
CameronDev
programming.dev
CameronDev@programming.dev Joined: 2023-06-18 |
I gave it some further thought and I might be completely misguided to try and max throughput. Datagrams are completely connectionless and therefore can’t know if your router’s send buffer is full or not, unless I’m missing something internal between the kernel and the router that makes sendto block (which AFAIK only happens when the socket’s send buffer is full). Therefore most “extra” datagram...
Going too hard with your scan may upset your ISP as well, even if you don't lose packets along the way. |
||
| 1 | |||
| Post Reply |
Back to top |