aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-communicator-udp.c494
-rw-r--r--src/transport/gnunet-service-transport.c2
-rw-r--r--src/transport/plugin_transport_http_client.c15
-rw-r--r--src/transport/plugin_transport_http_common.c2
-rw-r--r--src/transport/plugin_transport_http_server.c24
-rw-r--r--src/transport/plugin_transport_tcp.c12
-rw-r--r--src/transport/plugin_transport_udp.c15
-rw-r--r--src/transport/plugin_transport_unix.c4
-rw-r--r--src/transport/tcp_connection_legacy.c16
-rw-r--r--src/transport/tcp_service_legacy.c2
-rw-r--r--src/transport/test_communicator_basic.c206
-rw-r--r--src/transport/transport-testing2.c7
12 files changed, 576 insertions, 223 deletions
diff --git a/src/transport/gnunet-communicator-udp.c b/src/transport/gnunet-communicator-udp.c
index 5ca5a4e86..e967e8e9a 100644
--- a/src/transport/gnunet-communicator-udp.c
+++ b/src/transport/gnunet-communicator-udp.c
@@ -75,6 +75,9 @@
75 */ 75 */
76#define ADDRESS_VALIDITY_PERIOD GNUNET_TIME_UNIT_HOURS 76#define ADDRESS_VALIDITY_PERIOD GNUNET_TIME_UNIT_HOURS
77 77
78#define WORKING_QUEUE_INTERVALL \
79 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS,1)
80
78/** 81/**
79 * AES key size. 82 * AES key size.
80 */ 83 */
@@ -90,6 +93,8 @@
90 */ 93 */
91#define GCM_TAG_SIZE (128 / 8) 94#define GCM_TAG_SIZE (128 / 8)
92 95
96#define GENERATE_AT_ONCE 2
97
93/** 98/**
94 * If we fall below this number of available KCNs, 99 * If we fall below this number of available KCNs,
95 * we generate additional ACKs until we reach 100 * we generate additional ACKs until we reach
@@ -129,7 +134,7 @@
129 * sense. Might make sense to adapt to RTT if we had 134 * sense. Might make sense to adapt to RTT if we had
130 * a good measurement... 135 * a good measurement...
131 */ 136 */
132#define MAX_SECRETS 128 137#define MAX_SECRETS 128000
133 138
134/** 139/**
135 * How often do we rekey based on number of bytes transmitted? 140 * How often do we rekey based on number of bytes transmitted?
@@ -251,6 +256,12 @@ struct UDPAck
251 uint32_t sequence_max GNUNET_PACKED; 256 uint32_t sequence_max GNUNET_PACKED;
252 257
253 /** 258 /**
259 * Sequence acknowledgement limit. Specifies current maximum sequence
260 * number supported by receiver.
261 */
262 uint32_t acks_available GNUNET_PACKED;
263
264 /**
254 * CMAC of the base key being acknowledged. 265 * CMAC of the base key being acknowledged.
255 */ 266 */
256 struct GNUNET_HashCode cmac; 267 struct GNUNET_HashCode cmac;
@@ -500,6 +511,12 @@ struct SenderAddress
500 unsigned int num_secrets; 511 unsigned int num_secrets;
501 512
502 /** 513 /**
514 * Number of BOX keys from ACKs we have currently
515 * available for this sender.
516 */
517 unsigned int acks_available;
518
519 /**
503 * Which network type does this queue use? 520 * Which network type does this queue use?
504 */ 521 */
505 enum GNUNET_NetworkType nt; 522 enum GNUNET_NetworkType nt;
@@ -653,6 +670,15 @@ struct BroadcastInterface
653 int found; 670 int found;
654}; 671};
655 672
673/**
674 * Timeout for this receiver address.
675 */
676struct GNUNET_TIME_Absolute *rekey_timeout;
677
678/**
679 * Shared secret we finished the last kce working queue for.
680 */
681struct SharedSecret *ss_finished;
656 682
657/** 683/**
658 * Cache of pre-generated key IDs. 684 * Cache of pre-generated key IDs.
@@ -670,6 +696,16 @@ static struct GNUNET_SCHEDULER_Task *read_task;
670static struct GNUNET_SCHEDULER_Task *timeout_task; 696static struct GNUNET_SCHEDULER_Task *timeout_task;
671 697
672/** 698/**
699 * ID of kce working queue task
700 */
701static struct GNUNET_SCHEDULER_Task *kce_task;
702
703/**
704 * Is the kce_task finished?
705 */
706static int kce_task_finished = GNUNET_NO;
707
708/**
673 * ID of master broadcast task 709 * ID of master broadcast task
674 */ 710 */
675static struct GNUNET_SCHEDULER_Task *broadcast_task; 711static struct GNUNET_SCHEDULER_Task *broadcast_task;
@@ -847,6 +883,7 @@ kce_destroy (struct KeyCacheEntry *kce)
847 struct SharedSecret *ss = kce->ss; 883 struct SharedSecret *ss = kce->ss;
848 884
849 ss->active_kce_count--; 885 ss->active_kce_count--;
886 ss->sender->acks_available--;
850 GNUNET_CONTAINER_DLL_remove (ss->kce_head, ss->kce_tail, kce); 887 GNUNET_CONTAINER_DLL_remove (ss->kce_head, ss->kce_tail, kce);
851 GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multishortmap_remove (key_cache, 888 GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multishortmap_remove (key_cache,
852 &kce->kid, 889 &kce->kid,
@@ -902,6 +939,7 @@ kce_generate (struct SharedSecret *ss, uint32_t seq)
902 get_kid (&ss->master, seq, &kce->kid); 939 get_kid (&ss->master, seq, &kce->kid);
903 GNUNET_CONTAINER_DLL_insert (ss->kce_head, ss->kce_tail, kce); 940 GNUNET_CONTAINER_DLL_insert (ss->kce_head, ss->kce_tail, kce);
904 ss->active_kce_count++; 941 ss->active_kce_count++;
942 ss->sender->acks_available++;
905 (void) GNUNET_CONTAINER_multishortmap_put ( 943 (void) GNUNET_CONTAINER_multishortmap_put (
906 key_cache, 944 key_cache,
907 &kce->kid, 945 &kce->kid,
@@ -920,12 +958,20 @@ kce_generate (struct SharedSecret *ss, uint32_t seq)
920 * @param ss shared secret to destroy 958 * @param ss shared secret to destroy
921 */ 959 */
922static void 960static void
923secret_destroy (struct SharedSecret *ss) 961secret_destroy (struct SharedSecret *ss, int withoutKce)
924{ 962{
925 struct SenderAddress *sender; 963 struct SenderAddress *sender;
926 struct ReceiverAddress *receiver; 964 struct ReceiverAddress *receiver;
927 struct KeyCacheEntry *kce; 965 struct KeyCacheEntry *kce;
928 966
967 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
968 "secret destroy %u %u\n",
969 withoutKce,
970 ss->sequence_allowed);
971
972 if (withoutKce && (ss->sequence_allowed > 0))
973 return;
974
929 if (NULL != (sender = ss->sender)) 975 if (NULL != (sender = ss->sender))
930 { 976 {
931 GNUNET_CONTAINER_DLL_remove (sender->ss_head, sender->ss_tail, ss); 977 GNUNET_CONTAINER_DLL_remove (sender->ss_head, sender->ss_tail, ss);
@@ -935,7 +981,9 @@ secret_destroy (struct SharedSecret *ss)
935 { 981 {
936 GNUNET_CONTAINER_DLL_remove (receiver->ss_head, receiver->ss_tail, ss); 982 GNUNET_CONTAINER_DLL_remove (receiver->ss_head, receiver->ss_tail, ss);
937 receiver->num_secrets--; 983 receiver->num_secrets--;
984 // Uncomment this for alternativ 1 of backchannel functionality
938 receiver->acks_available -= (ss->sequence_allowed - ss->sequence_used); 985 receiver->acks_available -= (ss->sequence_allowed - ss->sequence_used);
986 // Until here for alternativ 1
939 } 987 }
940 while (NULL != (kce = ss->kce_head)) 988 while (NULL != (kce = ss->kce_head))
941 kce_destroy (kce); 989 kce_destroy (kce);
@@ -1284,8 +1332,11 @@ handle_ack (void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
1284{ 1332{
1285 const struct UDPAck *ack = cls; 1333 const struct UDPAck *ack = cls;
1286 struct ReceiverAddress *receiver = value; 1334 struct ReceiverAddress *receiver = value;
1335 struct SharedSecret *pos;
1336
1287 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1337 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1288 "in handle ack\n"); 1338 "in handle ack\n");
1339 struct SharedSecret *ss_to_destroy;
1289 1340
1290 (void) pid; 1341 (void) pid;
1291 for (struct SharedSecret *ss = receiver->ss_head; NULL != ss; ss = ss->next) 1342 for (struct SharedSecret *ss = receiver->ss_head; NULL != ss; ss = ss->next)
@@ -1301,9 +1352,12 @@ handle_ack (void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
1301 if (allowed > ss->sequence_allowed) 1352 if (allowed > ss->sequence_allowed)
1302 { 1353 {
1303 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1354 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1304 "%u > %u (%u)\n", allowed, ss->sequence_allowed, 1355 "%u > %u (%u %u) for secrect %s\n", allowed,
1305 receiver->acks_available); 1356 ss->sequence_allowed,
1306 1357 receiver->acks_available,
1358 ack->acks_available,
1359 GNUNET_h2s (&ss->master));
1360 // Uncomment this for alternativ 1 of backchannel functionality
1307 receiver->acks_available += (allowed - ss->sequence_allowed); 1361 receiver->acks_available += (allowed - ss->sequence_allowed);
1308 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1362 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1309 "Tell transport we have more acks!\n"); 1363 "Tell transport we have more acks!\n");
@@ -1312,11 +1366,33 @@ handle_ack (void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
1312 (allowed 1366 (allowed
1313 - ss->sequence_allowed), 1367 - ss->sequence_allowed),
1314 1); 1368 1);
1369 // Until here for alternativ 1
1315 ss->sequence_allowed = allowed; 1370 ss->sequence_allowed = allowed;
1316 /* move ss to head to avoid discarding it anytime soon! */ 1371 /* move ss to head to avoid discarding it anytime soon! */
1317 GNUNET_CONTAINER_DLL_remove (receiver->ss_head, receiver->ss_tail, ss); 1372 GNUNET_CONTAINER_DLL_remove (receiver->ss_head, receiver->ss_tail, ss);
1318 GNUNET_CONTAINER_DLL_insert (receiver->ss_head, receiver->ss_tail, ss); 1373 GNUNET_CONTAINER_DLL_insert (receiver->ss_head, receiver->ss_tail, ss);
1374 pos = receiver->ss_head;
1375 while ( NULL != pos)
1376 {
1377 ss_to_destroy = pos;
1378 pos = pos->next;
1379
1380 secret_destroy (ss_to_destroy, GNUNET_YES);
1381 }
1319 } 1382 }
1383
1384 // Uncomment this for alternativ 2 of backchannel functionality
1385 /*if (receiver->acks_available != ack->acks_available)
1386 {
1387 receiver->acks_available = ack->acks_available;
1388 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1389 "Tell transport we have different number of acks!\n");
1390 GNUNET_TRANSPORT_communicator_mq_update (ch,
1391 receiver->d_qh,
1392 receiver->acks_available,
1393 1);
1394 }*/
1395 // Until here for alternativ 2
1320 return GNUNET_NO; 1396 return GNUNET_NO;
1321 } 1397 }
1322 } 1398 }
@@ -1370,6 +1446,36 @@ try_handle_plaintext (struct SenderAddress *sender,
1370 } 1446 }
1371} 1447}
1372 1448
1449static void
1450kce_generate_cb (void *cls)
1451{
1452 struct SharedSecret *ss = cls;
1453
1454
1455
1456 if (ss->sender->acks_available < KCN_TARGET)
1457 {
1458
1459 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1460 "Precomputing keys\n");
1461
1462 for (int i = 0; i < GENERATE_AT_ONCE; i++)
1463 kce_generate (ss, ++ss->sequence_allowed);
1464
1465 kce_task = GNUNET_SCHEDULER_add_delayed (WORKING_QUEUE_INTERVALL,
1466 kce_generate_cb,
1467 ss);
1468 }
1469 else
1470 {
1471 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1472 "We have enough keys.\n");
1473 ss_finished = ss;
1474 kce_task_finished = GNUNET_YES;
1475 }
1476
1477
1478}
1373 1479
1374/** 1480/**
1375 * We established a shared secret with a sender. We should try to send 1481 * We established a shared secret with a sender. We should try to send
@@ -1378,21 +1484,81 @@ try_handle_plaintext (struct SenderAddress *sender,
1378 * recently). 1484 * recently).
1379 * 1485 *
1380 * @param ss shared secret to generate ACKs for 1486 * @param ss shared secret to generate ACKs for
1487 * @param intial The SharedSecret came with initial KX.
1381 */ 1488 */
1382static void 1489static void
1383consider_ss_ack (struct SharedSecret *ss) 1490consider_ss_ack (struct SharedSecret *ss, int initial)
1384{ 1491{
1492 struct SharedSecret *ss_to_destroy;
1493 struct SharedSecret *pos;
1494
1385 GNUNET_assert (NULL != ss->sender); 1495 GNUNET_assert (NULL != ss->sender);
1386 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1496 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1387 "Considering SS UDPAck %s\n", 1497 "Considering SS UDPAck %s\n",
1388 GNUNET_i2s_full (&ss->sender->target)); 1498 GNUNET_i2s_full (&ss->sender->target));
1389 1499
1500 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1501 "We have %u acks available.\n",
1502 ss->sender->acks_available);
1390 /* drop ancient KeyCacheEntries */ 1503 /* drop ancient KeyCacheEntries */
1391 while ((NULL != ss->kce_head) && 1504 while ((NULL != ss->kce_head) &&
1392 (MAX_SQN_DELTA < 1505 (MAX_SQN_DELTA <
1393 ss->kce_head->sequence_number - ss->kce_tail->sequence_number)) 1506 ss->kce_head->sequence_number - ss->kce_tail->sequence_number))
1394 kce_destroy (ss->kce_tail); 1507 kce_destroy (ss->kce_tail);
1395 if (ss->active_kce_count < KCN_THRESHOLD) 1508
1509
1510 if (GNUNET_NO == initial)
1511 kce_generate (ss, ++ss->sequence_allowed);
1512
1513 /*if (0 == ss->sender->acks_available)
1514 {
1515 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1516 "Generating keys\n");
1517 while (ss->active_kce_count < KCN_TARGET)
1518 kce_generate (ss, ++ss->sequence_allowed);
1519 }*/
1520
1521 if (((NULL != kce_task) && kce_task_finished) || (GNUNET_NO == initial))
1522 {
1523 struct UDPAck ack;
1524
1525 ack.header.type = htons (GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_ACK);
1526 ack.header.size = htons (sizeof(ack));
1527 ack.sequence_max = htonl (ss_finished->sequence_allowed);
1528 ack.acks_available = ss->sender->acks_available;
1529 ack.cmac = ss_finished->cmac;
1530 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1531 "Notifying transport of UDPAck %s with intial %u\n",
1532 GNUNET_i2s_full (&ss_finished->sender->target),
1533 initial);
1534 GNUNET_TRANSPORT_communicator_notify (ch,
1535 &ss_finished->sender->target,
1536 COMMUNICATOR_ADDRESS_PREFIX,
1537 &ack.header);
1538 pos = ss->sender->ss_head;
1539 while ( NULL != pos)
1540 {
1541 ss_to_destroy = pos;
1542 pos = pos->next;
1543 secret_destroy (ss_to_destroy, GNUNET_YES);
1544 }
1545 kce_task = NULL;
1546 }
1547 else if (((NULL == kce_task) && (KCN_THRESHOLD >
1548 ss->sender->acks_available)) ||
1549 (ss->sender->num_secrets > MAX_SECRETS) )
1550 {
1551
1552 // kce_generate (ss, ++ss->sequence_allowed);
1553 // kce_generate (ss, ++ss->sequence_allowed);
1554 kce_task = GNUNET_SCHEDULER_add_delayed (WORKING_QUEUE_INTERVALL,
1555 kce_generate_cb,
1556 ss);
1557
1558 }
1559
1560
1561 /*if (ss->active_kce_count < KCN_THRESHOLD)
1396 { 1562 {
1397 struct UDPAck ack; 1563 struct UDPAck ack;
1398 1564
@@ -1402,11 +1568,13 @@ consider_ss_ack (struct SharedSecret *ss)
1402 * For the initial KX (active_kce_count==0), 1568 * For the initial KX (active_kce_count==0),
1403 * we only generate a single KCE to prevent 1569 * we only generate a single KCE to prevent
1404 * unnecessary overhead. 1570 * unnecessary overhead.
1405 */ 1571
1406 if (0 < ss->active_kce_count) { 1572 if (0 < ss->active_kce_count)
1573 {
1407 while (ss->active_kce_count < KCN_TARGET) 1574 while (ss->active_kce_count < KCN_TARGET)
1408 kce_generate (ss, ++ss->sequence_allowed); 1575 kce_generate (ss, ++ss->sequence_allowed);
1409 } else { 1576 }
1577 else {
1410 kce_generate (ss, ++ss->sequence_allowed); 1578 kce_generate (ss, ++ss->sequence_allowed);
1411 } 1579 }
1412 ack.header.type = htons (GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_ACK); 1580 ack.header.type = htons (GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_ACK);
@@ -1420,7 +1588,7 @@ consider_ss_ack (struct SharedSecret *ss)
1420 &ss->sender->target, 1588 &ss->sender->target,
1421 COMMUNICATOR_ADDRESS_PREFIX, 1589 COMMUNICATOR_ADDRESS_PREFIX,
1422 &ack.header); 1590 &ack.header);
1423 } 1591 }*/
1424} 1592}
1425 1593
1426 1594
@@ -1459,8 +1627,11 @@ decrypt_box (const struct UDPBox *box,
1459 "# bytes decrypted with BOX", 1627 "# bytes decrypted with BOX",
1460 sizeof(out_buf), 1628 sizeof(out_buf),
1461 GNUNET_NO); 1629 GNUNET_NO);
1630 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1631 "decrypted UDPBox with kid %s\n",
1632 GNUNET_sh2s (&box->kid));
1462 try_handle_plaintext (ss->sender, out_buf, sizeof(out_buf)); 1633 try_handle_plaintext (ss->sender, out_buf, sizeof(out_buf));
1463 consider_ss_ack (ss); 1634 consider_ss_ack (ss, GNUNET_NO);
1464} 1635}
1465 1636
1466 1637
@@ -1530,8 +1701,8 @@ setup_sender (const struct GNUNET_PeerIdentity *target,
1530{ 1701{
1531 struct SenderAddress *sender; 1702 struct SenderAddress *sender;
1532 struct SearchContext sc = { .address = address, 1703 struct SearchContext sc = { .address = address,
1533 .address_len = address_len, 1704 .address_len = address_len,
1534 .sender = NULL }; 1705 .sender = NULL };
1535 1706
1536 GNUNET_CONTAINER_multipeermap_get_multiple (senders, 1707 GNUNET_CONTAINER_multipeermap_get_multiple (senders,
1537 target, 1708 target,
@@ -1547,10 +1718,10 @@ setup_sender (const struct GNUNET_PeerIdentity *target,
1547 sender->address = GNUNET_memdup (address, address_len); 1718 sender->address = GNUNET_memdup (address, address_len);
1548 sender->address_len = address_len; 1719 sender->address_len = address_len;
1549 (void) GNUNET_CONTAINER_multipeermap_put ( 1720 (void) GNUNET_CONTAINER_multipeermap_put (
1550 senders, 1721 senders,
1551 &sender->target, 1722 &sender->target,
1552 sender, 1723 sender,
1553 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 1724 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
1554 GNUNET_STATISTICS_set (stats, 1725 GNUNET_STATISTICS_set (stats,
1555 "# senders active", 1726 "# senders active",
1556 GNUNET_CONTAINER_multipeermap_size (receivers), 1727 GNUNET_CONTAINER_multipeermap_size (receivers),
@@ -1587,10 +1758,10 @@ verify_confirmation (const struct GNUNET_CRYPTO_EcdhePublicKey *ephemeral,
1587 uhs.ephemeral = *ephemeral; 1758 uhs.ephemeral = *ephemeral;
1588 uhs.monotonic_time = uc->monotonic_time; 1759 uhs.monotonic_time = uc->monotonic_time;
1589 return GNUNET_CRYPTO_eddsa_verify ( 1760 return GNUNET_CRYPTO_eddsa_verify (
1590 GNUNET_SIGNATURE_COMMUNICATOR_UDP_HANDSHAKE, 1761 GNUNET_SIGNATURE_COMMUNICATOR_UDP_HANDSHAKE,
1591 &uhs, 1762 &uhs,
1592 &uc->sender_sig, 1763 &uc->sender_sig,
1593 &uc->sender.public_key); 1764 &uc->sender.public_key);
1594} 1765}
1595 1766
1596 1767
@@ -1610,22 +1781,22 @@ sockaddr_to_udpaddr_string (const struct sockaddr *address,
1610 1781
1611 switch (address->sa_family) 1782 switch (address->sa_family)
1612 { 1783 {
1613 case AF_INET: 1784 case AF_INET:
1614 GNUNET_asprintf (&ret, 1785 GNUNET_asprintf (&ret,
1615 "%s-%s", 1786 "%s-%s",
1616 COMMUNICATOR_ADDRESS_PREFIX, 1787 COMMUNICATOR_ADDRESS_PREFIX,
1617 GNUNET_a2s (address, address_len)); 1788 GNUNET_a2s (address, address_len));
1618 break; 1789 break;
1619 1790
1620 case AF_INET6: 1791 case AF_INET6:
1621 GNUNET_asprintf (&ret, 1792 GNUNET_asprintf (&ret,
1622 "%s-%s", 1793 "%s-%s",
1623 COMMUNICATOR_ADDRESS_PREFIX, 1794 COMMUNICATOR_ADDRESS_PREFIX,
1624 GNUNET_a2s (address, address_len)); 1795 GNUNET_a2s (address, address_len));
1625 break; 1796 break;
1626 1797
1627 default: 1798 default:
1628 GNUNET_assert (0); 1799 GNUNET_assert (0);
1629 } 1800 }
1630 return ret; 1801 return ret;
1631} 1802}
@@ -1744,10 +1915,10 @@ sock_read (void *cls)
1744 "Unable to decrypt tag, dropping...\n"); 1915 "Unable to decrypt tag, dropping...\n");
1745 GNUNET_free (ss); 1916 GNUNET_free (ss);
1746 GNUNET_STATISTICS_update ( 1917 GNUNET_STATISTICS_update (
1747 stats, 1918 stats,
1748 "# messages dropped (no kid, AEAD decryption failed)", 1919 "# messages dropped (no kid, AEAD decryption failed)",
1749 1, 1920 1,
1750 GNUNET_NO); 1921 GNUNET_NO);
1751 return; 1922 return;
1752 } 1923 }
1753 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1924 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1778,9 +1949,9 @@ sock_read (void *cls)
1778 1, 1949 1,
1779 GNUNET_NO); 1950 GNUNET_NO);
1780 try_handle_plaintext (sender, &uc[1], sizeof(pbuf) - sizeof(*uc)); 1951 try_handle_plaintext (sender, &uc[1], sizeof(pbuf) - sizeof(*uc));
1781 consider_ss_ack (ss); 1952 consider_ss_ack (ss, GNUNET_YES);
1782 if (sender->num_secrets > MAX_SECRETS) 1953 /*if (sender->num_secrets > MAX_SECRETS)
1783 secret_destroy (sender->ss_tail); 1954 secret_destroy (sender->ss_tail);*/
1784 } 1955 }
1785} 1956}
1786 1957
@@ -1859,9 +2030,9 @@ udp_address_to_sockaddr (const char *bindto, socklen_t *sock_len)
1859 else 2030 else
1860 { 2031 {
1861 GNUNET_log ( 2032 GNUNET_log (
1862 GNUNET_ERROR_TYPE_ERROR, 2033 GNUNET_ERROR_TYPE_ERROR,
1863 "BINDTO specification `%s' invalid: last ':' not followed by number\n", 2034 "BINDTO specification `%s' invalid: last ':' not followed by number\n",
1864 bindto); 2035 bindto);
1865 GNUNET_free (cp); 2036 GNUNET_free (cp);
1866 return NULL; 2037 return NULL;
1867 } 2038 }
@@ -1939,8 +2110,8 @@ do_pad (gcry_cipher_hd_t out_cipher, char *dgram, size_t pad_size)
1939 memcpy (pad, &hdr, sizeof(hdr)); 2110 memcpy (pad, &hdr, sizeof(hdr));
1940 } 2111 }
1941 GNUNET_assert ( 2112 GNUNET_assert (
1942 0 == 2113 0 ==
1943 gcry_cipher_encrypt (out_cipher, dgram, sizeof(pad), pad, sizeof(pad))); 2114 gcry_cipher_encrypt (out_cipher, dgram, sizeof(pad), pad, sizeof(pad)));
1944} 2115}
1945 2116
1946 2117
@@ -1967,6 +2138,19 @@ mq_send_kx (struct GNUNET_MQ_Handle *mq,
1967 size_t dpos; 2138 size_t dpos;
1968 gcry_cipher_hd_t out_cipher; 2139 gcry_cipher_hd_t out_cipher;
1969 struct SharedSecret *ss; 2140 struct SharedSecret *ss;
2141 struct SharedSecret *ss_to_destroy;
2142 struct SharedSecret *pos;
2143
2144 if (receiver->num_secrets > MAX_SECRETS)
2145 {
2146 pos = receiver->ss_head;
2147 while ( NULL != pos)
2148 {
2149 ss_to_destroy = pos;
2150 pos = pos->next;
2151 secret_destroy (ss_to_destroy, GNUNET_YES);
2152 }
2153 }
1970 2154
1971 2155
1972 GNUNET_assert (mq == receiver->kx_mq); 2156 GNUNET_assert (mq == receiver->kx_mq);
@@ -2007,13 +2191,13 @@ mq_send_kx (struct GNUNET_MQ_Handle *mq,
2007 dpos += sizeof(uc); 2191 dpos += sizeof(uc);
2008 /* Append encrypted payload to dgram */ 2192 /* Append encrypted payload to dgram */
2009 GNUNET_assert ( 2193 GNUNET_assert (
2010 0 == gcry_cipher_encrypt (out_cipher, &dgram[dpos], msize, msg, msize)); 2194 0 == gcry_cipher_encrypt (out_cipher, &dgram[dpos], msize, msg, msize));
2011 dpos += msize; 2195 dpos += msize;
2012 do_pad (out_cipher, &dgram[dpos], sizeof(dgram) - dpos); 2196 do_pad (out_cipher, &dgram[dpos], sizeof(dgram) - dpos);
2013 /* Datagram starts with kx */ 2197 /* Datagram starts with kx */
2014 kx.ephemeral = uhs.ephemeral; 2198 kx.ephemeral = uhs.ephemeral;
2015 GNUNET_assert ( 2199 GNUNET_assert (
2016 0 == gcry_cipher_gettag (out_cipher, kx.gcm_tag, sizeof(kx.gcm_tag))); 2200 0 == gcry_cipher_gettag (out_cipher, kx.gcm_tag, sizeof(kx.gcm_tag)));
2017 gcry_cipher_close (out_cipher); 2201 gcry_cipher_close (out_cipher);
2018 memcpy (dgram, &kx, sizeof(kx)); 2202 memcpy (dgram, &kx, sizeof(kx));
2019 if (-1 == GNUNET_NETWORK_socket_sendto (udp_sock, 2203 if (-1 == GNUNET_NETWORK_socket_sendto (udp_sock,
@@ -2044,6 +2228,8 @@ mq_send_d (struct GNUNET_MQ_Handle *mq,
2044{ 2228{
2045 struct ReceiverAddress *receiver = impl_state; 2229 struct ReceiverAddress *receiver = impl_state;
2046 uint16_t msize = ntohs (msg->size); 2230 uint16_t msize = ntohs (msg->size);
2231 struct GNUNET_TIME_Relative rt;
2232 struct SharedSecret *pos;
2047 2233
2048 GNUNET_assert (mq == receiver->d_mq); 2234 GNUNET_assert (mq == receiver->d_mq);
2049 if ((msize > receiver->d_mtu) || 2235 if ((msize > receiver->d_mtu) ||
@@ -2058,7 +2244,18 @@ mq_send_d (struct GNUNET_MQ_Handle *mq,
2058 /* begin "BOX" encryption method, scan for ACKs from tail! */ 2244 /* begin "BOX" encryption method, scan for ACKs from tail! */
2059 for (struct SharedSecret *ss = receiver->ss_tail; NULL != ss; ss = ss->prev) 2245 for (struct SharedSecret *ss = receiver->ss_tail; NULL != ss; ss = ss->prev)
2060 { 2246 {
2247 if (0 < ss->sequence_used)
2248 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2249 "Trying to send UDPBox with shared secrect %s sequence_used %u and ss->sequence_allowed %u\n",
2250 GNUNET_h2s (&ss->master),
2251 ss->sequence_used,
2252 ss->sequence_allowed);
2253 // Uncomment this for alternativ 1 of backchannel functionality
2061 if (ss->sequence_used >= ss->sequence_allowed) 2254 if (ss->sequence_used >= ss->sequence_allowed)
2255 // Until here for alternativ 1
2256 // Uncomment this for alternativ 2 of backchannel functionality
2257 // if (0 == ss->sequence_allowed)
2258 // Until here for alternativ 2
2062 { 2259 {
2063 continue; 2260 continue;
2064 } 2261 }
@@ -2074,7 +2271,7 @@ mq_send_d (struct GNUNET_MQ_Handle *mq,
2074 /* Append encrypted payload to dgram */ 2271 /* Append encrypted payload to dgram */
2075 dpos = sizeof(struct UDPBox); 2272 dpos = sizeof(struct UDPBox);
2076 GNUNET_assert ( 2273 GNUNET_assert (
2077 0 == gcry_cipher_encrypt (out_cipher, &dgram[dpos], msize, msg, msize)); 2274 0 == gcry_cipher_encrypt (out_cipher, &dgram[dpos], msize, msg, msize));
2078 dpos += msize; 2275 dpos += msize;
2079 do_pad (out_cipher, &dgram[dpos], sizeof(dgram) - dpos); 2276 do_pad (out_cipher, &dgram[dpos], sizeof(dgram) - dpos);
2080 GNUNET_assert (0 == gcry_cipher_gettag (out_cipher, 2277 GNUNET_assert (0 == gcry_cipher_gettag (out_cipher,
@@ -2087,14 +2284,43 @@ mq_send_d (struct GNUNET_MQ_Handle *mq,
2087 receiver->address, 2284 receiver->address,
2088 receiver->address_len)) 2285 receiver->address_len))
2089 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "send"); 2286 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "send");
2287 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2288 "Sending UDPBox to %s\n", GNUNET_a2s (receiver->address,
2289 receiver->address_len));
2090 GNUNET_MQ_impl_send_continue (mq); 2290 GNUNET_MQ_impl_send_continue (mq);
2091 receiver->acks_available--; 2291 // receiver->acks_available--;
2092 if (0 == receiver->acks_available) 2292 if (0 == receiver->acks_available)
2093 { 2293 {
2094 /* We have no more ACKs */ 2294 /* We have no more ACKs */
2095 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2295 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2096 "No more acks\n"); 2296 "No more acks\n");
2097 } 2297 }
2298
2299 /* (NULL == rekey_timeout)
2300 rekey_timeout = GNUNET_TIME_relative_to_absolute (REKEY_TIME_INTERVAL);
2301 else
2302 {
2303 rt = GNUNET_TIME_absolute_get_remaining (rekey_timeout);
2304 if (0 == rt.rel_value_us)
2305 {
2306 rekey_timeout = NULL;
2307 pos = receiver->ss_head;
2308 while ( NULL != pos)
2309 {
2310 ss_to_destroy = pos;
2311 pos = pos->next;
2312 secret_destroy (ss_to_destroy, GNUNET_NO);
2313 }
2314 if (0 != receiver->acks_available)
2315 GNUNET_TRANSPORT_communicator_mq_update (ch,
2316 receiver->d_qh,
2317 // TODO We can not do this. But how can we signal this queue is not able to handle a message. Test code interprets q-len as additional length.
2318 -receiver->acks_available,
2319 1);
2320 }
2321 }*/
2322
2323
2098 return; 2324 return;
2099 } 2325 }
2100} 2326}
@@ -2205,25 +2431,25 @@ setup_receiver_mq (struct ReceiverAddress *receiver)
2205 // GNUNET_assert (NULL == receiver->mq); 2431 // GNUNET_assert (NULL == receiver->mq);
2206 switch (receiver->address->sa_family) 2432 switch (receiver->address->sa_family)
2207 { 2433 {
2208 case AF_INET: 2434 case AF_INET:
2209 base_mtu = 1480 /* Ethernet MTU, 1500 - Ethernet header - VLAN tag */ 2435 base_mtu = 1480 /* Ethernet MTU, 1500 - Ethernet header - VLAN tag */
2210 - sizeof(struct GNUNET_TUN_IPv4Header) /* 20 */ 2436 - sizeof(struct GNUNET_TUN_IPv4Header) /* 20 */
2211 - sizeof(struct GNUNET_TUN_UdpHeader) /* 8 */; 2437 - sizeof(struct GNUNET_TUN_UdpHeader) /* 8 */;
2212 break; 2438 break;
2213 2439
2214 case AF_INET6: 2440 case AF_INET6:
2215 base_mtu = 1280 /* Minimum MTU required by IPv6 */ 2441 base_mtu = 1280 /* Minimum MTU required by IPv6 */
2216 - sizeof(struct GNUNET_TUN_IPv6Header) /* 40 */ 2442 - sizeof(struct GNUNET_TUN_IPv6Header) /* 40 */
2217 - sizeof(struct GNUNET_TUN_UdpHeader) /* 8 */; 2443 - sizeof(struct GNUNET_TUN_UdpHeader) /* 8 */;
2218 break; 2444 break;
2219 2445
2220 default: 2446 default:
2221 GNUNET_assert (0); 2447 GNUNET_assert (0);
2222 break; 2448 break;
2223 } 2449 }
2224 /* MTU based on full KX messages */ 2450 /* MTU based on full KX messages */
2225 receiver->kx_mtu = base_mtu - sizeof(struct InitialKX) /* 48 */ 2451 receiver->kx_mtu = base_mtu - sizeof(struct InitialKX) /* 48 */
2226 - sizeof(struct UDPConfirmation); /* 104 */ 2452 - sizeof(struct UDPConfirmation); /* 104 */
2227 /* MTU based on BOXed messages */ 2453 /* MTU based on BOXed messages */
2228 receiver->d_mtu = base_mtu - sizeof(struct UDPBox); 2454 receiver->d_mtu = base_mtu - sizeof(struct UDPBox);
2229 2455
@@ -2314,10 +2540,10 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address)
2314 receiver->target = *peer; 2540 receiver->target = *peer;
2315 receiver->nt = GNUNET_NT_scanner_get_type (is, in, in_len); 2541 receiver->nt = GNUNET_NT_scanner_get_type (is, in, in_len);
2316 (void) GNUNET_CONTAINER_multipeermap_put ( 2542 (void) GNUNET_CONTAINER_multipeermap_put (
2317 receivers, 2543 receivers,
2318 &receiver->target, 2544 &receiver->target,
2319 receiver, 2545 receiver,
2320 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 2546 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
2321 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2547 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2322 "Added %s to receivers\n", 2548 "Added %s to receivers\n",
2323 GNUNET_i2s_full (&receiver->target)); 2549 GNUNET_i2s_full (&receiver->target));
@@ -2553,55 +2779,55 @@ ifc_broadcast (void *cls)
2553 2779
2554 switch (bi->sa->sa_family) 2780 switch (bi->sa->sa_family)
2555 { 2781 {
2556 case AF_INET: { 2782 case AF_INET: {
2557 static int yes = 1; 2783 static int yes = 1;
2558 static int no = 0; 2784 static int no = 0;
2559 ssize_t sent; 2785 ssize_t sent;
2560 2786
2561 if (GNUNET_OK != GNUNET_NETWORK_socket_setsockopt (udp_sock, 2787 if (GNUNET_OK != GNUNET_NETWORK_socket_setsockopt (udp_sock,
2562 SOL_SOCKET, 2788 SOL_SOCKET,
2563 SO_BROADCAST, 2789 SO_BROADCAST,
2564 &yes, 2790 &yes,
2565 sizeof(int))) 2791 sizeof(int)))
2566 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "setsockopt"); 2792 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "setsockopt");
2567 sent = GNUNET_NETWORK_socket_sendto (udp_sock, 2793 sent = GNUNET_NETWORK_socket_sendto (udp_sock,
2568 &bi->bcm, 2794 &bi->bcm,
2569 sizeof(bi->bcm), 2795 sizeof(bi->bcm),
2570 bi->ba, 2796 bi->ba,
2571 bi->salen); 2797 bi->salen);
2572 if (-1 == sent) 2798 if (-1 == sent)
2573 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "sendto"); 2799 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "sendto");
2574 if (GNUNET_OK != GNUNET_NETWORK_socket_setsockopt (udp_sock, 2800 if (GNUNET_OK != GNUNET_NETWORK_socket_setsockopt (udp_sock,
2575 SOL_SOCKET, 2801 SOL_SOCKET,
2576 SO_BROADCAST, 2802 SO_BROADCAST,
2577 &no, 2803 &no,
2578 sizeof(int))) 2804 sizeof(int)))
2579 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "setsockopt"); 2805 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "setsockopt");
2580 break; 2806 break;
2581 } 2807 }
2582 2808
2583 case AF_INET6: { 2809 case AF_INET6: {
2584 ssize_t sent; 2810 ssize_t sent;
2585 struct sockaddr_in6 dst; 2811 struct sockaddr_in6 dst;
2586 2812
2587 dst.sin6_family = AF_INET6; 2813 dst.sin6_family = AF_INET6;
2588 dst.sin6_port = htons (my_port); 2814 dst.sin6_port = htons (my_port);
2589 dst.sin6_addr = bi->mcreq.ipv6mr_multiaddr; 2815 dst.sin6_addr = bi->mcreq.ipv6mr_multiaddr;
2590 dst.sin6_scope_id = ((struct sockaddr_in6 *) bi->ba)->sin6_scope_id; 2816 dst.sin6_scope_id = ((struct sockaddr_in6 *) bi->ba)->sin6_scope_id;
2591 2817
2592 sent = GNUNET_NETWORK_socket_sendto (udp_sock, 2818 sent = GNUNET_NETWORK_socket_sendto (udp_sock,
2593 &bi->bcm, 2819 &bi->bcm,
2594 sizeof(bi->bcm), 2820 sizeof(bi->bcm),
2595 (const struct sockaddr *) &dst, 2821 (const struct sockaddr *) &dst,
2596 sizeof(dst)); 2822 sizeof(dst));
2597 if (-1 == sent) 2823 if (-1 == sent)
2598 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "sendto"); 2824 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "sendto");
2599 break; 2825 break;
2600 } 2826 }
2601 2827
2602 default: 2828 default:
2603 GNUNET_break (0); 2829 GNUNET_break (0);
2604 break; 2830 break;
2605 } 2831 }
2606} 2832}
2607 2833
@@ -2683,7 +2909,7 @@ iface_proc (void *cls,
2683 (const struct sockaddr_in6 *) broadcast_addr; 2909 (const struct sockaddr_in6 *) broadcast_addr;
2684 2910
2685 GNUNET_assert ( 2911 GNUNET_assert (
2686 1 == inet_pton (AF_INET6, "FF05::13B", &bi->mcreq.ipv6mr_multiaddr)); 2912 1 == inet_pton (AF_INET6, "FF05::13B", &bi->mcreq.ipv6mr_multiaddr));
2687 2913
2688 /* http://tools.ietf.org/html/rfc2553#section-5.2: 2914 /* http://tools.ietf.org/html/rfc2553#section-5.2:
2689 * 2915 *
@@ -2820,17 +3046,17 @@ run (void *cls,
2820 GNUNET_a2s ((const struct sockaddr *) &in_sto, sto_len)); 3046 GNUNET_a2s ((const struct sockaddr *) &in_sto, sto_len));
2821 switch (in->sa_family) 3047 switch (in->sa_family)
2822 { 3048 {
2823 case AF_INET: 3049 case AF_INET:
2824 my_port = ntohs (((struct sockaddr_in *) in)->sin_port); 3050 my_port = ntohs (((struct sockaddr_in *) in)->sin_port);
2825 break; 3051 break;
2826 3052
2827 case AF_INET6: 3053 case AF_INET6:
2828 my_port = ntohs (((struct sockaddr_in6 *) in)->sin6_port); 3054 my_port = ntohs (((struct sockaddr_in6 *) in)->sin6_port);
2829 break; 3055 break;
2830 3056
2831 default: 3057 default:
2832 GNUNET_break (0); 3058 GNUNET_break (0);
2833 my_port = 0; 3059 my_port = 0;
2834 } 3060 }
2835 stats = GNUNET_STATISTICS_create ("C-UDP", cfg); 3061 stats = GNUNET_STATISTICS_create ("C-UDP", cfg);
2836 senders = GNUNET_CONTAINER_multipeermap_create (32, GNUNET_YES); 3062 senders = GNUNET_CONTAINER_multipeermap_create (32, GNUNET_YES);
@@ -2845,9 +3071,9 @@ run (void *cls,
2845 if (NULL == my_private_key) 3071 if (NULL == my_private_key)
2846 { 3072 {
2847 GNUNET_log ( 3073 GNUNET_log (
2848 GNUNET_ERROR_TYPE_ERROR, 3074 GNUNET_ERROR_TYPE_ERROR,
2849 _ ( 3075 _ (
2850 "Transport service is lacking key configuration settings. Exiting.\n")); 3076 "Transport service is lacking key configuration settings. Exiting.\n"));
2851 GNUNET_SCHEDULER_shutdown (); 3077 GNUNET_SCHEDULER_shutdown ();
2852 return; 3078 return;
2853 } 3079 }
@@ -2923,8 +3149,8 @@ main (int argc, char *const *argv)
2923 options, 3149 options,
2924 &run, 3150 &run,
2925 NULL)) 3151 NULL))
2926 ? 0 3152 ? 0
2927 : 1; 3153 : 1;
2928 GNUNET_free_nz ((void *) argv); 3154 GNUNET_free_nz ((void *) argv);
2929 return ret; 3155 return ret;
2930} 3156}
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index 207c17f2f..92e37a91c 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -700,6 +700,7 @@ handle_send_transmit_continuation (void *cls,
700 700
701 delay = GNUNET_TIME_absolute_get_duration (stcc->send_time); 701 delay = GNUNET_TIME_absolute_get_duration (stcc->send_time);
702 addr = GST_neighbour_get_current_address (&stcc->target); 702 addr = GST_neighbour_get_current_address (&stcc->target);
703#ifdef ENABLE_TTD
703 if (delay.rel_value_us > GNUNET_CONSTANTS_LATENCY_WARN.rel_value_us) 704 if (delay.rel_value_us > GNUNET_CONSTANTS_LATENCY_WARN.rel_value_us)
704 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 705 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
705 "It took us %s to send %u/%u bytes to %s (%d, %s)\n", 706 "It took us %s to send %u/%u bytes to %s (%d, %s)\n",
@@ -718,6 +719,7 @@ handle_send_transmit_continuation (void *cls,
718 GNUNET_i2s (&stcc->target), 719 GNUNET_i2s (&stcc->target),
719 success, 720 success,
720 (NULL != addr) ? addr->transport_name : "%"); 721 (NULL != addr) ? addr->transport_name : "%");
722#endif
721 723
722 if (GNUNET_NO == stcc->down) 724 if (GNUNET_NO == stcc->down)
723 { 725 {
diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c
index 92ed2fe52..219fae57b 100644
--- a/src/transport/plugin_transport_http_client.c
+++ b/src/transport/plugin_transport_http_client.c
@@ -769,10 +769,10 @@ http_client_plugin_send (void *cls,
769 char *stat_txt; 769 char *stat_txt;
770 770
771 LOG (GNUNET_ERROR_TYPE_DEBUG, 771 LOG (GNUNET_ERROR_TYPE_DEBUG,
772 "Session %p/request %p: Sending message with %u to peer `%s' \n", 772 "Session %p/request %p: Sending message with %lu to peer `%s' \n",
773 s, 773 s,
774 s->put.easyhandle, 774 s->put.easyhandle,
775 msgbuf_size, 775 (unsigned long) msgbuf_size,
776 GNUNET_i2s (&s->address->peer)); 776 GNUNET_i2s (&s->address->peer));
777 777
778 /* create new message and schedule */ 778 /* create new message and schedule */
@@ -1087,11 +1087,10 @@ client_send_cb (void *stream,
1087 if (msg->pos == msg->size) 1087 if (msg->pos == msg->size)
1088 { 1088 {
1089 LOG (GNUNET_ERROR_TYPE_DEBUG, 1089 LOG (GNUNET_ERROR_TYPE_DEBUG,
1090 "Session %p/request %p: sent message with %u bytes sent, removing message from queue\n", 1090 "Session %p/request %p: sent message with %lu bytes sent, removing message from queue\n",
1091 s, 1091 s,
1092 s->put.easyhandle, 1092 s->put.easyhandle,
1093 msg->size, 1093 (unsigned long) msg->size);
1094 msg->pos);
1095 /* Calling transmit continuation */ 1094 /* Calling transmit continuation */
1096 GNUNET_CONTAINER_DLL_remove (s->msg_head, 1095 GNUNET_CONTAINER_DLL_remove (s->msg_head,
1097 s->msg_tail, 1096 s->msg_tail,
@@ -1249,10 +1248,10 @@ client_receive (void *stream,
1249 size_t len = size * nmemb; 1248 size_t len = size * nmemb;
1250 1249
1251 LOG (GNUNET_ERROR_TYPE_DEBUG, 1250 LOG (GNUNET_ERROR_TYPE_DEBUG,
1252 "Session %p / request %p: Received %u bytes from peer `%s'\n", 1251 "Session %p / request %p: Received %lu bytes from peer `%s'\n",
1253 s, 1252 s,
1254 s->get.easyhandle, 1253 s->get.easyhandle,
1255 len, 1254 (unsigned long) len,
1256 GNUNET_i2s (&s->address->peer)); 1255 GNUNET_i2s (&s->address->peer));
1257 now = GNUNET_TIME_absolute_get (); 1256 now = GNUNET_TIME_absolute_get ();
1258 if (now.abs_value_us < s->next_receive.abs_value_us) 1257 if (now.abs_value_us < s->next_receive.abs_value_us)
@@ -1346,7 +1345,7 @@ client_run (void *cls)
1346 /* Log status of terminated request */ 1345 /* Log status of terminated request */
1347 if ((0 != msg->data.result) || (http_statuscode != 200)) 1346 if ((0 != msg->data.result) || (http_statuscode != 200))
1348 LOG (GNUNET_ERROR_TYPE_DEBUG, 1347 LOG (GNUNET_ERROR_TYPE_DEBUG,
1349 "Session %p/request %p: %s request to `%s' ended with status %i reason %i: `%s'\n", 1348 "Session %p/request %p: %s request to `%s' ended with status %li reason %i: `%s'\n",
1350 s, msg->easy_handle, 1349 s, msg->easy_handle,
1351 (GNUNET_YES == put_request) ? "PUT" : "GET", 1350 (GNUNET_YES == put_request) ? "PUT" : "GET",
1352 GNUNET_i2s (&s->address->peer), 1351 GNUNET_i2s (&s->address->peer),
diff --git a/src/transport/plugin_transport_http_common.c b/src/transport/plugin_transport_http_common.c
index d81d6db9c..0e3778837 100644
--- a/src/transport/plugin_transport_http_common.c
+++ b/src/transport/plugin_transport_http_common.c
@@ -629,7 +629,7 @@ http_common_plugin_address_to_string (const char *plugin,
629 if (addr_str[ntohl (address->urlen) - 1] != '\0') 629 if (addr_str[ntohl (address->urlen) - 1] != '\0')
630 return NULL; 630 return NULL;
631 GNUNET_asprintf (&res, "%s.%u.%s", plugin, ntohl (address->options), 631 GNUNET_asprintf (&res, "%s.%u.%s", plugin, ntohl (address->options),
632 &address[1]); 632 (char*)&address[1]);
633 if (strlen (res) + 1 < 500) 633 if (strlen (res) + 1 < 500)
634 { 634 {
635 GNUNET_memcpy (rbuf, res, strlen (res) + 1); 635 GNUNET_memcpy (rbuf, res, strlen (res) + 1);
diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c
index d1b21ba9c..6e95ca00c 100644
--- a/src/transport/plugin_transport_http_server.c
+++ b/src/transport/plugin_transport_http_server.c
@@ -745,10 +745,10 @@ http_server_plugin_send (void *cls,
745 char *stat_txt; 745 char *stat_txt;
746 746
747 LOG (GNUNET_ERROR_TYPE_DEBUG, 747 LOG (GNUNET_ERROR_TYPE_DEBUG,
748 "Session %p/request %p: Sending message with %u to peer `%s'\n", 748 "Session %p/request %p: Sending message with %lu to peer `%s'\n",
749 session, 749 session,
750 session->server_send, 750 session->server_send,
751 msgbuf_size, 751 (unsigned long) msgbuf_size,
752 GNUNET_i2s (&session->target)); 752 GNUNET_i2s (&session->target));
753 753
754 /* create new message and schedule */ 754 /* create new message and schedule */
@@ -1270,8 +1270,8 @@ server_parse_url (struct HTTP_Server_Plugin *plugin,
1270 if (hash_length != plugin->peer_id_length) 1270 if (hash_length != plugin->peer_id_length)
1271 { 1271 {
1272 LOG (GNUNET_ERROR_TYPE_DEBUG, 1272 LOG (GNUNET_ERROR_TYPE_DEBUG,
1273 "URL target is %u bytes, expecting %u\n", 1273 "URL target is %lu bytes, expecting %u\n",
1274 hash_length, plugin->peer_id_length); 1274 (unsigned long) hash_length, plugin->peer_id_length);
1275 return GNUNET_SYSERR; 1275 return GNUNET_SYSERR;
1276 } 1276 }
1277 if (GNUNET_OK != 1277 if (GNUNET_OK !=
@@ -1616,8 +1616,8 @@ server_send_callback (void *cls,
1616 { 1616 {
1617 sc->connected = GNUNET_YES; 1617 sc->connected = GNUNET_YES;
1618 LOG (GNUNET_ERROR_TYPE_DEBUG, 1618 LOG (GNUNET_ERROR_TYPE_DEBUG,
1619 "Sent %u bytes to peer `%s' with session %p \n", 1619 "Sent %lu bytes to peer `%s' with session %p \n",
1620 bytes_read, 1620 (unsigned long) bytes_read,
1621 GNUNET_i2s (&s->target), 1621 GNUNET_i2s (&s->target),
1622 s); 1622 s);
1623 GNUNET_asprintf (&stat_txt, 1623 GNUNET_asprintf (&stat_txt,
@@ -1761,14 +1761,14 @@ server_access_cb (void *cls,
1761 1761
1762 LOG (GNUNET_ERROR_TYPE_DEBUG, 1762 LOG (GNUNET_ERROR_TYPE_DEBUG,
1763 _ ( 1763 _ (
1764 "Access from connection %p (%u of %u) for `%s' `%s' url `%s' with upload data size %u\n"), 1764 "Access from connection %p (%u of %u) for `%s' `%s' url `%s' with upload data size %lu\n"),
1765 sc, 1765 sc,
1766 plugin->cur_request, 1766 plugin->cur_request,
1767 plugin->max_request, 1767 plugin->max_request,
1768 method, 1768 method,
1769 version, 1769 version,
1770 url, 1770 url,
1771 (*upload_data_size)); 1771 (unsigned long) (*upload_data_size));
1772 if (NULL == sc) 1772 if (NULL == sc)
1773 { 1773 {
1774 /* CORS pre-flight request */ 1774 /* CORS pre-flight request */
@@ -1868,19 +1868,19 @@ server_access_cb (void *cls,
1868 1868
1869 /* (*upload_data_size > 0) for every segment received */ 1869 /* (*upload_data_size > 0) for every segment received */
1870 LOG (GNUNET_ERROR_TYPE_DEBUG, 1870 LOG (GNUNET_ERROR_TYPE_DEBUG,
1871 "Session %p / Connection %p: Peer `%s' PUT on address `%s' received %u bytes\n", 1871 "Session %p / Connection %p: Peer `%s' PUT on address `%s' received %lu bytes\n",
1872 s, sc, 1872 s, sc,
1873 GNUNET_i2s (&s->target), 1873 GNUNET_i2s (&s->target),
1874 http_common_plugin_address_to_string (plugin->protocol, 1874 http_common_plugin_address_to_string (plugin->protocol,
1875 s->address->address, 1875 s->address->address,
1876 s->address->address_length), 1876 s->address->address_length),
1877 *upload_data_size); 1877 (unsigned long) *upload_data_size);
1878 delay = GNUNET_TIME_absolute_get_remaining (s->next_receive); 1878 delay = GNUNET_TIME_absolute_get_remaining (s->next_receive);
1879 if (0 == delay.rel_value_us) 1879 if (0 == delay.rel_value_us)
1880 { 1880 {
1881 LOG (GNUNET_ERROR_TYPE_DEBUG, 1881 LOG (GNUNET_ERROR_TYPE_DEBUG,
1882 "PUT with %u bytes forwarded to MST\n", 1882 "PUT with %lu bytes forwarded to MST\n",
1883 *upload_data_size); 1883 (unsigned long) *upload_data_size);
1884 if (s->msg_tk == NULL) 1884 if (s->msg_tk == NULL)
1885 { 1885 {
1886 s->msg_tk = GNUNET_MST_create (&server_receive_mst_cb, 1886 s->msg_tk = GNUNET_MST_create (&server_receive_mst_cb,
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c
index e3bc21543..8378a64dd 100644
--- a/src/transport/plugin_transport_tcp.c
+++ b/src/transport/plugin_transport_tcp.c
@@ -2010,8 +2010,8 @@ do_transmit (void *cls, size_t size, void *buf)
2010 GNUNET_assert (pos->message_size <= session->bytes_in_queue); 2010 GNUNET_assert (pos->message_size <= session->bytes_in_queue);
2011 session->bytes_in_queue -= pos->message_size; 2011 session->bytes_in_queue -= pos->message_size;
2012 LOG (GNUNET_ERROR_TYPE_DEBUG, 2012 LOG (GNUNET_ERROR_TYPE_DEBUG,
2013 "Failed to transmit %u byte message to `%s'.\n", 2013 "Failed to transmit %lu byte message to `%s'.\n",
2014 pos->message_size, 2014 (unsigned long) pos->message_size,
2015 GNUNET_i2s (&session->target)); 2015 GNUNET_i2s (&session->target));
2016 ret += pos->message_size; 2016 ret += pos->message_size;
2017 GNUNET_CONTAINER_DLL_insert_after (hd, tl, tl, pos); 2017 GNUNET_CONTAINER_DLL_insert_after (hd, tl, tl, pos);
@@ -2067,9 +2067,9 @@ do_transmit (void *cls, size_t size, void *buf)
2067 session->bytes_in_queue -= pos->message_size; 2067 session->bytes_in_queue -= pos->message_size;
2068 GNUNET_assert (size >= pos->message_size); 2068 GNUNET_assert (size >= pos->message_size);
2069 LOG (GNUNET_ERROR_TYPE_DEBUG, 2069 LOG (GNUNET_ERROR_TYPE_DEBUG,
2070 "Transmitting message of type %u size %u to peer %s at %s\n", 2070 "Transmitting message of type %u size %lu to peer %s at %s\n",
2071 ntohs (((struct GNUNET_MessageHeader *) pos->msg)->type), 2071 ntohs (((struct GNUNET_MessageHeader *) pos->msg)->type),
2072 pos->message_size, 2072 (unsigned long) pos->message_size,
2073 GNUNET_i2s (&session->target), 2073 GNUNET_i2s (&session->target),
2074 tcp_plugin_address_to_string (session->plugin, 2074 tcp_plugin_address_to_string (session->plugin,
2075 session->address->address, 2075 session->address->address,
@@ -2192,8 +2192,8 @@ tcp_plugin_send (void *cls,
2192 pm->transmit_cont_cls = cont_cls; 2192 pm->transmit_cont_cls = cont_cls;
2193 2193
2194 LOG (GNUNET_ERROR_TYPE_DEBUG, 2194 LOG (GNUNET_ERROR_TYPE_DEBUG,
2195 "Asked to transmit %u bytes to `%s', added message to list.\n", 2195 "Asked to transmit %lu bytes to `%s', added message to list.\n",
2196 msgbuf_size, 2196 (unsigned long) msgbuf_size,
2197 GNUNET_i2s (&session->target)); 2197 GNUNET_i2s (&session->target));
2198 2198
2199 if (GNUNET_YES == 2199 if (GNUNET_YES ==
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c
index ec3a0edd8..49e84dfe7 100644
--- a/src/transport/plugin_transport_udp.c
+++ b/src/transport/plugin_transport_udp.c
@@ -1821,7 +1821,8 @@ enqueue_fragment (void *cls, const struct GNUNET_MessageHeader *msg)
1821 struct GNUNET_ATS_Session *session = frag_ctx->session; 1821 struct GNUNET_ATS_Session *session = frag_ctx->session;
1822 size_t msg_len = ntohs (msg->size); 1822 size_t msg_len = ntohs (msg->size);
1823 1823
1824 LOG (GNUNET_ERROR_TYPE_DEBUG, "Enqueuing fragment with %u bytes\n", msg_len); 1824 LOG (GNUNET_ERROR_TYPE_DEBUG, "Enqueuing fragment with %lu bytes\n",
1825 (unsigned long) msg_len);
1825 udpw = GNUNET_malloc (sizeof(struct UDP_MessageWrapper) + msg_len); 1826 udpw = GNUNET_malloc (sizeof(struct UDP_MessageWrapper) + msg_len);
1826 udpw->session = session; 1827 udpw->session = session;
1827 udpw->msg_buf = (char *) &udpw[1]; 1828 udpw->msg_buf = (char *) &udpw[1];
@@ -1996,8 +1997,8 @@ udp_plugin_send (void *cls,
1996 return GNUNET_SYSERR; 1997 return GNUNET_SYSERR;
1997 } 1998 }
1998 LOG (GNUNET_ERROR_TYPE_DEBUG, 1999 LOG (GNUNET_ERROR_TYPE_DEBUG,
1999 "UDP transmits %u-byte message to `%s' using address `%s'\n", 2000 "UDP transmits %lu-byte message to `%s' using address `%s'\n",
2000 udpmlen, 2001 (unsigned long) udpmlen,
2001 GNUNET_i2s (&s->target), 2002 GNUNET_i2s (&s->target),
2002 udp_address_to_string (plugin, 2003 udp_address_to_string (plugin,
2003 s->address->address, 2004 s->address->address,
@@ -3113,18 +3114,18 @@ remove_timeout_messages_and_select (struct Plugin *plugin,
3113 { 3114 {
3114 /* this message is not delayed */ 3115 /* this message is not delayed */
3115 LOG (GNUNET_ERROR_TYPE_DEBUG, 3116 LOG (GNUNET_ERROR_TYPE_DEBUG,
3116 "Message for peer `%s' (%u bytes) is not delayed \n", 3117 "Message for peer `%s' (%lu bytes) is not delayed \n",
3117 GNUNET_i2s (&udpw->session->target), 3118 GNUNET_i2s (&udpw->session->target),
3118 udpw->payload_size); 3119 (unsigned long) udpw->payload_size);
3119 break; /* Found message to send, break */ 3120 break; /* Found message to send, break */
3120 } 3121 }
3121 else 3122 else
3122 { 3123 {
3123 /* Message is delayed, try next */ 3124 /* Message is delayed, try next */
3124 LOG (GNUNET_ERROR_TYPE_DEBUG, 3125 LOG (GNUNET_ERROR_TYPE_DEBUG,
3125 "Message for peer `%s' (%u bytes) is delayed for %s\n", 3126 "Message for peer `%s' (%lu bytes) is delayed for %s\n",
3126 GNUNET_i2s (&udpw->session->target), 3127 GNUNET_i2s (&udpw->session->target),
3127 udpw->payload_size, 3128 (unsigned long) udpw->payload_size,
3128 GNUNET_STRINGS_relative_time_to_string (remaining, GNUNET_YES)); 3129 GNUNET_STRINGS_relative_time_to_string (remaining, GNUNET_YES));
3129 udpw = udpw->next; 3130 udpw = udpw->next;
3130 } 3131 }
diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c
index 9d3e7d354..2324914c9 100644
--- a/src/transport/plugin_transport_unix.c
+++ b/src/transport/plugin_transport_unix.c
@@ -1304,8 +1304,8 @@ unix_plugin_send (void *cls,
1304 return GNUNET_SYSERR; 1304 return GNUNET_SYSERR;
1305 } 1305 }
1306 LOG (GNUNET_ERROR_TYPE_DEBUG, 1306 LOG (GNUNET_ERROR_TYPE_DEBUG,
1307 "Sending %u bytes with session for peer `%s' `%s'\n", 1307 "Sending %lu bytes with session for peer `%s' `%s'\n",
1308 msgbuf_size, 1308 (unsigned long) msgbuf_size,
1309 GNUNET_i2s (&session->target), 1309 GNUNET_i2s (&session->target),
1310 unix_plugin_address_to_string (NULL, 1310 unix_plugin_address_to_string (NULL,
1311 session->address->address, 1311 session->address->address,
diff --git a/src/transport/tcp_connection_legacy.c b/src/transport/tcp_connection_legacy.c
index 3e173b8a4..924362ef2 100644
--- a/src/transport/tcp_connection_legacy.c
+++ b/src/transport/tcp_connection_legacy.c
@@ -1142,9 +1142,9 @@ RETRY:
1142 return; 1142 return;
1143 } 1143 }
1144 LOG (GNUNET_ERROR_TYPE_DEBUG, 1144 LOG (GNUNET_ERROR_TYPE_DEBUG,
1145 "receive_ready read %u/%u bytes from `%s' (%p)!\n", 1145 "receive_ready read %lu/%lu bytes from `%s' (%p)!\n",
1146 (unsigned int) ret, 1146 (unsigned long) ret,
1147 connection->max, 1147 (unsigned long) connection->max,
1148 GNUNET_a2s (connection->addr, connection->addrlen), 1148 GNUNET_a2s (connection->addr, connection->addrlen),
1149 connection); 1149 connection);
1150 GNUNET_assert (NULL != (receiver = connection->receiver)); 1150 GNUNET_assert (NULL != (receiver = connection->receiver));
@@ -1327,8 +1327,8 @@ connect_error (void *cls)
1327 GNUNET_CONNECTION_TransmitReadyNotify notify; 1327 GNUNET_CONNECTION_TransmitReadyNotify notify;
1328 1328
1329 LOG (GNUNET_ERROR_TYPE_DEBUG, 1329 LOG (GNUNET_ERROR_TYPE_DEBUG,
1330 "Transmission request of size %u fails (%s/%u), connection failed (%p).\n", 1330 "Transmission request of size %lu fails (%s/%u), connection failed (%p).\n",
1331 connection->nth.notify_size, 1331 (unsigned long) connection->nth.notify_size,
1332 connection->hostname, 1332 connection->hostname,
1333 connection->port, 1333 connection->port,
1334 connection); 1334 connection);
@@ -1423,9 +1423,9 @@ RETRY:
1423 return; 1423 return;
1424 } 1424 }
1425 LOG (GNUNET_ERROR_TYPE_DEBUG, 1425 LOG (GNUNET_ERROR_TYPE_DEBUG,
1426 "Connection transmitted %u/%u bytes to `%s' (%p)\n", 1426 "Connection transmitted %lu/%lu bytes to `%s' (%p)\n",
1427 (unsigned int) ret, 1427 (unsigned long) ret,
1428 have, 1428 (unsigned long) have,
1429 GNUNET_a2s (connection->addr, connection->addrlen), 1429 GNUNET_a2s (connection->addr, connection->addrlen),
1430 connection); 1430 connection);
1431 connection->write_buffer_pos += ret; 1431 connection->write_buffer_pos += ret;
diff --git a/src/transport/tcp_service_legacy.c b/src/transport/tcp_service_legacy.c
index 12dce3993..8606b353b 100644
--- a/src/transport/tcp_service_legacy.c
+++ b/src/transport/tcp_service_legacy.c
@@ -1433,7 +1433,7 @@ LEGACY_SERVICE_run (int argc,
1433 { 1433 {
1434 clock_offset = skew_offset - skew_variance; 1434 clock_offset = skew_offset - skew_variance;
1435 GNUNET_TIME_set_offset (clock_offset); 1435 GNUNET_TIME_set_offset (clock_offset);
1436 LOG (GNUNET_ERROR_TYPE_DEBUG, "Skewing clock by %dll ms\n", clock_offset); 1436 LOG (GNUNET_ERROR_TYPE_DEBUG, "Skewing clock by %lld ms\n", clock_offset);
1437 } 1437 }
1438 /* actually run service */ 1438 /* actually run service */
1439 err = 0; 1439 err = 0;
diff --git a/src/transport/test_communicator_basic.c b/src/transport/test_communicator_basic.c
index e3573ac2c..8251a5169 100644
--- a/src/transport/test_communicator_basic.c
+++ b/src/transport/test_communicator_basic.c
@@ -82,6 +82,11 @@ static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *my_tc;
82 82
83static unsigned int iterations_left = TOTAL_ITERATIONS; 83static unsigned int iterations_left = TOTAL_ITERATIONS;
84 84
85#define TIMEOUT_MULTIPLIER 1
86
87#define DELAY \
88 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS,50)
89
85#define SHORT_BURST_WINDOW \ 90#define SHORT_BURST_WINDOW \
86 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,2) 91 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,2)
87 92
@@ -97,13 +102,21 @@ enum TestPhase
97}; 102};
98 103
99 104
100static size_t num_sent = 0; 105static size_t num_sent_short = 0;
106
107static size_t num_sent_long = 0;
108
109static size_t num_sent_size = 0;
101 110
102static uint32_t ack = 0; 111static uint32_t ack = 0;
103 112
104static enum TestPhase phase; 113static enum TestPhase phase;
105 114
106static size_t num_received = 0; 115static size_t num_received_short = 0;
116
117static size_t num_received_long = 0;
118
119static size_t num_received_size = 0;
107 120
108static uint64_t avg_latency = 0; 121static uint64_t avg_latency = 0;
109 122
@@ -230,6 +243,10 @@ make_payload (size_t payload_size)
230static void 243static void
231latency_timeout (void *cls) 244latency_timeout (void *cls)
232{ 245{
246
247 size_t num_sent = 0;
248 size_t num_received = 0;
249
233 to_task = NULL; 250 to_task = NULL;
234 if (GNUNET_TIME_absolute_get_remaining (timeout).rel_value_us > 0) 251 if (GNUNET_TIME_absolute_get_remaining (timeout).rel_value_us > 0)
235 { 252 {
@@ -239,6 +256,21 @@ latency_timeout (void *cls)
239 return; 256 return;
240 } 257 }
241 258
259 switch (phase)
260 {
261 case TP_BURST_SHORT:
262 num_sent = num_sent_short;
263 num_received = num_received_short;
264 break;
265 case TP_BURST_LONG:
266 num_sent = num_sent_long;
267 num_received = num_received_long;
268 break;
269 case TP_SIZE_CHECK:
270 num_sent = num_sent_size;
271 num_received = num_received_size;
272 break;
273 }
242 LOG (GNUNET_ERROR_TYPE_ERROR, 274 LOG (GNUNET_ERROR_TYPE_ERROR,
243 "Latency too high. Test failed. (Phase: %d. Sent: %lu, Received: %lu)\n", 275 "Latency too high. Test failed. (Phase: %d. Sent: %lu, Received: %lu)\n",
244 phase, num_sent, num_received); 276 phase, num_sent, num_received);
@@ -246,6 +278,8 @@ latency_timeout (void *cls)
246 GNUNET_SCHEDULER_shutdown (); 278 GNUNET_SCHEDULER_shutdown ();
247} 279}
248 280
281/*static void
282 size_test (void *cls);*/
249 283
250static void 284static void
251size_test (void *cls) 285size_test (void *cls)
@@ -253,6 +287,9 @@ size_test (void *cls)
253 char *payload; 287 char *payload;
254 size_t max_size = 64000; 288 size_t max_size = 64000;
255 289
290 LOG (GNUNET_ERROR_TYPE_DEBUG,
291 "size_test_cb %u\n",
292 num_sent_size);
256 GNUNET_assert (TP_SIZE_CHECK == phase); 293 GNUNET_assert (TP_SIZE_CHECK == phase);
257 if (LONG_MESSAGE_SIZE != long_message_size) 294 if (LONG_MESSAGE_SIZE != long_message_size)
258 max_size = long_message_size; 295 max_size = long_message_size;
@@ -260,7 +297,7 @@ size_test (void *cls)
260 return; /* Leave some room for our protocol, so not 2^16 exactly */ 297 return; /* Leave some room for our protocol, so not 2^16 exactly */
261 ack += 10; 298 ack += 10;
262 payload = make_payload (ack); 299 payload = make_payload (ack);
263 num_sent++; 300 num_sent_size++;
264 GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, 301 GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
265 (ack < max_size) 302 (ack < max_size)
266 ? &size_test 303 ? &size_test
@@ -269,47 +306,98 @@ size_test (void *cls)
269 payload, 306 payload,
270 ack); 307 ack);
271 GNUNET_free (payload); 308 GNUNET_free (payload);
272 timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS); 309 timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (
310 GNUNET_TIME_UNIT_SECONDS,
311 TIMEOUT_MULTIPLIER));
273} 312}
274 313
314/*static void
315size_test (void *cls)
316{
317 GNUNET_SCHEDULER_add_delayed (DELAY,
318 &size_test_cb,
319 NULL);
320 }*/
321
322static void
323long_test (void *cls);
275 324
276static void 325static void
277long_test (void *cls) 326long_test_cb (void *cls)
278{ 327{
279 char *payload; 328 char *payload;
280 329
330 LOG (GNUNET_ERROR_TYPE_DEBUG,
331 "long_test_cb %u/%u\n",
332 num_sent_long,
333 num_received_long);
281 payload = make_payload (long_message_size); 334 payload = make_payload (long_message_size);
282 num_sent++; 335 num_sent_long++;
283 GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, 336 GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
284 (BURST_PACKETS == 337 ((BURST_PACKETS
285 num_sent) 338 * 0.91 ==
339 num_received_long) ||
340 (BURST_PACKETS ==
341 num_sent_long))
286 ? NULL 342 ? NULL
287 : &long_test, 343 : &long_test,
288 NULL, 344 NULL,
289 payload, 345 payload,
290 long_message_size); 346 long_message_size);
291 GNUNET_free (payload); 347 GNUNET_free (payload);
292 timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS); 348 timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (
349 GNUNET_TIME_UNIT_SECONDS,
350 TIMEOUT_MULTIPLIER));
293} 351}
294 352
353static void
354long_test (void *cls)
355{
356 /*LOG (GNUNET_ERROR_TYPE_DEBUG,
357 "long_test %u\n",
358 num_sent_long);*/
359 GNUNET_SCHEDULER_add_delayed (DELAY,
360 &long_test_cb,
361 NULL);
362}
295 363
296static void 364static void
297short_test (void *cls) 365short_test (void *cls);
366
367static void
368short_test_cb (void *cls)
298{ 369{
299 char *payload; 370 char *payload;
300 371
372 LOG (GNUNET_ERROR_TYPE_DEBUG,
373 "short_test_cb %u/%u\n",
374 num_sent_short,
375 num_received_short);
301 payload = make_payload (SHORT_MESSAGE_SIZE); 376 payload = make_payload (SHORT_MESSAGE_SIZE);
302 num_sent++; 377 num_sent_short++;
303 GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, 378 GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
304 (BURST_PACKETS == 379 ((BURST_PACKETS
305 num_sent) 380 * 0.91 ==
381 num_received_short) ||
382 (BURST_PACKETS ==
383 num_sent_short))
306 ? NULL 384 ? NULL
307 : &short_test, 385 : &short_test,
308 NULL, 386 NULL,
309 payload, 387 payload,
310 SHORT_MESSAGE_SIZE); 388 SHORT_MESSAGE_SIZE);
311 GNUNET_free (payload); 389 GNUNET_free (payload);
312 timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS); 390 timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (
391 GNUNET_TIME_UNIT_SECONDS,
392 TIMEOUT_MULTIPLIER));
393}
394
395static void
396short_test (void *cls)
397{
398 GNUNET_SCHEDULER_add_delayed (DELAY,
399 &short_test_cb,
400 NULL);
313} 401}
314 402
315 403
@@ -373,12 +461,17 @@ add_queue_cb (void *cls,
373 else 461 else
374 long_message_size = LONG_MESSAGE_SIZE; 462 long_message_size = LONG_MESSAGE_SIZE;
375 phase = TP_BURST_SHORT; 463 phase = TP_BURST_SHORT;
376 timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES); 464 timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (
465 GNUNET_TIME_UNIT_SECONDS,
466 TIMEOUT_MULTIPLIER));
377 GNUNET_assert (NULL == to_task); 467 GNUNET_assert (NULL == to_task);
378 to_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, 468 to_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (
469 GNUNET_TIME_UNIT_SECONDS,
470 TIMEOUT_MULTIPLIER),
379 &latency_timeout, 471 &latency_timeout,
380 NULL); 472 NULL);
381 prepare_test (NULL); 473 // prepare_test (NULL);
474 short_test (NULL);
382} 475}
383 476
384 477
@@ -388,10 +481,26 @@ update_avg_latency (const char*payload)
388 struct GNUNET_TIME_AbsoluteNBO *ts_n; 481 struct GNUNET_TIME_AbsoluteNBO *ts_n;
389 struct GNUNET_TIME_Absolute ts; 482 struct GNUNET_TIME_Absolute ts;
390 struct GNUNET_TIME_Relative latency; 483 struct GNUNET_TIME_Relative latency;
484 size_t num_received = 0;
391 485
392 ts_n = (struct GNUNET_TIME_AbsoluteNBO *) payload; 486 ts_n = (struct GNUNET_TIME_AbsoluteNBO *) payload;
393 ts = GNUNET_TIME_absolute_ntoh (*ts_n); 487 ts = GNUNET_TIME_absolute_ntoh (*ts_n);
394 latency = GNUNET_TIME_absolute_get_duration (ts); 488 latency = GNUNET_TIME_absolute_get_duration (ts);
489 LOG (GNUNET_ERROR_TYPE_DEBUG,
490 "Latency of received packet: %u\n",
491 latency);
492 switch (phase)
493 {
494 case TP_BURST_SHORT:
495 num_received = num_received_short;
496 break;
497 case TP_BURST_LONG:
498 num_received = num_received_long;
499 break;
500 case TP_SIZE_CHECK:
501 num_received = num_received_size;
502 break;
503 }
395 if (1 >= num_received) 504 if (1 >= num_received)
396 avg_latency = latency.rel_value_us; 505 avg_latency = latency.rel_value_us;
397 else 506 else
@@ -400,7 +509,6 @@ update_avg_latency (const char*payload)
400 509
401} 510}
402 511
403
404/** 512/**
405 * @brief Handle an incoming message 513 * @brief Handle an incoming message
406 * 514 *
@@ -412,7 +520,8 @@ update_avg_latency (const char*payload)
412 */ 520 */
413static void 521static void
414incoming_message_cb (void *cls, 522incoming_message_cb (void *cls,
415 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle 523 struct
524 GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
416 *tc_h, 525 *tc_h,
417 const char*payload, 526 const char*payload,
418 size_t payload_len) 527 size_t payload_len)
@@ -424,7 +533,9 @@ incoming_message_cb (void *cls,
424 return; 533 return;
425 } 534 }
426 /* Reset timeout */ 535 /* Reset timeout */
427 timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS); 536 timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (
537 GNUNET_TIME_UNIT_SECONDS,
538 TIMEOUT_MULTIPLIER));
428 switch (phase) 539 switch (phase)
429 { 540 {
430 case TP_INIT: 541 case TP_INIT:
@@ -433,30 +544,31 @@ incoming_message_cb (void *cls,
433 case TP_BURST_SHORT: 544 case TP_BURST_SHORT:
434 { 545 {
435 GNUNET_assert (SHORT_MESSAGE_SIZE == payload_len); 546 GNUNET_assert (SHORT_MESSAGE_SIZE == payload_len);
436 num_received++; 547 num_received_short++;
437 duration = GNUNET_TIME_absolute_get_duration (start_short); 548 duration = GNUNET_TIME_absolute_get_duration (start_short);
438 update_avg_latency (payload); 549 update_avg_latency (payload);
439 if (num_received == BURST_PACKETS) 550 if (num_received_short == BURST_PACKETS * 0.91)
440 { 551 {
441 LOG (GNUNET_ERROR_TYPE_MESSAGE, 552 LOG (GNUNET_ERROR_TYPE_MESSAGE,
442 "Short size packet test done.\n"); 553 "Short size packet test done.\n");
443 char *goodput = GNUNET_STRINGS_byte_size_fancy ((SHORT_MESSAGE_SIZE 554 char *goodput = GNUNET_STRINGS_byte_size_fancy ((SHORT_MESSAGE_SIZE
444 * num_received * 1000 555 * num_received_short
556 * 1000
445 * 1000) 557 * 1000)
446 / duration.rel_value_us); 558 / duration.rel_value_us);
447 LOG (GNUNET_ERROR_TYPE_MESSAGE, 559 LOG (GNUNET_ERROR_TYPE_MESSAGE,
448 "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n", 560 "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n",
449 (unsigned long) num_received, 561 (unsigned long) num_received_short,
450 (unsigned long) num_sent, 562 (unsigned long) num_sent_short,
451 (unsigned long long) duration.rel_value_us, 563 (unsigned long long) duration.rel_value_us,
452 goodput, 564 goodput,
453 (unsigned long long) avg_latency); 565 (unsigned long long) avg_latency);
454 GNUNET_free (goodput); 566 GNUNET_free (goodput);
455 start_long = GNUNET_TIME_absolute_get (); 567 start_long = GNUNET_TIME_absolute_get ();
456 phase = TP_BURST_LONG; 568 phase = TP_BURST_LONG;
457 num_sent = 0; 569 // num_sent_short = 0;
458 avg_latency = 0; 570 avg_latency = 0;
459 num_received = 0; 571 // num_received = 0;
460 long_test (NULL); 572 long_test (NULL);
461 } 573 }
462 break; 574 break;
@@ -467,32 +579,34 @@ incoming_message_cb (void *cls,
467 { 579 {
468 LOG (GNUNET_ERROR_TYPE_WARNING, 580 LOG (GNUNET_ERROR_TYPE_WARNING,
469 "Ignoring packet with wrong length\n"); 581 "Ignoring packet with wrong length\n");
470 return; // Ignore 582 return; // Ignore
471 } 583 }
472 num_received++; 584 num_received_long++;
473 duration = GNUNET_TIME_absolute_get_duration (start_long); 585 duration = GNUNET_TIME_absolute_get_duration (start_long);
474 update_avg_latency (payload); 586 update_avg_latency (payload);
475 if (num_received == BURST_PACKETS) 587 if (num_received_long == BURST_PACKETS * 0.91)
476 { 588 {
477 LOG (GNUNET_ERROR_TYPE_MESSAGE, 589 LOG (GNUNET_ERROR_TYPE_MESSAGE,
478 "Long size packet test done.\n"); 590 "Long size packet test done.\n");
479 char *goodput = GNUNET_STRINGS_byte_size_fancy ((long_message_size 591 char *goodput = GNUNET_STRINGS_byte_size_fancy ((long_message_size
480 * num_received * 1000 592 * num_received_long
593 * 1000
481 * 1000) 594 * 1000)
482 / duration.rel_value_us); 595 / duration.
596 rel_value_us);
483 597
484 LOG (GNUNET_ERROR_TYPE_MESSAGE, 598 LOG (GNUNET_ERROR_TYPE_MESSAGE,
485 "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n", 599 "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n",
486 (unsigned long) num_received, 600 (unsigned long) num_received_long,
487 (unsigned long) num_sent, 601 (unsigned long) num_sent_long,
488 (unsigned long long) duration.rel_value_us, 602 (unsigned long long) duration.rel_value_us,
489 goodput, 603 goodput,
490 (unsigned long long) avg_latency); 604 (unsigned long long) avg_latency);
491 GNUNET_free (goodput); 605 GNUNET_free (goodput);
492 ack = 0; 606 ack = 0;
493 phase = TP_SIZE_CHECK; 607 phase = TP_SIZE_CHECK;
494 num_received = 0; 608 // num_received = 0;
495 num_sent = 0; 609 // num_sent_long = 0;
496 avg_latency = 0; 610 avg_latency = 0;
497 size_test (NULL); 611 size_test (NULL);
498 } 612 }
@@ -505,25 +619,29 @@ incoming_message_cb (void *cls,
505 GNUNET_assert (TP_SIZE_CHECK == phase); 619 GNUNET_assert (TP_SIZE_CHECK == phase);
506 if (LONG_MESSAGE_SIZE != long_message_size) 620 if (LONG_MESSAGE_SIZE != long_message_size)
507 max_size = long_message_size; 621 max_size = long_message_size;
508 num_received++; 622 num_received_size++;
509 update_avg_latency (payload); 623 update_avg_latency (payload);
510 if (num_received >= (max_size) / 10) 624 if (num_received_size >= (max_size) / 10)
511 { 625 {
512 LOG (GNUNET_ERROR_TYPE_MESSAGE, 626 LOG (GNUNET_ERROR_TYPE_MESSAGE,
513 "Size packet test done.\n"); 627 "Size packet test done.\n");
514 LOG (GNUNET_ERROR_TYPE_MESSAGE, 628 LOG (GNUNET_ERROR_TYPE_MESSAGE,
515 "%lu/%lu packets -- avg latency: %llu us\n", 629 "%lu/%lu packets -- avg latency: %llu us\n",
516 (unsigned long) num_received, 630 (unsigned long) num_received_size,
517 (unsigned long) num_sent, 631 (unsigned long) num_sent_size,
518 (unsigned long long) avg_latency); 632 (unsigned long long) avg_latency);
519 num_received = 0; 633 num_received_size = 0;
520 num_sent = 0; 634 num_sent_size = 0;
521 avg_latency = 0; 635 avg_latency = 0;
522 iterations_left--; 636 iterations_left--;
523 if (0 != iterations_left) 637 if (0 != iterations_left)
524 { 638 {
525 start_short = GNUNET_TIME_absolute_get (); 639 start_short = GNUNET_TIME_absolute_get ();
526 phase = TP_BURST_SHORT; 640 phase = TP_BURST_SHORT;
641 num_sent_short = 0;
642 num_sent_long = 0;
643 num_received_short = 0;
644 num_received_long = 0;
527 short_test (NULL); 645 short_test (NULL);
528 break; 646 break;
529 } 647 }
@@ -561,8 +679,8 @@ static void
561run (void *cls) 679run (void *cls)
562{ 680{
563 ret = 0; 681 ret = 0;
564 num_received = 0; 682 // num_received = 0;
565 num_sent = 0; 683 // num_sent = 0;
566 for (unsigned int i = 0; i < NUM_PEERS; i++) 684 for (unsigned int i = 0; i < NUM_PEERS; i++)
567 { 685 {
568 tc_hs[i] = GNUNET_TRANSPORT_TESTING_transport_communicator_service_start ( 686 tc_hs[i] = GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c
index 98cfd5e29..076fbf331 100644
--- a/src/transport/transport-testing2.c
+++ b/src/transport/transport-testing2.c
@@ -553,7 +553,12 @@ handle_update_queue_message (void *cls,
553 tc_queue->mtu = ntohl (msg->mtu); 553 tc_queue->mtu = ntohl (msg->mtu);
554 tc_queue->cs = msg->cs; 554 tc_queue->cs = msg->cs;
555 tc_queue->priority = ntohl (msg->priority); 555 tc_queue->priority = ntohl (msg->priority);
556 // Uncomment this for alternativ 1 of backchannel functionality
556 tc_queue->q_len += GNUNET_ntohll (msg->q_len); 557 tc_queue->q_len += GNUNET_ntohll (msg->q_len);
558 // Until here for alternativ 1
559 // Uncomment this for alternativ 2 of backchannel functionality
560 // tc_queue->q_len = GNUNET_ntohll (msg->q_len);
561 // Until here for alternativ 2
557 GNUNET_SERVICE_client_continue (client->client); 562 GNUNET_SERVICE_client_continue (client->client);
558} 563}
559 564
@@ -1130,8 +1135,10 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_send
1130 } 1135 }
1131 } 1136 }
1132 GNUNET_assert (NULL != tc_queue); 1137 GNUNET_assert (NULL != tc_queue);
1138 // Uncomment this for alternativ 1 of backchannel functionality
1133 if (tc_queue->q_len != GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED) 1139 if (tc_queue->q_len != GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED)
1134 tc_queue->q_len--; 1140 tc_queue->q_len--;
1141 // Until here for alternativ 1
1135 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1142 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1136 "Sending message\n"); 1143 "Sending message\n");
1137 inbox_size = sizeof (struct GNUNET_MessageHeader) + payload_size; 1144 inbox_size = sizeof (struct GNUNET_MessageHeader) + payload_size;