| 123456789101112131415161718192021222324252627282930313233 |
- #include <stdlib.h>
- #include "start.hpp"
- // Once all the networking is set up, start doing whatever we were asked
- // to do on the command line
- void start(NetIO &netio, int argc, char **argv)
- {
- srand48(1);
- // Send a bunch of data to all peers
- for (size_t node_num = 0; node_num < netio.num_nodes; ++node_num) {
- if (node_num == netio.me) continue;
- NodeIO &node = netio.node(node_num);
- uint32_t msgsize = lrand48() % 10000000;
- printf("Msgsize to %lu: %u\n", node_num, msgsize);
- node.send_message_header(msgsize);
- uint8_t c = 0;
- while (msgsize > 0) {
- uint8_t* frame = node.request_frame();
- uint32_t chunk_size = (lrand48() % (MAXCHUNKSIZE-1)) + 1;
- if (chunk_size > msgsize) {
- chunk_size = msgsize;
- }
- memset(frame, ++c, chunk_size);
- node.send_chunk(frame, chunk_size);
- msgsize -= chunk_size;
- }
- }
- printf("Sleeping\n");
- sleep(10);
- }
|