|
Post by AnthroHeart on Mar 24, 2024 3:29:13 GMT
I turned off my firewall, and ran your latest code, but it still didn't show a spike in total network usage.
Maybe on my computer it isn't Network Interface. I don't know.
Hmm that is strange for me its consistent. I just realized i sent you the wrong program. HAHAHAH that was my intention repeater. There are a couple of things. Why did you rename the file to picosha2.hPP instead of picosha2.h ? If you compile using g++ with the -Wall flag, it will give you a few extra warnings that help make your coding better. Like this: g++ -O3 -static -Wall main.cpp -o main.exe -lws2_32 The static flag includes all necessary libraries, and lws2_32 was required for some other reason.
|
|
|
Post by nathanmyersc on Mar 24, 2024 4:18:35 GMT
Hmm that is strange for me its consistent. I just realized i sent you the wrong program. HAHAHAH that was my intention repeater. There are a couple of things. Why did you rename the file to picosha2.hPP instead of picosha2.h ? If you compile using g++ with the -Wall flag, it will give you a few extra warnings that help make your coding better. Like this: g++ -O3 -static -Wall main.cpp -o main.exe -lws2_32 The static flag includes all necessary libraries, and lws2_32 was required for some other reason. habit of naming my headers hpp. I hate how windows names libraries. thats the Windows Socket Library. we neede that to interact with the operating systems socket modules.
|
|
|
Post by nathanmyersc on Mar 24, 2024 5:19:13 GMT
Hmm that is strange for me its consistent. I just realized i sent you the wrong program. HAHAHAH that was my intention repeater. There are a couple of things. Why did you rename the file to picosha2.hPP instead of picosha2.h ? If you compile using g++ with the -Wall flag, it will give you a few extra warnings that help make your coding better. Like this: g++ -O3 -static -Wall main.cpp -o main.exe -lws2_32 The static flag includes all necessary libraries, and lws2_32 was required for some other reason. Checking your version 0.15 i figured out why it wasnt working chat gpt must have erased the BROADCAST command to hte socket. so it wasnt in broadcasting mode.
|
|
|
Post by AnthroHeart on Mar 24, 2024 5:24:02 GMT
What update would you recommend I make?
|
|
|
Post by nathanmyersc on Mar 24, 2024 5:27:17 GMT
What update would you recommend I make? setting up the socket should look something like this int setupSocket(SOCKET& theSocket, const int i)
{
//setWindowsSockets();
theSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (theSocket == INVALID_SOCKET)
{
cerr << "Socket creation failed for thread " << i << " with error: " << WSAGetLastError() << endl;
WSACleanup();
return 1;
}
const int broadcast = 1; // Value to enable broadcast
if (setsockopt(theSocket, SOL_SOCKET, SO_BROADCAST, (const char*)&broadcast, sizeof(broadcast)) == SOCKET_ERROR) {
// Setting socket option for enabling broadcast
cerr << "Error in setting Broadcast option with error: " << WSAGetLastError() << endl; // Printing error message if setting fails
closesocket(theSocket); // Closing socket
WSACleanup(); // Cleaning up Winsock resources
return 1; // Exiting program with error code
}
if (setsockopt(theSocket, SOL_SOCKET, SO_SNDBUF, (const char *)&BUFFER_SIZE, sizeof(BUFFER_SIZE)) == SOCKET_ERROR)
{
cerr << "Error in setting UDP buffer size with error: " << WSAGetLastError() << endl;
closesocket(theSocket);
WSACleanup();
return 1;
}
return 0;
}
|
|
|
Post by nathanmyersc on Mar 24, 2024 5:40:05 GMT
What update would you recommend I make? Minimize UDP Header Size and Avoid Unnecessary Protocol Options: To minimize the UDP header size and avoid unnecessary protocol options, we'll use the IP_HDRINCL socket option. This option allows us to construct our own IP header, bypassing the default UDP header provided by the operating system. By doing this, we can send UDP packets with only the necessary information, reducing overhead. Here's how you can set this option in your code: cpp Copy code int enable = 1;
if (setsockopt(sock, IPPROTO_IP, IP_HDRINCL, (char *)&enable, sizeof(enable)) < 0) {
cerr << "Error setting IP_HDRINCL option" << endl;
// Handle error
} Set Appropriate Socket Timeouts and Retries: To set socket timeouts and retries, we'll use the setsockopt() function with the SO_RCVTIMEO and SO_SNDTIMEO options for both send and receive operations. These options allow us to specify the maximum time to wait for socket operations (e.g., send or receive) before timing out. Here's how you can set socket timeouts for both send and receive operations: cpp Copy code struct timeval timeout;
timeout.tv_sec = 5; // Set timeout to 5 seconds
timeout.tv_usec = 0; // Set microseconds to 0
if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof(timeout)) < 0) {
cerr << "Error setting receive timeout" << endl;
// Handle error
}
if (setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout, sizeof(timeout)) < 0) {
cerr << "Error setting send timeout" << endl;
// Handle error
} ZLIB Message Compression: ZLIB is a widely used compression library that provides functions for data compression and decompression. You can use ZLIB to compress your intention message before sending it over the network, reducing the amount of data transmitted. Here's how you can use ZLIB compression in your code: cpp Copy code #include <zlib.h>
std::string compressMessage(const std::string &message) {
z_stream zs;
memset(&zs, 0, sizeof(zs));
if (deflateInit(&zs, Z_DEFAULT_COMPRESSION) != Z_OK) {
return ""; // Compression initialization failed
}
zs.next_in = (Bytef *)message.data();
zs.avail_in = message.size();
std::string compressed;
char outbuffer[32768]; // Output buffer
int ret;
do {
zs.next_out = reinterpret_cast<Bytef *>(outbuffer);
zs.avail_out = sizeof(outbuffer);
ret = deflate(&zs, Z_FINISH);
if (compressed.size() < zs.total_out) {
compressed.append(outbuffer, zs.total_out - compressed.size());
}
} while (ret == Z_OK);
deflateEnd(&zs);
if (ret != Z_STREAM_END) {
return ""; // Compression failed
}
return compressed;
} These optimizations should help you minimize UDP header size, avoid unnecessary protocol options, set appropriate socket timeouts and retries, and implement ZLIB message compression in your code. Make sure to integrate these optimizations into your existing codebase as needed. should explore some of these options as well. chat gpt suggested ZLIB message compression. If we could COMPRESS the multiplid hashed value into a smaller size we could transmit even more.
|
|
|
Post by AnthroHeart on Mar 24, 2024 5:42:18 GMT
What update would you recommend I make? setting up the socket should look something like this int setupSocket(SOCKET& theSocket, const int i)
{
//setWindowsSockets();
theSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (theSocket == INVALID_SOCKET)
{
cerr << "Socket creation failed for thread " << i << " with error: " << WSAGetLastError() << endl;
WSACleanup();
return 1;
}
const int broadcast = 1; // Value to enable broadcast
if (setsockopt(theSocket, SOL_SOCKET, SO_BROADCAST, (const char*)&broadcast, sizeof(broadcast)) == SOCKET_ERROR) {
// Setting socket option for enabling broadcast
cerr << "Error in setting Broadcast option with error: " << WSAGetLastError() << endl; // Printing error message if setting fails
closesocket(theSocket); // Closing socket
WSACleanup(); // Cleaning up Winsock resources
return 1; // Exiting program with error code
}
if (setsockopt(theSocket, SOL_SOCKET, SO_SNDBUF, (const char *)&BUFFER_SIZE, sizeof(BUFFER_SIZE)) == SOCKET_ERROR)
{
cerr << "Error in setting UDP buffer size with error: " << WSAGetLastError() << endl;
closesocket(theSocket);
WSACleanup();
return 1;
}
return 0;
} It's giving me the error: Error in setting Broadcast option with error: 0
And now error: Error setting IP_HDRINCL option
For this code: Intention_Repeater_WiFi_v0.16.cpp (16.04 KB)
|
|
|
Post by nathanmyersc on Mar 24, 2024 7:00:27 GMT
setting up the socket should look something like this int setupSocket(SOCKET& theSocket, const int i)
{
//setWindowsSockets();
theSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (theSocket == INVALID_SOCKET)
{
cerr << "Socket creation failed for thread " << i << " with error: " << WSAGetLastError() << endl;
WSACleanup();
return 1;
}
const int broadcast = 1; // Value to enable broadcast
if (setsockopt(theSocket, SOL_SOCKET, SO_BROADCAST, (const char*)&broadcast, sizeof(broadcast)) == SOCKET_ERROR) {
// Setting socket option for enabling broadcast
cerr << "Error in setting Broadcast option with error: " << WSAGetLastError() << endl; // Printing error message if setting fails
closesocket(theSocket); // Closing socket
WSACleanup(); // Cleaning up Winsock resources
return 1; // Exiting program with error code
}
if (setsockopt(theSocket, SOL_SOCKET, SO_SNDBUF, (const char *)&BUFFER_SIZE, sizeof(BUFFER_SIZE)) == SOCKET_ERROR)
{
cerr << "Error in setting UDP buffer size with error: " << WSAGetLastError() << endl;
closesocket(theSocket);
WSACleanup();
return 1;
}
return 0;
} It's giving me the error: Error in setting Broadcast option with error: 0
And now error: Error setting IP_HDRINCL option
For this code: View AttachmentHeres my code i never attempted using raw sockets or a custom header yet. But i implemented ZLIB compression as an option. ITS like putting our hashed value into a 7zip basically. I havent multipled the zlib compression but it should be faster since it doesnt take up as much space its probably even within the MTU. EDIT UPDATED IT AFTER FIXING IT. Now i GET CONSISTENT 2+ megabyte transfer per second. And no more errors. And i no longer have to restart my router after using it. IT AMAZING. i have no idea if ZLIB compression helps. But either way i am sending consistent megabyte transfers broadcasting every second. no errors about sockets or anything like that NO BROADCAST WAITING OR ANYTHING. its awesome. no idea of the effects but when i sleep tonight ima have it on. Attachments:main.cpp (18.8 KB)
|
|
|
Post by nathanmyersc on Mar 24, 2024 7:53:28 GMT
Ok heres another updated version of my take on the intention repeater wifi broadcaster more cleaning up code and optimizing. Made an option to display details in the title of the console instead of writing to console. as i feel it may be faster or use less resources to change the title not sure. Attachments:main.cpp (19.87 KB)
|
|
|
Post by AnthroHeart on Mar 24, 2024 9:46:07 GMT
Ok heres another updated version of my take on the intention repeater wifi broadcaster more cleaning up code and optimizing. Made an option to display details in the title of the console instead of writing to console. as i feel it may be faster or use less resources to change the title not sure. Ok, I was able to make small changes like including header files that were missing.
Should we update this to show a timer and # of iterations and the frequency?
My network display is finally showing 11,174,691 bytes / sec.
When you implement ZLIB compression, do you multiply that back up to 1GB, or leave it small and compressed and just repeat that?
Here is what I have: main.cpp (19.87 KB)
|
|
|
Post by nathanmyersc on Mar 24, 2024 9:52:30 GMT
Ok heres another updated version of my take on the intention repeater wifi broadcaster more cleaning up code and optimizing. Made an option to display details in the title of the console instead of writing to console. as i feel it may be faster or use less resources to change the title not sure. Ok, I was able to make small changes like including header files that were missing.
Should we update this to show a timer and # of iterations and the frequency?
My network display is finally showing 11,174,691 bytes / sec.
When you implement ZLIB compression, do you multiply that back up to 1GB, or leave it small and compressed and just repeat that?
I left it small so that there would be no issues with MTU. im getting consistent MBs sent out. My internet not the fastest. It currentl displays the timer and interations and frequency as part of the title due to a boolean i set. can easily disable it for it to show in the console. Totally going to sleep now and gonna have it on all night. its like a rife frequency generator to me. il chck out what you did tomorrow dead tired atm
|
|
|
Post by AnthroHeart on Mar 24, 2024 10:40:54 GMT
Ok, I was able to make small changes like including header files that were missing.
Should we update this to show a timer and # of iterations and the frequency?
My network display is finally showing 11,174,691 bytes / sec.
When you implement ZLIB compression, do you multiply that back up to 1GB, or leave it small and compressed and just repeat that?
I left it small so that there would be no issues with MTU. im getting consistent MBs sent out. My internet not the fastest. It currentl displays the timer and interations and frequency as part of the title due to a boolean i set. can easily disable it for it to show in the console. Totally going to sleep now and gonna have it on all night. its like a rife frequency generator to me. il chck out what you did tomorrow dead tired atm I ran for 5-10 mins and it froze my computer. Was throwing a few errors I didn't get around to recording.
I asked Claude 3 Opus to optimize the code and keep it from freezing the computer. It may have worked.
It didn't seem to freeze up when I ran it for an hour or so, but I haven't tested it thoroughly.
Here is my updated code from what you had: main2.cpp (12.82 KB)
|
|
|
Post by reden on Mar 24, 2024 13:13:36 GMT
There are a couple of things. Why did you rename the file to picosha2.hPP instead of picosha2.h ? If you compile using g++ with the -Wall flag, it will give you a few extra warnings that help make your coding better. Like this: g++ -O3 -static -Wall main.cpp -o main.exe -lws2_32 The static flag includes all necessary libraries, and lws2_32 was required for some other reason. Checking your version 0.15 i figured out why it wasnt working chat gpt must have erased the BROADCAST command to hte socket. so it wasnt in broadcasting mode. Claude deletes stuff way more rarely.
|
|
|
Post by nathanmyersc on Mar 24, 2024 18:31:44 GMT
I left it small so that there would be no issues with MTU. im getting consistent MBs sent out. My internet not the fastest. It currentl displays the timer and interations and frequency as part of the title due to a boolean i set. can easily disable it for it to show in the console. Totally going to sleep now and gonna have it on all night. its like a rife frequency generator to me. il chck out what you did tomorrow dead tired atm I ran for 5-10 mins and it froze my computer. Was throwing a few errors I didn't get around to recording.
I asked Claude 3 Opus to optimize the code and keep it from freezing the computer. It may have worked.
It didn't seem to freeze up when I ran it for an hour or so, but I haven't tested it thoroughly.
Im pretty sure its this_thread::sleep_for(milliseconds(10)); inside the loop. Since the bottle neck is the packet transmission perhaps the 10 milliseconds minimum between loops stops the crash or overflowing. perhaps experiment with higher inervals of sleep. Its crashing cuase its using 100 percent of hte CPU and making your laptop overheat or malfunction. i actually get better packet transmission consistent 10 mb per second with 10 ms sleep for intervals. I think it crashes because it uses the entire CPU and might be heating up to oa large extent. perhaps with 10 ms interval sleep minimum it wont od that.
|
|
|
Post by nathanmyersc on Mar 24, 2024 21:00:43 GMT
Heres the latest version with many improvements. it no loonger maxes every Core at 100% i made improvements to how the threads sleep. It uses very little CPU now whilst maintaing the same packet sending rate. The timer descriptor we use is not really an accurate representation of the number of packets actually sent. But i leave it in. it glitches out sometimes but looking at the actual packets sent shows me it isnt a problem. This program now does not cause your computer to crash although it will stop your internet from working since it steals all the bandwidth Attachments:main.cpp (19.74 KB)
|
|