2 This file is part of GNUnet
3 (C) 2012 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file transport/gnunet-transport-wlan-receiver.c
23 * @brief program to send via WLAN as much as possible (to test physical/theoretical throughput)
24 * @author David Brodski
27 #include "gnunet_protocols.h"
28 #include "plugin_transport_wlan.h"
31 main (int argc, char *argv[])
34 unsigned long long count;
40 int commpipe[2]; /* This holds the fd for the input & output of the pipe */
45 "This program must be started with the interface name as argument.\n");
47 "Usage: %s interface-name\n"
53 /* Setup communication pipeline first */
57 "Failed to create pipe: %s\n",
62 /* Attempt to fork and check for errors */
63 if ((pid = fork ()) == -1)
65 fprintf (stderr, "Failed to fork: %s\n",
72 /* A positive (non-negative) PID indicates the parent process */
73 if (0 != close (commpipe[1])) /* Close unused side of pipe (in side) */
75 "Failed to close fd: %s\n",
81 ret = read (commpipe[0], msg_buf, sizeof (msg_buf));
84 fprintf (stderr, "read failed: %s\n", strerror (errno));
91 bytes_per_s = count / (akt - start);
93 printf ("recv %f kb/s\n", bytes_per_s);
101 /* A zero PID indicates that this is the child process */
103 if (-1 == dup2 (commpipe[1], 1)) /* Replace stdin with the in side of the pipe */
104 fprintf (stderr, "dup2 failed: %s\n", strerror (errno));
105 (void) close (commpipe[0]); /* Close unused side of pipe (in side) */
106 /* Replace the child fork with a new process */
108 ("gnunet-helper-transport-wlan", "gnunet-helper-transport-wlan",
109 argv[1], NULL) == -1)
111 fprintf (stderr, "Could not start gnunet-helper-transport-wlan!");