GNUnet 0.28.1-dev.4-8-g14b9efcb0
 
Loading...
Searching...
No Matches
gnunet-transport.c File Reference

Print the virtual links transport currently has, with the flow control state CORE rides on. More...

Include dependency graph for gnunet-transport.c:

Go to the source code of this file.

Functions

static void shutdown_task (void *cls)
 Task run when the user aborts us or the listing finished.
 
static const char * route_to_string (const struct GNUNET_TRANSPORT_LinkInformation *li, char *buf, size_t buf_size)
 Render how a link is routed into buf.
 
static void print_link_verbose (const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_LinkInformation *li)
 Print everything we know about li, one field per line.
 
static void link_cb (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_LinkInformation *li)
 Function called once per virtual link, and a final time with both arguments NULL.
 
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Main function that will be run by the scheduler.
 
int main (int argc, char *const *argv)
 The main function to list the virtual links of the transport service.
 

Variables

static int ret
 Return code.
 
static int include_unconfirmed
 Option -a: also show links that are not established yet.
 
static int verbose
 Option -V: show the full flow control state of every link.
 
static char * peer_id
 Option -p: restrict the listing to this peer.
 
static struct GNUNET_TRANSPORT_LinkListContextllc
 Handle to the running listing, NULL once it completed.
 
static unsigned int num_links
 Number of links reported so far.
 

Detailed Description

Print the virtual links transport currently has, with the flow control state CORE rides on.

Author
Martin Schanzenbach

Definition in file gnunet-transport.c.

Function Documentation

◆ shutdown_task()

static void shutdown_task ( void *  cls)
static

Task run when the user aborts us or the listing finished.

Parameters
clsNULL

Definition at line 68 of file gnunet-transport.c.

69{
70 (void) cls;
71 if (NULL != llc)
72 {
74 llc = NULL;
75 }
76}
static struct GNUNET_TRANSPORT_LinkListContext * llc
Handle to the running listing, NULL once it completed.
void GNUNET_TRANSPORT_links_list_cancel(struct GNUNET_TRANSPORT_LinkListContext *llc)
Cancel a request to list virtual links.

References GNUNET_TRANSPORT_links_list_cancel(), and llc.

Here is the call graph for this function:

◆ route_to_string()

static const char * route_to_string ( const struct GNUNET_TRANSPORT_LinkInformation li,
char *  buf,
size_t  buf_size 
)
static

Render how a link is routed into buf.

Parameters
lilink to describe
[out]bufwhere to write the description
buf_sizenumber of bytes available in buf
Returns
buf

Definition at line 88 of file gnunet-transport.c.

91{
93 {
94 GNUNET_snprintf (buf, buf_size, "%s", _ ("direct"));
95 return buf;
96 }
97 /* `distance' counts neither the next hop nor the target, so the number
98 of hops a user would count is two more. */
99 GNUNET_snprintf (buf, buf_size, _ ("dv (%u hops)"), li->distance + 2);
100 return buf;
101}
@ GNUNET_TRANSPORT_LINK_ROUTE_DIRECT
Over one or more queues to a directly connected neighbour.
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.
#define _(String)
GNU gettext support macro.
Definition platform.h:179
unsigned int distance
Hops of the shortest DV path, excluding the next hop and the target itself; so 0 already means two ho...
enum GNUNET_TRANSPORT_LinkRoute route
How the link is routed.

References _, GNUNET_TRANSPORT_LinkInformation::distance, GNUNET_snprintf(), GNUNET_TRANSPORT_LINK_ROUTE_DIRECT, and GNUNET_TRANSPORT_LinkInformation::route.

Referenced by link_cb(), and print_link_verbose().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_link_verbose()

static void print_link_verbose ( const struct GNUNET_PeerIdentity peer,
const struct GNUNET_TRANSPORT_LinkInformation li 
)
static

Print everything we know about li, one field per line.

Parameters
peerpeer at the other end of the link
lithe link to print

Definition at line 111 of file gnunet-transport.c.

113{
114 char route[64];
115 char *s1;
116 char *s2;
117
118 fprintf (stdout, "%s\n", GNUNET_i2s_full (peer));
119 fprintf (stdout,
120 _ (" routed: %s over %s (%u queue(s))\n"),
121 route_to_string (li, route, sizeof (route)),
122 ('\0' == li->communicators[0]) ? "-" : li->communicators,
123 li->num_queues);
124 fprintf (stdout,
125 _ (" established: %s\n"),
126 (GNUNET_YES == li->confirmed) ? _ ("yes") : _ ("no"));
127 fprintf (stdout,
128 _ (" CORE receive window: %d\n"),
129 li->core_recv_window);
130 fprintf (stdout,
131 _ (" stalled for CORE: %u message(s)\n"),
132 li->stalled);
133 fprintf (stdout,
134 _ (" pending transmission: %u message(s)\n"),
135 li->pending);
138 fprintf (stdout, _ (" inbound window used: %s of %s\n"), s1, s2);
139 GNUNET_free (s1);
140 GNUNET_free (s2);
143 fprintf (stdout, _ (" outbound window used: %s of %s\n"), s1, s2);
144 GNUNET_free (s1);
145 GNUNET_free (s2);
148 fprintf (stdout, _ (" buffer used: %s of %s\n"), s1, s2);
149 GNUNET_free (s1);
150 GNUNET_free (s2);
151 fprintf (stdout,
152 _ (" estimated loss: %lld byte(s)\n"),
153 (long long) li->incoming_fc_window_size_loss);
154 fprintf (stdout,
155 _ (" flow control RTT: %s (peer reports %s)\n"),
157 GNUNET_YES),
159 GNUNET_YES));
160 fprintf (stdout,
161 _ (" last flow control: %s ago (%u retransmission(s))\n"),
164 GNUNET_YES),
166 fprintf (stdout, "\n");
167}
static const char * route_to_string(const struct GNUNET_TRANSPORT_LinkInformation *li, char *buf, size_t buf_size)
Render how a link is routed into buf.
@ GNUNET_YES
const char * GNUNET_i2s_full(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_free(ptr)
Wrapper around free.
char * GNUNET_STRINGS_byte_size_fancy(unsigned long long size)
Convert a given filesize into a fancy human-readable format.
Definition strings.c:105
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition time.c:438
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition strings.c:610
unsigned int pending
Number of messages queued for transmission to the target.
int64_t incoming_fc_window_size_loss
Current estimate of the message loss rate for the sender.
uint64_t outbound_fc_window_size
Window the other peer granted us.
uint64_t incoming_fc_window_size_used
How much of incoming_fc_window_size the other peer used.
uint64_t incoming_fc_window_size_ram
RAM currently held for this link.
uint64_t outbound_fc_window_size_used
How much of outbound_fc_window_size we used.
int core_recv_window
How many more messages we may hand to CORE before it must acknowledge them.
struct GNUNET_TIME_Relative other_rtt
RTT over all DV paths, as calculated by the target.
int confirmed
GNUNET_YES if the link is confirmed, i.e.
unsigned int fc_retransmit_count
Number of flow control retransmissions of the running task.
const char * communicators
Comma-separated address prefixes of the communicators currently carrying the link ("tcp",...
uint64_t available_fc_window_size
RAM transport is willing to spend on this link.
unsigned int stalled
Number of messages whose flow control ACK transport is withholding because core_recv_window is exhaus...
struct GNUNET_TIME_Absolute last_fc_transmission
When did we last send a flow control message?
uint64_t incoming_fc_window_size
Window we last granted the other peer.
struct GNUNET_TIME_Relative last_fc_rtt
RTT of the last flow control exchange.

References _, GNUNET_TRANSPORT_LinkInformation::available_fc_window_size, GNUNET_TRANSPORT_LinkInformation::communicators, GNUNET_TRANSPORT_LinkInformation::confirmed, GNUNET_TRANSPORT_LinkInformation::core_recv_window, GNUNET_TRANSPORT_LinkInformation::fc_retransmit_count, GNUNET_free, GNUNET_i2s_full(), GNUNET_STRINGS_byte_size_fancy(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get_duration(), GNUNET_YES, GNUNET_TRANSPORT_LinkInformation::incoming_fc_window_size, GNUNET_TRANSPORT_LinkInformation::incoming_fc_window_size_loss, GNUNET_TRANSPORT_LinkInformation::incoming_fc_window_size_ram, GNUNET_TRANSPORT_LinkInformation::incoming_fc_window_size_used, GNUNET_TRANSPORT_LinkInformation::last_fc_rtt, GNUNET_TRANSPORT_LinkInformation::last_fc_transmission, GNUNET_TRANSPORT_LinkInformation::num_queues, GNUNET_TRANSPORT_LinkInformation::other_rtt, GNUNET_TRANSPORT_LinkInformation::outbound_fc_window_size, GNUNET_TRANSPORT_LinkInformation::outbound_fc_window_size_used, GNUNET_TRANSPORT_LinkInformation::pending, route_to_string(), and GNUNET_TRANSPORT_LinkInformation::stalled.

Referenced by link_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ link_cb()

static void link_cb ( void *  cls,
const struct GNUNET_PeerIdentity peer,
const struct GNUNET_TRANSPORT_LinkInformation li 
)
static

Function called once per virtual link, and a final time with both arguments NULL.

Parameters
clsNULL
peerpeer at the other end of the link, NULL when done
listate of the link, NULL when done

Definition at line 179 of file gnunet-transport.c.

182{
183 char route[64];
184
185 (void) cls;
186 if (NULL == peer)
187 {
188 /* The listing completed; the handle released itself. */
189 llc = NULL;
190 if (0 == num_links)
191 fprintf (stdout, "%s\n", _ ("No virtual links."));
193 return;
194 }
195 if (verbose)
196 {
197 print_link_verbose (peer, li);
198 num_links++;
199 return;
200 }
201 if (0 == num_links)
202 fprintf (stdout,
203 "%-10s %-14s %-12s %9s %8s %8s %10s\n",
204 _ ("PEER"),
205 _ ("ROUTE"),
206 _ ("VIA"),
207 _ ("CORE-WIN"),
208 _ ("STALLED"),
209 _ ("PENDING"),
210 _ ("RTT"));
211 num_links++;
212 fprintf (stdout,
213 "%-10s %-14s %-12s %9d %8u %8u %10s\n",
214 GNUNET_i2s (peer),
215 route_to_string (li, route, sizeof (route)),
216 ('\0' == li->communicators[0]) ? "-" : li->communicators,
217 li->core_recv_window,
218 li->stalled,
219 li->pending,
221 GNUNET_YES));
222}
static unsigned int pending
The number of DNS queries that are outstanding.
static unsigned int num_links
Number of links reported so far.
static int verbose
Option -V: show the full flow control state of every link.
static void print_link_verbose(const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_LinkInformation *li)
Print everything we know about li, one field per line.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition scheduler.c:572

References _, GNUNET_TRANSPORT_LinkInformation::communicators, GNUNET_TRANSPORT_LinkInformation::core_recv_window, GNUNET_i2s(), GNUNET_SCHEDULER_shutdown(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_YES, GNUNET_TRANSPORT_LinkInformation::last_fc_rtt, llc, num_links, GNUNET_TRANSPORT_LinkInformation::pending, print_link_verbose(), route_to_string(), GNUNET_TRANSPORT_LinkInformation::stalled, and verbose.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

static void run ( void *  cls,
char *const *  args,
const char *  cfgfile,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Main function that will be run by the scheduler.

Parameters
clsclosure
argsremaining command-line arguments
cfgfilename of the configuration file used (can be NULL!)
cfgconfiguration

Definition at line 234 of file gnunet-transport.c.

238{
239 struct GNUNET_PeerIdentity pid;
240 const struct GNUNET_PeerIdentity *pidp = NULL;
241
242 (void) cls;
243 (void) cfgfile;
244 if (NULL != args[0])
245 {
246 fprintf (stderr, _ ("Invalid command line argument `%s'\n"), args[0]);
247 ret = 1;
248 return;
249 }
250 if (NULL != peer_id)
251 {
252 if (GNUNET_OK !=
254 strlen (peer_id),
255 &pid.public_key))
256 {
257 fprintf (stderr, _ ("Invalid peer ID `%s'\n"), peer_id);
258 ret = 1;
259 return;
260 }
261 pidp = &pid;
262 }
265 pidp,
267 : GNUNET_NO,
268 &link_cb,
269 NULL);
270 if (NULL == llc)
271 {
272 fprintf (stderr, "%s", _ ("Failed to connect to transport service!\n"));
273 ret = 1;
275 }
276}
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition gnunet-arm.c:108
struct GNUNET_SCHEDULER_Task * shutdown_task
static void link_cb(void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TRANSPORT_LinkInformation *li)
Function called once per virtual link, and a final time with both arguments NULL.
static char * peer_id
Option -p: restrict the listing to this peer.
static int ret
Return code.
static int include_unconfirmed
Option -a: also show links that are not established yet.
struct GNUNET_TRANSPORT_LinkListContext * GNUNET_TRANSPORT_links_list(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_PeerIdentity *peer, int include_unconfirmed, GNUNET_TRANSPORT_LinkCallback cb, void *cb_cls)
Ask the transport service for the virtual links it currently has.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_public_key_from_string(const char *enc, size_t enclen, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Convert a string representing a public key to a public key.
Definition crypto_ecc.c:362
@ GNUNET_OK
@ GNUNET_NO
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Definition scheduler.c:1345
The identity of the host (wraps the signing key of the peer).

References _, cfg, GNUNET_CRYPTO_eddsa_public_key_from_string(), GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_TRANSPORT_links_list(), GNUNET_YES, include_unconfirmed, link_cb(), llc, peer_id, GNUNET_PeerIdentity::public_key, ret, and shutdown_task.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *const *  argv 
)

The main function to list the virtual links of the transport service.

Parameters
argcnumber of arguments from the command line
argvcommand line arguments
Returns
0 ok, 1 on error

Definition at line 287 of file gnunet-transport.c.

288{
289 int res;
292 'a',
293 "all",
294 gettext_noop ("also show links that are not established yet"),
297 'p',
298 "peer",
299 "PEERID",
300 gettext_noop ("only show the link to this peer"),
301 &peer_id),
303 'V',
304 "verbose",
305 gettext_noop ("show the full flow control state of every link"),
306 &verbose),
308 };
309
311 argc,
312 argv,
313 "gnunet-transport",
315 "Print information about the virtual links of "
316 "the transport service."),
317 options,
318 &run,
319 NULL);
320 if (GNUNET_OK == res)
321 return ret;
322 return 1;
323}
struct GNUNET_GETOPT_CommandLineOption options[]
Definition 002.c:5
#define gettext_noop(String)
Definition gettext.h:74
static char * res
Currently read line or NULL on EOF.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main function that will be run by the scheduler.
#define GNUNET_GETOPT_OPTION_END
Marker for the end of the list of options.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(const struct GNUNET_OS_ProjectData *pd, int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
Definition program.c:406
Definition of a command line option.

References gettext_noop, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_flag(), GNUNET_GETOPT_option_string(), GNUNET_OK, GNUNET_OS_project_data_gnunet(), GNUNET_PROGRAM_run(), include_unconfirmed, options, peer_id, res, ret, run(), and verbose.

Here is the call graph for this function:

Variable Documentation

◆ ret

int ret
static

Return code.

Definition at line 34 of file gnunet-transport.c.

Referenced by main(), and run().

◆ include_unconfirmed

int include_unconfirmed
static

Option -a: also show links that are not established yet.

Definition at line 39 of file gnunet-transport.c.

Referenced by GNUNET_TRANSPORT_links_list(), main(), and run().

◆ verbose

int verbose
static

Option -V: show the full flow control state of every link.

Definition at line 44 of file gnunet-transport.c.

Referenced by link_cb(), and main().

◆ peer_id

char* peer_id
static

Option -p: restrict the listing to this peer.

Definition at line 49 of file gnunet-transport.c.

Referenced by main(), and run().

◆ llc

◆ num_links

unsigned int num_links
static

Number of links reported so far.

Definition at line 59 of file gnunet-transport.c.

Referenced by link_cb().