diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-10-26 11:52:38 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-10-26 11:52:38 +0000 |
commit | 1bc7c494bd8a44ee0b135c52644d5ef10ba69c89 (patch) | |
tree | 868389b214e4f80d55225854f5ab98133e35d49d /src/transport | |
parent | e8024a46c34365da41f95431324625d5f4e85928 (diff) | |
download | gnunet-1bc7c494bd8a44ee0b135c52644d5ef10ba69c89.tar.gz gnunet-1bc7c494bd8a44ee0b135c52644d5ef10ba69c89.zip |
kb
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/gnunet-transport.c | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c index 7ce6cf72f..e8d1e3572 100644 --- a/src/transport/gnunet-transport.c +++ b/src/transport/gnunet-transport.c | |||
@@ -74,15 +74,19 @@ do_disconnect (void *cls, | |||
74 | { | 74 | { |
75 | duration = GNUNET_TIME_absolute_get_duration (start_time); | 75 | duration = GNUNET_TIME_absolute_get_duration (start_time); |
76 | fprintf (stderr, | 76 | fprintf (stderr, |
77 | "Received %llu bytes/s\n", | 77 | "Received %llu bytes/s (%llu bytes in %llu ms)\n", |
78 | traffic_received / (1+duration.rel_value)); | 78 | 1000 * traffic_received / (1+duration.rel_value), |
79 | traffic_received, | ||
80 | (unsigned long long) duration.rel_value); | ||
79 | } | 81 | } |
80 | if (benchmark_send) | 82 | if (benchmark_send) |
81 | { | 83 | { |
82 | duration = GNUNET_TIME_absolute_get_duration (start_time); | 84 | duration = GNUNET_TIME_absolute_get_duration (start_time); |
83 | fprintf (stderr, | 85 | fprintf (stderr, |
84 | "Transmitted %llu bytes/s\n", | 86 | "Transmitted %llu bytes/s (%llu bytes in %llu ms)\n", |
85 | traffic_sent / (1+duration.rel_value)); | 87 | 1000 * traffic_sent / (1+duration.rel_value), |
88 | traffic_sent, | ||
89 | (unsigned long long) duration.rel_value); | ||
86 | } | 90 | } |
87 | } | 91 | } |
88 | 92 | ||
@@ -116,6 +120,10 @@ transmit_data (void *cls, size_t size, | |||
116 | 0, | 120 | 0, |
117 | GNUNET_TIME_UNIT_FOREVER_REL, | 121 | GNUNET_TIME_UNIT_FOREVER_REL, |
118 | &transmit_data, NULL); | 122 | &transmit_data, NULL); |
123 | fprintf (stderr, | ||
124 | "Transmitting %u bytes to %s\n", | ||
125 | (unsigned int) size, | ||
126 | GNUNET_i2s (&pid)); | ||
119 | return size; | 127 | return size; |
120 | } | 128 | } |
121 | 129 | ||
@@ -137,6 +145,9 @@ notify_connect (void *cls, | |||
137 | GNUNET_ATS_Information | 145 | GNUNET_ATS_Information |
138 | * ats, uint32_t ats_count) | 146 | * ats, uint32_t ats_count) |
139 | { | 147 | { |
148 | fprintf (stderr, | ||
149 | "Connected to %s\n", | ||
150 | GNUNET_i2s (peer)); | ||
140 | if (0 != memcmp (&pid, | 151 | if (0 != memcmp (&pid, |
141 | peer, | 152 | peer, |
142 | sizeof (struct GNUNET_PeerIdentity))) | 153 | sizeof (struct GNUNET_PeerIdentity))) |
@@ -174,6 +185,9 @@ notify_disconnect (void *cls, | |||
174 | const struct | 185 | const struct |
175 | GNUNET_PeerIdentity * peer) | 186 | GNUNET_PeerIdentity * peer) |
176 | { | 187 | { |
188 | fprintf (stderr, | ||
189 | "Disconnected from %s\n", | ||
190 | GNUNET_i2s (peer)); | ||
177 | if ( (0 == memcmp (&pid, | 191 | if ( (0 == memcmp (&pid, |
178 | peer, | 192 | peer, |
179 | sizeof (struct GNUNET_PeerIdentity))) && | 193 | sizeof (struct GNUNET_PeerIdentity))) && |
@@ -210,6 +224,10 @@ notify_receive (void *cls, | |||
210 | { | 224 | { |
211 | if (! benchmark_receive) | 225 | if (! benchmark_receive) |
212 | return; | 226 | return; |
227 | fprintf (stderr, | ||
228 | "Received %u bytes from %s\n", | ||
229 | (unsigned int) ntohs (message->size), | ||
230 | GNUNET_i2s (peer)); | ||
213 | if (traffic_received == 0) | 231 | if (traffic_received == 0) |
214 | start_time = GNUNET_TIME_absolute_get (); | 232 | start_time = GNUNET_TIME_absolute_get (); |
215 | traffic_received += ntohs (message->size); | 233 | traffic_received += ntohs (message->size); |
@@ -237,19 +255,18 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
237 | if (NULL != cpid) | 255 | if (NULL != cpid) |
238 | { | 256 | { |
239 | ret = 1; | 257 | ret = 1; |
240 | handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, | ||
241 | ¬ify_receive, | ||
242 | ¬ify_connect, | ||
243 | ¬ify_disconnect); | ||
244 | if (GNUNET_OK != | 258 | if (GNUNET_OK != |
245 | GNUNET_CRYPTO_hash_from_string (cpid, &pid.hashPubKey)) | 259 | GNUNET_CRYPTO_hash_from_string (cpid, &pid.hashPubKey)) |
246 | { | 260 | { |
247 | fprintf (stderr, | 261 | fprintf (stderr, |
248 | _("Failed to parse peer identity `%s'\n"), | 262 | _("Failed to parse peer identity `%s'\n"), |
249 | cpid); | 263 | cpid); |
250 | GNUNET_TRANSPORT_disconnect (handle); | ||
251 | return; | 264 | return; |
252 | } | 265 | } |
266 | handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, | ||
267 | ¬ify_receive, | ||
268 | ¬ify_connect, | ||
269 | ¬ify_disconnect); | ||
253 | GNUNET_TRANSPORT_try_connect (handle, &pid); | 270 | GNUNET_TRANSPORT_try_connect (handle, &pid); |
254 | end = GNUNET_SCHEDULER_add_delayed (benchmark_send | 271 | end = GNUNET_SCHEDULER_add_delayed (benchmark_send |
255 | ? GNUNET_TIME_UNIT_FOREVER_REL | 272 | ? GNUNET_TIME_UNIT_FOREVER_REL |