Skip to content

Commit

Permalink
added code to send rhizome announce packets to ARP-detected peers. #24
Browse files Browse the repository at this point in the history
  • Loading branch information
gardners committed Oct 7, 2012
1 parent a6e2c64 commit ee418d0
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 12 deletions.
25 changes: 25 additions & 0 deletions broadcastfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,31 @@ void overlay_poke_arp_peers()

DEBUGF("Discovered %d peers by ARP.",peer_count);

/* Now send rhizome advertisements to them */

// initialise the packet buffer
struct outgoing_packet packet;
bzero(&packet, sizeof(struct outgoing_packet));
/* Interface doesn't really matter, so just lie that we are using one */
overlay_init_packet(&packet, &overlay_interfaces[0], 1);

/* Stuff more payloads from queues and send it */
overlay_rhizome_add_advertisements(packet.i,packet.buffer);

int i;
for(i=0;i<peer_count;i++)
{
struct sockaddr_in addr;
addr.sin_family=AF_INET;
addr.sin_port=htons(PORT_DNA);
addr.sin_addr=peers[i];
overlay_broadcast_ensemble(packet.i,&addr,packet.buffer->bytes,
packet.buffer->position);
}
ob_free(packet.buffer);
overlay_address_clear();

/* Schedule ourselves to run periodically */
bzero(&alarm,sizeof(alarm));
alarm.alarm = gettime_ms()+ 1000;
alarm.deadline = gettime_ms()+ 1000;
Expand Down
12 changes: 2 additions & 10 deletions overlay_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,6 @@ struct sched_ent sock_any;
struct sockaddr_in sock_any_addr;
struct profile_total sock_any_stats;

struct outgoing_packet{
overlay_interface *interface;
int i;
int unicast;
struct sockaddr_in dest;
struct overlay_buffer *buffer;
};

struct sched_ent next_packet;
struct profile_total send_packet;

Expand Down Expand Up @@ -689,7 +681,7 @@ void overlay_dummy_poll(struct sched_ent *alarm)
return ;
}

static int
int
overlay_broadcast_ensemble(int interface_number,
struct sockaddr_in *recipientaddr,
unsigned char *bytes,int len)
Expand Down Expand Up @@ -989,7 +981,7 @@ overlay_queue_dump(overlay_txqueue *q)
}
#endif // 0

static void
void
overlay_init_packet(struct outgoing_packet *packet, overlay_interface *interface, int tick){
packet->interface = interface;
packet->i = (interface - overlay_interfaces);
Expand Down
14 changes: 12 additions & 2 deletions serval.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ extern char *instrumentation_file;
extern char *batman_socket;
extern char *batman_peerfile;


struct subscriber;

typedef struct keypair {
Expand Down Expand Up @@ -417,6 +416,18 @@ typedef struct overlay_peer {

extern overlay_peer overlay_peers[OVERLAY_MAX_PEERS];

struct outgoing_packet{
overlay_interface *interface;
int i;
int unicast;
struct sockaddr_in dest;
struct overlay_buffer *buffer;
};
int overlay_broadcast_ensemble(int interface_number,
struct sockaddr_in *recipientaddr,
unsigned char *bytes,int len);
void overlay_init_packet(struct outgoing_packet *packet,
overlay_interface *interface, int tick);

typedef struct overlay_txqueue {
struct overlay_frame *first;
Expand Down Expand Up @@ -934,7 +945,6 @@ void dump_stack();
#define RETURNNULL { OUT() return(NULL); }



int olsr_init_socket(void);
int olsr_send(struct overlay_frame *frame);

Expand Down

2 comments on commit ee418d0

@lakeman
Copy link
Member

@lakeman lakeman commented on ee418d0 Oct 7, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is the direction we want to be going in.

The arp table will contain peers who have moved out of range. Sending unicast packets to people who aren't there will waste significant available airtime due to retry behaviour.

In a crowded room this would cause n^2 packets to be sent every second. Even to neighbours that don't need to be poked via unicast.

If we're going to send unicast packets, we must know that they are required. We must be able to send any payload types, not just rhizome announcements.

Any solution probably belongs in the link state tracking layer of our routing protocol.

@gardners
Copy link
Member Author

@gardners gardners commented on ee418d0 Oct 8, 2012 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.