31#include "gnunet_transport_service.h"
36#define RESOLUTION_TIMEOUT \
37 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
42#define OP_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
83 struct GNUNET_TRANSPORT_AddressToStringContext *
asc;
104 enum GNUNET_TRANSPORT_PeerState
state;
140 struct GNUNET_TRANSPORT_AddressToStringContext *
asc;
145 enum GNUNET_TRANSPORT_PeerState
state;
272static struct GNUNET_TRANSPORT_PeerMonitoringContext *
pic;
277static struct GNUNET_TRANSPORT_PluginMonitor *
pm;
369 GNUNET_TRANSPORT_monitor_peers_cancel (
pic);
374 GNUNET_TRANSPORT_monitor_plugins_cancel (
pm);
379 for (cur =
next; NULL != cur; cur =
next)
383 GNUNET_TRANSPORT_address_to_string_cancel (cur->
asc);
386 GNUNET_HELLO_address_free (cur->
addrcp);
392 GNUNET_TRANSPORT_address_to_string_cancel (rc->
asc);
406 _ (
"Transmitted %llu bytes/s (%llu bytes in %s)\n"),
415 _ (
"Received %llu bytes/s (%llu bytes in %s)\n"),
435 GNUNET_TRANSPORT_blacklist_cancel (
blacklist);
462 while (NULL != (cur =
next))
466 _ (
"Failed to resolve address for peer `%s'\n"),
470 GNUNET_TRANSPORT_address_to_string_cancel (cur->
asc);
477 _ (
"Failed to list connections, timeout occurred\n"));
504 _ (
"Transmitting %u bytes\n"),
537 "Successfully connected to `%s', starting to send benchmark data in %u Kb blocks\n"),
561 if (NULL == internal_cls)
566 _ (
"Disconnected from peer `%s' while benchmarking\n"),
590 _ (
"%24s: %-17s %4s (%u connections in total)\n"),
619 _ (
"%24s: %-17s %4s (%u connections in total)\n"),
621 _ (
"Disconnected from"),
654 _ (
"Received %u bytes\n"),
655 (
unsigned int) ntohs (message->
size));
674 enum GNUNET_TRANSPORT_PeerState
state,
682 enum GNUNET_TRANSPORT_PeerState
state,
689 _ (
"Peer `%s': %s %s in state `%s' until %s\n"),
693 GNUNET_TRANSPORT_ps2s (
state),
697 (GNUNET_TRANSPORT_is_connected (
state)))
701 _ (
"Peer `%s': %s %s\n"),
736 "Failed to convert address for peer `%s' plugin `%s' length %u to string \n",
738 rc->
addrcp->transport_name,
739 (
unsigned int) rc->
addrcp->address_length);
818 enum GNUNET_TRANSPORT_PeerState
state,
832 rc->
asc = GNUNET_TRANSPORT_address_to_string (
cfg,
854 const struct GNUNET_HELLO_Address *
address,
855 enum GNUNET_TRANSPORT_PeerState
state,
875 "Received address for peer `%s': %s\n",
894 struct GNUNET_TRANSPORT_AddressToStringContext *
asc;
905 struct GNUNET_TRANSPORT_SessionInfo
si;
917 const struct GNUNET_TRANSPORT_SessionInfo *
info)
923 case GNUNET_TRANSPORT_SS_INIT:
927 case GNUNET_TRANSPORT_SS_HANDSHAKE:
931 case GNUNET_TRANSPORT_SS_UP:
935 case GNUNET_TRANSPORT_SS_UPDATE:
939 case GNUNET_TRANSPORT_SS_DONE:
948 "%s: state %s timeout in %s @ %s%s\n",
957 "%s: queue has %3u messages and %6u bytes\n",
959 info->num_msg_pending,
960 info->num_bytes_pending);
964 "%s: receiving blocked until %s\n",
996 if (NULL != addr->
str)
1022 struct GNUNET_TRANSPORT_PluginSession *session,
1024 const struct GNUNET_TRANSPORT_SessionInfo *
info)
1028 if ((NULL ==
info) && (NULL == session))
1030 addr = *session_ctx;
1035 if (NULL != addr->
asc)
1037 GNUNET_TRANSPORT_address_to_string_cancel (addr->
asc);
1042 *session_ctx = NULL;
1053 GNUNET_TRANSPORT_address_to_string (
cfg,
1059 *session_ctx = addr;
1061 if (NULL == addr->
str)
1065 if (GNUNET_TRANSPORT_SS_DONE ==
info->state)
1067 if (NULL != addr->
asc)
1069 GNUNET_TRANSPORT_address_to_string_cancel (addr->
asc);
1074 *session_ctx = NULL;
1092 const struct GNUNET_HELLO_Address *
address,
1093 enum GNUNET_TRANSPORT_PeerState
state,
1103 "Monitor disconnected from transport service. Reconnecting.\n"));
1123 if ((
m->state ==
state) &&
1125 (NULL ==
address) && (NULL ==
m->address))
1129 if ((
m->state ==
state) && (NULL !=
address) && (NULL !=
m->address) &&
1130 (0 == GNUNET_HELLO_address_cmp (
m->address,
address)))
1134 if (NULL !=
m->address)
1140 m->address = GNUNET_HELLO_address_copy (
address);
1147 print_info (peer, NULL, NULL,
m->state,
m->state_timeout);
1180 const char *cfgfile,
1199 "Multiple operations given. Please choose only one operation: %s, %s, %s, %s, %s, %s %s\n"),
1202 "benchmark receive",
1214 "No operation given. Please choose one operation: %s, %s, %s, %s, %s, %s, %s\n"),
1217 "benchmark receive",
1227 if (0 == memcmp (&zero_pid, &
pid,
sizeof(
pid)))
1230 _ (
"Option `%s' makes no sense without option `%s'.\n"),
1242 "Failed to connect to transport service for disconnection\n"));
1248 _ (
"Blacklisting request in place, stop with CTRL-C\n"));
1252 if (0 == memcmp (&zero_pid, &
pid,
sizeof(
pid)))
1255 _ (
"Option `%s' makes no sense without option `%s'.\n"),
1270 fprintf (stderr,
"%s",
_ (
"Failed to connect to transport service\n"));
1296 fprintf (stderr,
"%s",
_ (
"Failed to connect to transport service\n"));
1301 fprintf (stdout,
"%s",
_ (
"Starting to receive benchmark data\n"));
1306 pic = GNUNET_TRANSPORT_monitor_peers (
cfg,
1318 pic = GNUNET_TRANSPORT_monitor_peers (
cfg,
1342 fprintf (stderr,
"%s",
_ (
"Failed to connect to transport service\n"));
1367 "print information for all peers (instead of only connected peers)"),
1373 "measure how fast we are receiving data from all peers (until CTRL-C)"),
1383 "provide information about all current connections (once)"),
1389 "provide information about all current connections (continuously)"),
1395 "provide information about all connects and disconnect events (continuously)"),
1414 "send data for benchmarking to the other peer (until CTRL-C)"),
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
struct GNUNET_GETOPT_CommandLineOption options[]
struct GNUNET_MQ_MessageHandlers handlers[]
struct GNUNET_MQ_Handle * mq
struct GNUNET_MQ_Envelope * env
#define gettext_noop(String)
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
static char * address
GNS address for this phone.
struct GNUNET_HashCode key
The key used in the DHT.
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
static char * res
Currently read line or NULL on EOF.
static char * value
Value of the record to add/remove.
enum State state
current state of profiling
struct GNUNET_TRANSPORT_ApplicationHandle * transport
Handle to Transport service.
static void print_info(const struct GNUNET_PeerIdentity *id, const char *transport, const char *addr, enum GNUNET_TRANSPORT_PeerState state, struct GNUNET_TIME_Absolute state_timeout)
static int benchmark_send
Option -s.
static int monitor_connections
Option -m.
static struct PeerResolutionContext * rc_tail
DLL: head of resolution entries.
static void process_peer_monitoring_cb(void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, enum GNUNET_TRANSPORT_PeerState state, struct GNUNET_TIME_Absolute state_timeout)
Function called with information about a peers.
static unsigned int verbosity
Selected level of verbosity.
struct GNUNET_TRANSPORT_Blacklist * blacklist
Blacklisting handle.
#define OP_TIMEOUT
Timeout for an operation.
static unsigned int address_resolutions
Number of address resolutions pending.
static void process_peer_string(void *cls, const char *address, int res)
Function called with a textual representation of an address.
static unsigned long long traffic_sent
Number of bytes of traffic we sent so far.
static int monitor_plugins
Option -P.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
static void address_cb(void *cls, const char *address, int res)
Function called with a textual representation of an address.
static int numeric
Option -n.
static struct ValidationResolutionContext * vc_tail
DLL: tail of validation resolution entries.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *mycfg)
Main function that will be run by the scheduler.
static int monitor_connect_counter
Current number of connections in monitor mode.
static struct GNUNET_TIME_Absolute start_time
Starting time of transmitting/receiving data.
static struct GNUNET_TRANSPORT_CoreHandle * handle
Handle to transport service.
static void do_send(void *cls)
Function called to notify a client about the socket begin ready to queue more data.
static void * monitor_notify_connect(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Function called to notify transport users that another peer connected to us.
static void shutdown_task(void *cls)
Task run in monitor mode when the user presses CTRL-C to abort.
static int ret
Global return value (0 success).
static struct GNUNET_CONFIGURATION_Handle * cfg
Configuration handle.
static void * notify_connect(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Function called to notify transport users that another peer connected to us.
static void plugin_monitoring_cb(void *cls, struct GNUNET_TRANSPORT_PluginSession *session, void **session_ctx, const struct GNUNET_TRANSPORT_SessionInfo *info)
Function called by the plugin with information about the current sessions managed by the plugin (for ...
static struct GNUNET_CONTAINER_MultiPeerMap * monitored_plugins
Map storing information about monitored plugins's sessions.
static struct GNUNET_TRANSPORT_PeerMonitoringContext * pic
Handle if we are monitoring peers at the transport level.
static int monitor_connects
Option -c.
static int iterate_all
Option -a.
static struct PeerResolutionContext * rc_head
DLL: head of resolution entries.
static void print_plugin_event_info(struct PluginMonitorAddress *addr, const struct GNUNET_TRANSPORT_SessionInfo *info)
Print information about a plugin monitoring event.
static void handle_dummy(void *cls, const struct GNUNET_MessageHeader *message)
Function called by the transport for each received message.
struct GNUNET_OS_Process * resolver
Resolver process handle.
static void operation_timeout(void *cls)
We are done, shut down.
static int do_disconnect
Option -D.
static void process_peer_iteration_cb(void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, enum GNUNET_TRANSPORT_PeerState state, struct GNUNET_TIME_Absolute state_timeout)
Function called with information about a peers during a one shot iteration.
static void notify_disconnect(void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls)
Function called to notify transport users that another peer disconnected from us.
static struct ValidationResolutionContext * vc_head
DLL: head of validation resolution entries.
static int check_dummy(void *cls, const struct GNUNET_MessageHeader *message)
Function called by the transport for each received message.
static int blacklist_cb(void *cls, const struct GNUNET_PeerIdentity *cpid)
Function called with the transport service checking if we want to blacklist a peer.
static struct GNUNET_CONTAINER_MultiPeerMap * monitored_peers
Map storing information about monitored peers.
static int benchmark_receive
Option -b.
static int iterate_connections
Option -i.
static struct GNUNET_TRANSPORT_PluginMonitor * pm
Handle if we are monitoring plugin session activity.
int main(int argc, char *const *argv)
static struct GNUNET_SCHEDULER_Task * op_timeout
Task for operation timeout.
static unsigned long long traffic_received
Number of bytes of traffic we received so far.
static int destroy_it(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Function called to release data stored in the monitored_peers map.
static void monitor_notify_disconnect(void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls)
Function called to notify transport users that another peer disconnected from us.
#define RESOLUTION_TIMEOUT
Timeout for a name resolution.
static void resolve_peer_address(const struct GNUNET_HELLO_Address *address, int numeric, enum GNUNET_TRANSPORT_PeerState state, struct GNUNET_TIME_Absolute state_timeout)
Convert address to a printable format.
#define BLOCKSIZE
Benchmarking block size in KB.
static struct GNUNET_TIME_Relative duration
Option '-d': duration of the mapping.
Constants for network protocols.
Functions related to doing DNS lookups.
struct GNUNET_TRANSPORT_CoreHandle * GNUNET_TRANSPORT_core_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_PeerIdentity *self, const struct GNUNET_MQ_MessageHandler *handlers, void *cls, GNUNET_TRANSPORT_NotifyConnect nc, GNUNET_TRANSPORT_NotifyDisconnect nd)
Connect to the transport service.
void GNUNET_TRANSPORT_core_disconnect(struct GNUNET_TRANSPORT_CoreHandle *handle)
Disconnect from the transport service.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_GETOPT_option_base32_auto(shortName, name, argumentHelp, description, val)
Allow user to specify a binary value using Crockford Base32 encoding where the size of the binary val...
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_verbose(unsigned int *level)
Define the '-V' verbosity option.
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.
void * GNUNET_CONTAINER_multipeermap_get(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Given a key find a value in the map matching the key.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
unsigned int GNUNET_CONTAINER_multipeermap_size(const struct GNUNET_CONTAINER_MultiPeerMap *map)
Get the number of key-value pairs in the map.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...
#define GNUNET_log(kind,...)
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * GNUNET_i2s_full(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
void GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Call a callback once the envelope has been sent, that is, sending it can not be canceled anymore.
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,...
#define GNUNET_MESSAGE_TYPE_DUMMY
Dummy messages for testing / benchmarking.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
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,...
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
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...
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Internal representation of the hash map.
Definition of a command line option.
Handle to a message queue.
Message handler for a specific message type.
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Time for absolute times used by GNUnet, in microseconds.
uint64_t abs_value_us
The actual value.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
Handle for the transport service (includes all of the state for the transport service).
Struct to store information about peers in monitor mode.
enum GNUNET_TRANSPORT_PeerState state
State of the peer.
struct GNUNET_TIME_Absolute state_timeout
Timeout.
struct GNUNET_HELLO_Address * address
The address to convert.
Context to store name resolutions for validation.
struct PeerResolutionContext * next
Next in DLL.
int printed
was the entry printed
struct GNUNET_HELLO_Address * addrcp
address to resolve
struct PeerResolutionContext * prev
Prev in DLL.
struct GNUNET_TIME_Absolute state_timeout
state timeout
enum GNUNET_TRANSPORT_PeerState state
peer state
struct GNUNET_TRANSPORT_AddressToStringContext * asc
transport conversiion context
char * transport
transport plugin
Context for address resolution by plugin_monitoring_cb().
char * str
Resolved address as string.
struct GNUNET_TRANSPORT_AddressToStringContext * asc
Ongoing resolution request.
struct GNUNET_TRANSPORT_SessionInfo si
Last event we got and did not yet print because str was NULL (address not yet resolved).
Context to store name resolutions for validation.
struct GNUNET_TIME_Absolute last_validation
Time of last validation.
struct GNUNET_TRANSPORT_AddressToStringContext * asc
Transport conversion handle.
struct ValidationResolutionContext * next
Next in DLL.
char * transport
plugin name
int printed
was the entry printed
struct GNUNET_TIME_Absolute valid_until
Address is valid until.
struct ValidationResolutionContext * prev
Previous in DLL.
struct GNUNET_HELLO_Address * addrcp
Address to resolve.
struct GNUNET_TIME_Absolute next_validation
Time of next validation.