2 This file is part of GNUnet
3 Copyright (C) 2012 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * @file transport/gnunet-transport-wlan-receiver.c
21 * @brief program to send via WLAN as much as possible (to test physical/theoretical throughput)
22 * @author David Brodski
25 #include "gnunet_protocols.h"
26 #include "plugin_transport_wlan.h"
29 main (int argc, char *argv[])
32 unsigned long long count;
38 int commpipe[2]; /* This holds the fd for the input & output of the pipe */
43 "This program must be started with the interface name as argument.\n");
45 "Usage: %s interface-name\n"
51 /* Setup communication pipeline first */
55 "Failed to create pipe: %s\n",
60 /* Attempt to fork and check for errors */
61 if ((pid = fork ()) == -1)
63 fprintf (stderr, "Failed to fork: %s\n",
70 /* A positive (non-negative) PID indicates the parent process */
71 if (0 != close (commpipe[1])) /* Close unused side of pipe (in side) */
73 "Failed to close fd: %s\n",
79 ret = read (commpipe[0], msg_buf, sizeof (msg_buf));
82 fprintf (stderr, "read failed: %s\n", strerror (errno));
89 bytes_per_s = count / (akt - start);
91 printf ("recv %f kb/s\n", bytes_per_s);
99 /* A zero PID indicates that this is the child process */
101 if (-1 == dup2 (commpipe[1], 1)) /* Replace stdin with the in side of the pipe */
102 fprintf (stderr, "dup2 failed: %s\n", strerror (errno));
103 (void) close (commpipe[0]); /* Close unused side of pipe (in side) */
104 /* Replace the child fork with a new process */
106 ("gnunet-helper-transport-wlan", "gnunet-helper-transport-wlan",
107 argv[1], NULL) == -1)
109 fprintf (stderr, "Could not start gnunet-helper-transport-wlan!");