aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_wlan.c
diff options
context:
space:
mode:
authorDavid Brodski <david@brodski.eu>2011-05-30 23:16:24 +0000
committerDavid Brodski <david@brodski.eu>2011-05-30 23:16:24 +0000
commit9b22b5817ab723ff24a83146c86b325e71313f48 (patch)
tree72d133868f5876dcff707197c0465bc2b9c3e643 /src/transport/plugin_transport_wlan.c
parentc592ecc8263cd14fe24e3d210e3acbd76958d394 (diff)
downloadgnunet-9b22b5817ab723ff24a83146c86b325e71313f48.tar.gz
gnunet-9b22b5817ab723ff24a83146c86b325e71313f48.zip
Small fixes and detection (backlog) of double received messages
Diffstat (limited to 'src/transport/plugin_transport_wlan.c')
-rw-r--r--src/transport/plugin_transport_wlan.c59
1 files changed, 50 insertions, 9 deletions
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index 25af40b7c..9d22591ef 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -44,21 +44,38 @@
44/** 44/**
45 * Max size of packet from helper 45 * Max size of packet from helper
46 */ 46 */
47#define WLAN_MTU 2100 47#define WLAN_MTU 1450
48 48
49/** 49/**
50 * Time until retransmission of a fragment in ms 50 * Time until retransmission of a fragment in ms
51 */ 51 */
52#define FRAGMENT_TIMEOUT GNUNET_TIME_UNIT_SECONDS 52#define FRAGMENT_TIMEOUT GNUNET_TIME_UNIT_SECONDS
53 53
54/**
55 * max size of fragment queue
56 */
54#define FRAGMENT_QUEUE_SIZE 10 57#define FRAGMENT_QUEUE_SIZE 10
58/**
59 * max messages in fragment queue per session/client
60 */
55#define FRAGMENT_QUEUE_MESSAGES_OUT_PER_SESSION 1 61#define FRAGMENT_QUEUE_MESSAGES_OUT_PER_SESSION 1
56 62
63/**
64 * time until message in in queue
65 */
57#define MESSAGE_IN_TIMEOUT GNUNET_TIME_UNIT_SECONDS 66#define MESSAGE_IN_TIMEOUT GNUNET_TIME_UNIT_SECONDS
58 67
68/**
69 * max messages in in queue
70 */
59#define MESSAGES_IN_QUEUE_SIZE 10 71#define MESSAGES_IN_QUEUE_SIZE 10
72/**
73 * max messages in in queue per session/client
74 */
60#define MESSAGES_IN_QUEUE_PER_SESSION 1 75#define MESSAGES_IN_QUEUE_PER_SESSION 1
61 76/**
77 * scaling factor for hello beacon
78 */
62#define HALLO_BEACON_SCALING_FACTOR 900 79#define HALLO_BEACON_SCALING_FACTOR 900
63 80
64#define DEBUG_wlan GNUNET_NO 81#define DEBUG_wlan GNUNET_NO
@@ -67,7 +84,10 @@
67 84
68#define MESSAGE_LENGHT_UNKNOWN -1 85#define MESSAGE_LENGHT_UNKNOWN -1
69//#define NO_MESSAGE_OR_MESSAGE_FINISHED -2 86//#define NO_MESSAGE_OR_MESSAGE_FINISHED -2
70 87/**
88 * size of log for recently used incomming messages id
89 */
90#define MESSAGE_ID_BACKLOG_SIZE 5
71/** 91/**
72 * After how long do we expire an address that we 92 * After how long do we expire an address that we
73 * learned from another peer if it is not reconfirmed 93 * learned from another peer if it is not reconfirmed
@@ -294,7 +314,6 @@ struct Plugin
294 * queue to send acks for received fragments (tail) 314 * queue to send acks for received fragments (tail)
295 */ 315 */
296 struct AckSendQueue * ack_send_queue_tail; 316 struct AckSendQueue * ack_send_queue_tail;
297
298}; 317};
299 318
300/** 319/**
@@ -549,6 +568,15 @@ struct Session
549 uint16_t tx_power; 568 uint16_t tx_power;
550 uint8_t antenna; 569 uint8_t antenna;
551 570
571
572 /**
573 * backlog for incoming message ids
574 */
575 uint32_t message_id_backlog[MESSAGE_ID_BACKLOG_SIZE];
576 /**
577 * position in the backlog
578 */
579 int message_id_backlog_pos;
552}; 580};
553 581
554/** 582/**
@@ -813,6 +841,7 @@ create_session(struct Plugin *plugin, const struct MacAddress * addr)
813 queue->content->addr = *addr; 841 queue->content->addr = *addr;
814 queue->content->fragment_messages_out_count = 0; 842 queue->content->fragment_messages_out_count = 0;
815 queue->content->fragment_messages_in_count = 0; 843 queue->content->fragment_messages_in_count = 0;
844 queue->content->message_id_backlog_pos = 0;
816 845
817 plugin->session_count++; 846 plugin->session_count++;
818 847
@@ -2246,7 +2275,7 @@ wlan_data_message_handler(void *cls, void *client,
2246 struct Session_light * session_light = (struct Session_light *) client; 2275 struct Session_light * session_light = (struct Session_light *) client;
2247 struct WlanHeader * wlanheader; 2276 struct WlanHeader * wlanheader;
2248 struct Session * session; 2277 struct Session * session;
2249 const char * tempmsg; 2278 //const char * tempmsg;
2250 const struct GNUNET_MessageHeader * temp_hdr; 2279 const struct GNUNET_MessageHeader * temp_hdr;
2251 struct GNUNET_PeerIdentity tmptarget; 2280 struct GNUNET_PeerIdentity tmptarget;
2252 int crc; 2281 int crc;
@@ -2276,7 +2305,7 @@ wlan_data_message_handler(void *cls, void *client,
2276 session = session_light->session; 2305 session = session_light->session;
2277 wlanheader = (struct WlanHeader *) hdr; 2306 wlanheader = (struct WlanHeader *) hdr;
2278 2307
2279 tempmsg = (char*) &wlanheader[1]; 2308 //tempmsg = (char*) &wlanheader[1];
2280 temp_hdr = (const struct GNUNET_MessageHeader *) &wlanheader[1]; 2309 temp_hdr = (const struct GNUNET_MessageHeader *) &wlanheader[1];
2281 crc = ntohl(wlanheader->crc); 2310 crc = ntohl(wlanheader->crc);
2282 wlanheader->crc = 0; 2311 wlanheader->crc = 0;
@@ -2450,6 +2479,8 @@ check_rx_finished_msg(struct Plugin* plugin,
2450 } 2479 }
2451 rx_frag = rx_frag->next; 2480 rx_frag = rx_frag->next;
2452 } 2481 }
2482 session->message_id_backlog[session->message_id_backlog_pos] = rx_message->message_id_in;
2483 session->message_id_backlog_pos = (session->message_id_backlog_pos + 1) % MESSAGE_ID_BACKLOG_SIZE;
2453 free_receive_message(plugin, rx_message); 2484 free_receive_message(plugin, rx_message);
2454 //call wlan_process_helper to process the message 2485 //call wlan_process_helper to process the message
2455 //wlan_data_message_handler(plugin, session_light, 2486 //wlan_data_message_handler(plugin, session_light,
@@ -2560,11 +2591,21 @@ insert_fragment_in_in_message_queue(struct Plugin * plugin,
2560 struct Receive_Message_Queue * rx_message; 2591 struct Receive_Message_Queue * rx_message;
2561 const char * tempmsg = (char*) &fh[1]; 2592 const char * tempmsg = (char*) &fh[1];
2562 uint64_t retval = 0; 2593 uint64_t retval = 0;
2594 int i;
2563 2595
2564 //TODO fragments do not timeout 2596 //TODO fragments do not timeout
2565 //check if message_id is right or it is a new msg 2597 //check if message_id is right or it is a new msg
2566 GNUNET_assert(fh != NULL); 2598 GNUNET_assert(fh != NULL);
2567 2599
2600 //check for receive of old messages
2601 for (i = 0; i< MESSAGE_ID_BACKLOG_SIZE; i++)
2602 {
2603 if (session->message_id_backlog[i] == ntohl(fh->message_id) ){
2604 setBit((char *) &retval, ntohs(fh->fragment_off_or_num));
2605 return retval;
2606 }
2607 }
2608
2568 rx_message = get_receive_message(plugin, session, ntohl(fh->message_id)); 2609 rx_message = get_receive_message(plugin, session, ntohl(fh->message_id));
2569 2610
2570 if (rx_message == NULL) 2611 if (rx_message == NULL)
@@ -2804,9 +2845,9 @@ wlan_data_helper(void *cls, struct Session_light * session_light,
2804 } 2845 }
2805 else 2846 else
2806 { 2847 {
2807 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 2848 //GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
2808 "WLAN fragment not in fragment list with id %u of ack\n", ntohl( 2849 // "WLAN fragment not in fragment list with id %u of ack\n", ntohl(
2809 fah->message_id)); 2850 // fah->message_id));
2810 return; 2851 return;
2811 } 2852 }
2812 2853