+
+ while(poll(pfd, 2, 0)) {
+ if(pfd[0].revents) {
+ receive_data(&sptps1);
+ }
+
+ if(pfd[1].revents) {
+ receive_data(&sptps2);
+ }
+ }
+
+ fprintf(stderr, "SPTPS/TCP transmit for %lg seconds: ", duration);
+
+ for(clock_start(); clock_countto(duration);) {
+ if(!sptps_send_record(&sptps1, 0, buf1, 1451)) {
+ abort();
+ }
+
+ receive_data(&sptps2);
+ }
+
+ rate *= 2 * 1451 * 8;
+
+ if(rate > 1e9) {
+ fprintf(stderr, "%14.2lf Gbit/s\n", rate / 1e9);
+ } else if(rate > 1e6) {
+ fprintf(stderr, "%14.2lf Mbit/s\n", rate / 1e6);
+ } else if(rate > 1e3) {
+ fprintf(stderr, "%14.2lf kbit/s\n", rate / 1e3);
+ }
+
+ sptps_stop(&sptps1);
+ sptps_stop(&sptps2);
+
+ // SPTPS datagram authentication phase
+
+ close(fd[0]);
+ close(fd[1]);
+
+ if(socketpair(AF_UNIX, SOCK_DGRAM, 0, fd)) {
+ fprintf(stderr, "Could not create a UNIX socket pair: %s\n", sockstrerror(sockerrno));
+ return 1;
+ }
+
+ fprintf(stderr, "SPTPS/UDP authenticate for %lg seconds: ", duration);
+
+ for(clock_start(); clock_countto(duration);) {
+ sptps_start(&sptps1, fd + 0, true, true, key1, key2, "sptps_speed", 11, send_data, receive_record);
+ sptps_start(&sptps2, fd + 1, false, true, key2, key1, "sptps_speed", 11, send_data, receive_record);
+
+ while(poll(pfd, 2, 0)) {
+ if(pfd[0].revents) {
+ receive_data(&sptps1);
+ }
+
+ if(pfd[1].revents) {
+ receive_data(&sptps2);
+ }
+ }
+
+ sptps_stop(&sptps1);
+ sptps_stop(&sptps2);
+ }
+
+ fprintf(stderr, "%10.2lf op/s\n", rate * 2);
+
+ // SPTPS datagram data
+
+ sptps_start(&sptps1, fd + 0, true, true, key1, key2, "sptps_speed", 11, send_data, receive_record);
+ sptps_start(&sptps2, fd + 1, false, true, key2, key1, "sptps_speed", 11, send_data, receive_record);
+