int main(int argc, char **argv) { (void)argc; (void)argv; const uint32_t net = 0x0a0a0a00; char *password; setup_test("tcpr-test", "test-spurious-fins"); password = get_password(htonl(net | 2), 8888, htonl(net | 3), 9999); setup_connection(net | 2, net | 4, net | 3, 8888, 9999, 0xdeadbeef, 0xcafebabe, test_options_size, test_options, peer_mss, peer_ws, password); fprintf(stderr, "Application: FIN (failure)\n"); send_segment(internal_log, net | 4, net | 2, 9999, 8888, TH_ACK | TH_FIN, 0xcafebabe + 1, 0xdeadbeef + 1, 0, NULL, 0, NULL, password); fprintf(stderr, " Filter: RST\n"); recv_segment(internal_log, net | 2, net | 4, 8888, 9999, TH_RST, 0xdeadbeef + 1, 0, 0, NULL, 0, NULL, password); cleanup_connection(net | 2, net | 4, 8888, 9999, 0xcafebabe + 1, 0xdeadbeef + 1, 0); cleanup_test(); return EXIT_SUCCESS; }
int main(int argc, char **argv) { (void)argc; (void)argv; const uint32_t net = 0x0a0a0a00; char *password; setup_test("tcpr-test", "test-recover-peer-send"); password = get_password(htonl(net | 2), 8888, htonl(net | 3), 9999); setup_connection(net | 2, net | 4, net | 3, 8888, 9999, 0xdeadbeef, 0xcafebabe, test_options_size, test_options, peer_mss, peer_ws, password); recover_connection(net | 5, net | 2, net | 3, 9999, 8888, 0xfeedbead, 0xcafebabe, 0xdeadbeef, test_options_size, test_options, peer_mss, peer_ws, TCPR_HAVE_ACK | TCPR_HAVE_PEER_MSS | TCPR_HAVE_PEER_WS, password); fprintf(stderr, " Peer: \"baz\" (retransmit)\n"); send_segment(external_log, net | 2, net | 3, 8888, 9999, TH_ACK, 0xdeadbeef + 1, 0xcafebabe + 1, 0, NULL, 4, "baz", password); recv_segment(internal_log, net | 2, net | 5, 8888, 9999, TH_ACK, 0xdeadbeef + 1, 0xfeedbead + 1, 0, NULL, 4, "baz", password); fprintf(stderr, "Application: ACK\n"); send_segment(internal_log, net | 5, net | 2, 9999, 8888, TH_ACK, 0xfeedbead + 1, 0xdeadbeef + 5, 0, NULL, 0, NULL, password); fprintf(stderr, "Application: update\n"); send_update(net | 2, net | 5, 8888, 9999, 0xcafebabe + 1, 0xdeadbeef + 5, 0, 0, (0xfeedbead + 1) - (0xcafebabe + 1), TCPR_HAVE_ACK); fprintf(stderr, " Filter: ACK\n"); recv_segment(external_log, net | 3, net | 2, 9999, 8888, TH_ACK, 0xcafebabe + 1, 0xdeadbeef + 5, 0, NULL, 0, NULL, password); cleanup_connection(net | 2, net | 4, 8888, 9999, 0xcafebabe + 1, 0xdeadbeef + 1, (0xfeedbead + 1) - (0xcafebabe + 1)); cleanup_test(); return EXIT_SUCCESS; }
int main(int argc, char **argv) { (void)argc; (void)argv; const uint32_t net = 0x0a0a0a00; char *password; setup_test("tcpr-test", "test-filter-recovery"); password = get_password(htonl(net | 2), 8888, htonl(net | 3), 9999); fprintf(stderr, "Application: \"a\"\n"); send_segment(internal_log, net | 4, net | 2, 9999, 8888, TH_ACK, 0xbeefbead, 0xbabedeed, 0, NULL, 2, "a", password); fprintf(stderr, " Filter: update (failure)\n"); recv_update(net | 2, net | 4, 8888, 9999, 0, 0, 0, 0, 0, 0); fprintf(stderr, "Application: update\n"); send_update(net | 2, net | 4, 8888, 9999, 0xbeefbead, 0xbabedeed - 4, peer_mss, peer_ws, 0, TCPR_HAVE_ACK); fprintf(stderr, " Filter: ACK\n"); recv_segment(external_log, net | 3, net | 2, 9999, 8888, TH_ACK, 0xbeefbead + 2, 0xbabedeed - 4, 0, NULL, 0, NULL, password); fprintf(stderr, "Application: \"a\" (retransmit)\n"); send_segment(internal_log, net | 4, net | 2, 9999, 8888, TH_ACK, 0xbeefbead, 0xbabedeed, 0, NULL, 2, "a", password); recv_segment(external_log, net | 3, net | 2, 9999, 8888, TH_ACK, 0xbeefbead, 0xbabedeed - 4, 0, NULL, 2, "a", password); cleanup_connection(net | 2, net | 4, 8888, 9999, 0xbeefbead, 0xbabedeed - 4, 0); cleanup_test(); return EXIT_SUCCESS; }
void *dedup_thread(void *arg) { struct segment* s = NULL; while (1) { struct chunk *c = NULL; if (destor.simulation_level != SIMULATION_ALL) c = sync_queue_pop(hash_queue); else c = sync_queue_pop(trace_queue); /* Add the chunk to the segment. */ s = segmenting(c); if (!s) continue; /* segmenting success */ if (s->chunk_num > 0) { VERBOSE("Dedup phase: the %lldth segment of %lld chunks", segment_num++, s->chunk_num); /* Each duplicate chunk will be marked. */ pthread_mutex_lock(&index_lock.mutex); while (index_lookup(s) == 0) { pthread_cond_wait(&index_lock.cond, &index_lock.mutex); } pthread_mutex_unlock(&index_lock.mutex); } else { VERBOSE("Dedup phase: an empty segment"); } /* Send chunks in the segment to the next phase. * The segment will be cleared. */ send_segment(s); free_segment(s); s = NULL; if (c == NULL) break; } sync_queue_term(dedup_queue); return NULL; }
int main(int argc, char **argv) { (void)argc; (void)argv; const uint32_t net = 0x0a0a0a00; char *password; setup_test("tcpr-test", "test-simultaneous-recovery"); password = get_password(htonl(net | 2), 8888, htonl(net | 3), 9999); fprintf(stderr, "Application: SYN (simultaneous recovery)\n"); send_segment(internal_log, net | 4, net | 2, 9999, 8888, TH_SYN, 0xcafebabe, 0, 0, NULL, 0, NULL, password); recv_segment(external_log, net | 3, net | 2, 9999, 8888, TH_SYN, 0xcafebabe, 0, 0, NULL, 0, NULL, password); fprintf(stderr, " Peer: ACK (answer unacceptable SYN)\n"); send_segment(external_log, net | 2, net | 3, 8888, 9999, TH_ACK, 0xdeadbeef + 5, 0xcafebabe + 1, 0, NULL, 0, NULL, password); fprintf(stderr, " Filter: update (failure)\n"); recv_update(net | 2, net | 4, 8888, 9999, 0xcafebabe + 1, 0, 0, 0, 0, 0); fprintf(stderr, "Application: update\n"); send_update(net | 2, net | 4, 8888, 9999, 0xcafebabe + 1, 0xdeadbeef + 5, 0, 0, 0, TCPR_HAVE_ACK); fprintf(stderr, " Filter: ACK\n"); recv_segment(external_log, net | 3, net | 2, 9999, 8888, TH_ACK, 0xcafebabe + 1, 0xdeadbeef + 5, 0, NULL, 0, NULL, password); fprintf(stderr, "Application: SYN (retransmit)\n"); send_segment(internal_log, net | 4, net | 2, 9999, 8888, TH_SYN, 0xcafebabe, 0, 0, NULL, 0, NULL, password); fprintf(stderr, " Filter: SYN ACK\n"); recv_segment(internal_log, net | 2, net | 4, 8888, 9999, TH_SYN | TH_ACK, 0xdeadbeef + 4, 0xcafebabe + 1, 0, NULL, 0, NULL, password); fprintf(stderr, " Filter: update\n"); recv_update(net | 2, net | 4, 8888, 9999, 0xcafebabe + 1, 0xdeadbeef + 5, 0, 0, 0, TCPR_HAVE_ACK); fprintf(stderr, "Application: ACK\n"); send_segment(internal_log, net | 4, net | 2, 9999, 8888, TH_ACK, 0xcafebabe + 1, 0xdeadbeef + 5, 0, NULL, 0, NULL, password); recv_segment(external_log, net | 3, net | 2, 9999, 8888, TH_ACK, 0xcafebabe + 1, 0xdeadbeef + 5, 0, NULL, 0, NULL, password); fprintf(stderr, "Application: update (reset)\n"); send_update(net | 2, net | 4, 8888, 9999, 0xcafebabe + 1, 0xdeadbeef + 5, 0, 0, 0, TCPR_HAVE_ACK | TCPR_TIME_WAIT); cleanup_connection(net | 2, net | 4, 8888, 9999, 0xcafebabe + 1, 0xdeadbeef + 1, 0); cleanup_test(); return EXIT_SUCCESS; }