void reboot_node(CnetEvent event){
	check = (char *)malloc(9*sizeof(char));
	CHECK(CNET_set_handler(EV_APPLICATIONREADY,application_ready, 0));
	CHECK(CNET_set_handler(EV_PHYSICALREADY,frame_arrived, 0));
	CHECK(CNET_set_handler(EV_TIMER1,resend_frame, 0));
	CNET_enable_application(ALLNODES);

}
Esempio n. 2
0
//-----------------------------------------------------------------------------
// initialization: called by reboot_node
void init_datalink() {
    //set event handler for physical ready event
    CHECK(CNET_set_handler( EV_PHYSICALREADY, read_datalink, 0));
    CHECK(CNET_set_handler( EV_DATALINK_FLUSH, flush_datalink_queue, 0));

    for (int i = 1; i <= nodeinfo.nlinks; i++) {
        datalink_timers[i] = NULLTIMER;
        output_queues[i] = queue_new();
        output_max[i] = 0;
    }
}
Esempio n. 3
0
/***************************************************************************
	Initialise the data link layer. 
 ***************************************************************************/
int init_datalink()
{
	printf("Initialising Datalink Layer\n");

	CNET_set_handler(EV_PHYSICALREADY, up_to_datalink, 0);
	/* The following call registers a handler to render frames.
		 Set drawframes = true/false in the topology file to use/disable this. */
	CNET_set_handler(EV_DRAWFRAME, render_frame, 0);
	
	return 0;
}
Esempio n. 4
0
File: click.c Progetto: stwn/kuliax
void reboot_node(CnetEvent ev, CnetTimer timer, CnetData data)
{
/*  Indicate our interest in EV_DEBUG1, EV_DEBUG2 and EV_PHYSICALREADY events */

    CHECK(CNET_set_handler(EV_PHYSICALREADY, frame_arrived, 0));

    CHECK(CNET_set_handler(EV_DEBUG1,        send_reliable, 0));
    CHECK(CNET_set_debug_string( EV_DEBUG1, "Reliable"));

    CHECK(CNET_set_handler(EV_DEBUG2,        send_unreliable, 0));
    CHECK(CNET_set_debug_string( EV_DEBUG2, "Unreliable"));
}
Esempio n. 5
0
///Initializes the mobile node and prepares it for operation.
///Called when this mobile node is booted up.
void reboot_mobile()
{

  // We require each node to have a different stream of random numbers.
  CNET_srand(nodeinfo.time_of_day.sec + nodeinfo.nodenumber);

  // Provide the required event handlers.
  CHECK(CNET_set_handler(EV_PHYSICALREADY, physical_ready, 0));
  CHECK(CNET_set_handler(EV_APPLICATIONREADY, application_ready, 0));

  // Initialize mobility.
  init_walking();
  start_walking();

  // Prepare to talk via our wireless connection.
  CHECK(CNET_set_wlan_model(my_WLAN_model));

  
  // Setup our data link layer instances.
  dll_states = calloc(nodeinfo.nlinks + 1, sizeof(struct dll_wifi_state *));
  
  for (int link = 1; link <= nodeinfo.nlinks; ++link) {
    if (linkinfo[link].linktype == LT_WLAN) {
      dll_states[link] = dll_wifi_new_state(link,
					    up_from_dll,
					    false /* is_ds */);
    }
  }
  
  isAss = false;
  timeAPset = false;
  
  //CNET TIMEOUT TIMER
  CHECK(CNET_set_handler( EV_TIMER2,           timeouts, 0));

  //CNET PROBE TIMER
  CHECK(CNET_set_handler(EV_TIMER1, probe, 0));
  CHECK(CNET_set_handler(EV_TIMER3, probe, 0));

  
  // Start cnet's default application layer.
  CHECK(CNET_enable_application(ALLNODES));
  
  printf("reboot_mobile() complete.\n");
  printf("\t(%s) My address: %" PRId32 ".\n",nodeinfo.nodename, nodeinfo.address);
  
  probe_timer = CNET_start_timer(EV_TIMER1, PROBE_START, 0);
  toSend = (struct nl_packet *)malloc(sizeof(struct nl_packet));
  CNET_start_timer(EV_TIMER1, 0, 0);

}
Esempio n. 6
0
void reboot_NL_table(void) {
	CHECK(CNET_set_handler(EV_DEBUG0, show_NL_table, 0));
	CHECK(CNET_set_debug_string(EV_DEBUG0, "NL info"));

	NL_table = calloc(NL_table_increment, sizeof(NLTABLE));
	NL_table_capacity = NL_table_increment;
	NL_table_size = 0;
}
Esempio n. 7
0
void reboot_node(CnetEvent ev, CnetTimerID timer, CnetData data)
{
    // SET EVENT HANDLERS
    CHECK(CNET_set_handler( EV_APPLICATIONREADY,  transport_down,   0));
    CHECK(CNET_set_handler( EV_PHYSICALREADY,     datalink_up,      0));
    CHECK(CNET_set_handler( EV_TIMER1,		      timeout_link_1,   0));
    CHECK(CNET_set_handler( EV_TIMER2,		      timeout_link_2,   0));
    CHECK(CNET_set_handler( EV_TIMER3,		      timeout_link_3,   0));
    CHECK(CNET_set_handler( EV_TIMER4,            timeout_link_4,   0));
    CHECK(CNET_set_handler( EV_DRAWFRAME,         draw_frame,       0));    

    // INITIALISE TIMER ARRAY TO NULL TIMERS
    for ( int ii = 0; ii < MAX_LINKS; ii++ )
        for ( int jj = 0; jj < MAX_SEQ + 1; jj++ )
            timers[ii][jj] = NULLTIMER;

    // ENABLE ALL NODES TO SEND TO ALL OTHER NODES
    CHECK(CNET_enable_application(ALLNODES));      

    // SET LEDS FOR LINKS TO ALL GREEN INITIALLY
    for ( int jj = 0; jj < nodeinfo.nlinks; jj++ )
        CNET_set_LED( jj, "green" );

    // SET LEDS FOR NON-USED LIGHTS TO ALL BLACK INITIALLY
    for ( int kk = nodeinfo.nlinks; kk < CNET_NLEDS; kk++ )
        CNET_set_LED( kk, "black" );
}
Esempio n. 8
0
void init_NL_table(int basic)
{
    if(nodeinfo.nlinks > 31) {
	fprintf(stderr,"Too many links for this routing table to support\n");
	exit(1);
    }

    table	= (NL_TABLE *)malloc(sizeof(NL_TABLE));
    table_size	= 0;

    if(basic) {
	CHECK(CNET_set_handler(EV_DEBUG1, show_basic, 0));
    }
    else {
	CHECK(CNET_set_handler(EV_DEBUG1, show_detailed, 0));
    }
    CHECK(CNET_set_debug_string( EV_DEBUG1, "NL info"));
}
Esempio n. 9
0
void init_walking(void)
{
	CnetPosition	start;

	CHECK(CNET_set_handler(EV_WALKING, walker, 0));

	choose_position(&start, 0);
	CHECK(CNET_set_position(start));
}
Esempio n. 10
0
void reboot_node(CnetEvent ev, CnetTimer timer, CnetData data)
{
    if(nodeinfo.nlinks > 32) {
        fprintf(stderr,"selective flooding will not work here\n");
        exit(1);
    }

    CHECK(CNET_set_handler(EV_APPLICATIONREADY, down_to_transport, 0));
    CHECK(CNET_set_handler(EV_PHYSICALREADY,    up_to_datalink, 0));
    CHECK(CNET_set_handler(EV_DEBUG1,           show_table, 0));

    CHECK(CNET_set_debug_string( EV_DEBUG1, "NL info"));

    init_DLL();
    init_NL();

    CNET_enable_application(ALLNODES);

    /* added a timer to sending stuff from queue */
    CNET_set_handler(EV_TIMER1, fire_queue, 0);

}
Esempio n. 11
0
//-----------------------------------------------------------------------------
//  initialize the routing protocol
void init_routing() {
    route_table = (ROUTE_TABLE *) malloc(sizeof(ROUTE_TABLE));
    route_table_size = 0;
    history_table = (HISTORY_TABLE*) malloc(sizeof(HISTORY_TABLE));
    history_table_size = 0;
    reverse_route = (REVERSE_ROUTE_TABLE*)malloc(sizeof(REVERSE_ROUTE_TABLE));
    reverse_table_size = 0;
    forward_route = (FORWARD_ROUTE_TABLE*)malloc(sizeof(FORWARD_ROUTE_TABLE));
    forward_table_size = 0;
    route_req_id = 1;
    // init route requests
    for (int i = 0; i < MAX_HOSTS_NUMBER; i++) {
        pending_route_requests[i] = NULLTIMER;
        route_notified[i]=0;
        routes[i] = 0;
    }
    // register handler for resending route requests
    CHECK(CNET_set_handler(EV_ROUTE_PENDING_TIMER,route_request_resend, 0));
}
Esempio n. 12
0
void reboot_NL_table(void)
{
    CHECK(CNET_set_handler(EV_DEBUG0, show_NL_table, 0));
    CHECK(CNET_set_debug_string(EV_DEBUG0, "NL info"));
    int i,j;
    for (i = 0; i < 2; i++)
    {
        for (j = 0; j < (NNODES+1); j++)
            NL_routingtable[i][j] = MAX_INT;
    }
    for (i = 0; i < (NNODES+1); i++)
    {
        for (j = 0; j < (NNODES+1); j++)
        {
            NL_fullroutingtable[i][j] = MAX_INT;
        }
    }
    NL_routingtable[0][nodeinfo.nodenumber] = 0;
    NL_routingtable[1][nodeinfo.nodenumber] = nodeinfo.nodenumber;
    NL_table		= calloc(1, sizeof(NLTABLE));
    NL_table_size	= 0;
}
Esempio n. 13
0
void
init_searchAP(void){
	CHECK(CNET_set_handler(EV_PHYSICALREADY, searching_ap, 0));
}
Esempio n. 14
0
void
init_association(double data)
{
	CHECK(CNET_set_handler(EV_ASSOCIATE, associate_with_ap, data));
}
Esempio n. 15
0
void 
init_timeout(void)
{
	CHECK(CNET_set_handler(EV_TIMEOUT, timeouts, 0));
}
Esempio n. 16
0
void 
init_talking(void)
{
	CHECK(CNET_set_handler(EV_TALKING, talking, 0));
}
Esempio n. 17
0
void ethernet_init()
{
    CNET_set_handler(EV_PHYSICALREADY, physical_ready, 0);
}