#include #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(netio.me); // Send a bunch of data to all peers for(int j=0;j<3;++j) 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; uint32_t cl = 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); ++cl; memmove(frame, &cl, sizeof(cl)); node.send_chunk(frame, chunk_size); msgsize -= chunk_size; } } printf("Sleeping\n"); sleep(3); printf("Reading\n"); 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); node.recv_commands( // error_cb [](boost::system::error_code) { printf("Error\n"); }, // epoch_cb [](uint32_t epoch) { printf("Epoch %u\n", epoch); }); } }