void ccnl_simu_phase_two(void *ptr, void *dummy) { phaseOne = 0; ccnl_set_timer(0, ccnl_simu_client_start, char2relay('A'), 0); ccnl_set_timer(500000, ccnl_simu_client_start, char2relay('B'), 0); }
void ccnl_sched_CTS_done(struct ccnl_sched_s *s, int cnt, int len) { #ifdef USE_CHEMFLOW cf_time now = ccnl_cf_now(); #else struct timeval now; long since; #endif if (!s) { DEBUGMSG(VERBOSE, "ccnl_sched_CTS_done sched=%p cnt=%d len=%d\n", (void*)s, cnt, len); return; } DEBUGMSG(VERBOSE, "ccnl_sched_CTS_done sched=%p/%d cnt=%d len=%d (mycnt=%d)\n", (void*)s, s->mode, cnt, len, s->cnt); s->cnt -= cnt; if (s->cnt <= 0) return; if (s->mode == 0) { s->cts(s->aux1, s->aux2); return; } #ifdef USE_CHEMFLOW if (CF_OK == cf_queue_dequeue_packet(s->q, 1)) { DEBUGMSG(VERBOSE, " cf_dequeue successful; CTS\n"); cf_queue_update_concentrations(s->q, now); cf_engine_reschedule_and_set_timer(engine, now); s->cts(s->aux1, s->aux2); } #else ccnl_get_timeval(&now); since = timevaldelta(&(s->nextTX), &now); if (since <= 0) { now.tv_sec += s->ipi / 1000000; now.tv_usec += s->ipi % 1000000; memcpy(&(s->nextTX), &now, sizeof(now)); s->cts(s->aux1, s->aux2); return; } DEBUGMSG(VERBOSE, "since=%ld\n", since); // ccnl_set_timer(since, (void(*)(void*,int))signal_cts, ccnl, ifndx); s->pendingTimer = ccnl_set_timer(since, s->cts, s->aux1, s->aux2); s->nextTX.tv_sec += s->ipi / 1000000;; s->nextTX.tv_usec += s->ipi % 1000000;; // s->cts(); #endif }
void ccnl_sched_RTS(struct ccnl_sched_s *s, int cnt, int len, void *aux1, void *aux2) { #ifdef USE_CHEMFLOW cf_time now = ccnl_cf_now(); #else struct timeval now; long since; #endif if (!s) { DEBUGMSG(VERBOSE, "ccnl_sched_RTS sched=%p len=%d aux1=%p aux2=%p\n", (void*)s, len, (void*)aux1, (void*)aux2); return; } DEBUGMSG(VERBOSE, "ccnl_sched_RTS sched=%p/%d len=%d aux1=%p aux2=%p\n", (void*)s, s->mode, len, (void*)aux1, (void*)aux2); s->cnt += cnt; s->aux1 = aux1; s->aux2 = aux2; if (s->mode == 0) { s->cts(aux1, aux2); return; } #ifdef USE_CHEMFLOW for (; cnt; --cnt) { DEBUGMSG(VERBOSE, " cf_enqueuen"); if (CF_OK == cf_queue_enqueue_packet(s->q, 1)) { cf_queue_update_concentrations(s->q, now); cf_engine_reschedule_and_set_timer(engine, now); } } #else ccnl_get_timeval(&now); since = timevaldelta(&(s->nextTX), &now); if (since <= 0) { now.tv_sec += s->ipi / 1000000; now.tv_usec += s->ipi % 1000000; memcpy(&(s->nextTX), &now, sizeof(now)); s->cts(aux1, aux2); return; } DEBUGMSG(VERBOSE, "since=%ld\n", since); // ccnl_set_timer(since, (void(*)(void*,int))signal_cts, ccnl, ifndx); s->pendingTimer = ccnl_set_timer(since, s->cts, aux1, aux2); s->nextTX.tv_sec += s->ipi / 1000000;; s->nextTX.tv_usec += s->ipi % 1000000;; #endif }
void ccnl_ageing(void *relay, void *aux) { time_t t = time(NULL); struct tm *tm = localtime(&t); if (lasthour != tm->tm_hour) { DEBUGMSG(INFO, "local time is %s", ctime(&t)); lasthour = tm->tm_hour; } ccnl_do_ageing(relay, aux); ccnl_set_timer(1000000, ccnl_ageing, relay, 0); }
void ccnl_simu_client_timeout(void *ptr, void *aux) { struct ccnl_relay_s *relay = (struct ccnl_relay_s*) ptr; struct ccnl_client_s *cl = relay->aux; char node = relay2char(relay); void **vpp = (void**) aux; int ndx; cl->retries++; ndx = vpp - cl->to_handlers; DEBUGMSG(WARNING, "*** node %c timeout: new timeout for ndx%d, seqno=%d\n", node, ndx, cl->onthefly[ndx]); *vpp = ccnl_set_timer(TIMEOUT, ccnl_simu_client_timeout, ptr, aux); cl->nonces[ndx] = random(); ccnl_client_TX(node, cl->name, cl->onthefly[ndx], cl->nonces[ndx]); }
void ccnl_simu_init_node(char node, const char *addr, int max_cache_entries, int mtu) { struct ccnl_relay_s *relay = char2relay(node); struct ccnl_if_s *i; DEBUGMSG(TRACE, "ccnl_simu_init_node\n"); relay->id = relay - relays; relay->max_cache_entries = node == 'C' ? -1 : max_cache_entries; // add (fake) eth0 interface with index 0: i = &relay->ifs[0]; i->addr.eth.sll_family = AF_PACKET; memcpy(i->addr.eth.sll_addr, addr, ETH_ALEN); if (mtu) i->mtu = mtu; else i->mtu = 4096; i->reflect = 1; i->fwdalli = 1; relay->ifcount++; #ifdef USE_SCHEDULER i->sched = ccnl_sched_pktrate_new(ccnl_interface_CTS, relay, inter_packet_interval); relay->defaultFaceScheduler = ccnl_simu_defaultFaceScheduler; #endif if (node == 'A' || node == 'B') { struct ccnl_client_s *client = ccnl_calloc(1, sizeof(struct ccnl_client_s)); client->lastseq = SIMU_NUMBER_OF_CHUNKS-1; client->last_received = -1; client->name = node == 'A' ? "/ccnl/simu/movie1" : "/ccnl/simu/movie2"; relay->aux = (void *) client; } ccnl_set_timer(1000000, ccnl_ageing, relay, 0); }
void ccnl_simu_client_kick(char node, int ndx) { struct ccnl_relay_s *relay = char2relay(node); struct ccnl_client_s *cl = relay->aux; if (cl->nextseq > cl->lastseq) return; if (!cl->to_handlers[ndx]) { cl->onthefly[ndx] = cl->nextseq; cl->nextseq++; cl->nonces[ndx] = random(); cl->to_handlers[ndx] = ccnl_set_timer(TIMEOUT, ccnl_simu_client_timeout, relay, cl->to_handlers + ndx); cl->threadcnt++; // printf("number of threads: %d\n", cl->threadcnt); ccnl_client_TX(node, cl->name, cl->onthefly[ndx], cl->nonces[ndx]); } }
void ccnl_simu_ethernet(void *dummy, void *dummy2) { if (etherqueue) { int i, qlen; struct ccnl_ethernet_s **pp, *p; // pick the last element in the queue for (qlen = 1, pp = ðerqueue; (*pp)->next; pp = &((*pp)->next)) qlen++; p = *pp; *pp = NULL; for (i = 0; i < 5; i++) { if (!memcmp(p->dst, &relays[i].ifs[0].addr.eth.sll_addr, ETH_ALEN)) { break; } } if (i < 5) { sockunion sun; sun.sa.sa_family = AF_PACKET; memcpy(sun.eth.sll_addr, p->src, ETH_ALEN); DEBUGMSG(DEBUG, "simu_ethernet: sending %d Bytes to %s, (qlen=%d)\n", p->len, eth2ascii(p->dst), qlen); ccnl_core_RX(relays + i, 0, (unsigned char*) p->data, p->len, &sun.sa, sizeof(sun.eth)); } else { DEBUGMSG(WARNING, "simu_ethernet: dest %s not found\n", eth2ascii(etherqueue->dst)); } ccnl_free(p); } ccnl_set_timer(2000, ccnl_simu_ethernet, dummy, dummy2); }
void ccnl_ageing(void *relay, void *aux) { ccnl_do_ageing(relay, aux); ccnl_set_timer(1000000, ccnl_ageing, relay, 0); }
int main(int argc, char **argv) { int opt; int udpport = 0; char *prefix, *defaultgw; struct ccnl_if_s *i; struct ccnl_forward_s *fwd; sockunion sun; srandom(time(NULL)); int suite = CCNL_SUITE_NDNTLV; while ((opt = getopt(argc, argv, "hs:u:v:")) != -1) { switch (opt) { case 's': opt = ccnl_str2suite(optarg); if (opt >= 0 && opt < CCNL_SUITE_LAST) suite = opt; else fprintf(stderr, "Suite parameter <%s> ignored.\n", optarg); break; case 'u': udpport = atoi(optarg); break; case 'v': debug_level = atoi(optarg); break; case 'h': default: usage: fprintf(stderr, "usage: %s [options] PREFIX DGWIP/DGWUDPPORT\n" "options: [-h] [-s SUITE] [-u udpport] [-v debuglevel]\n" "example: %s /ndn 128.252.153.194/6363\n", argv[0], argv[0]); exit(EXIT_FAILURE); } } if ((optind+1) >= argc) goto usage; prefix = argv[optind]; defaultgw = argv[optind+1]; ccnl_core_init(); // if (theRelay.suite == CCNL_SUITE_NDNTLV && !udpport) udpport = NDN_UDP_PORT; i = &theRelay.ifs[0]; i->mtu = NDN_DEFAULT_MTU; i->fwdalli = 1; i->sock = ccnl_open_udpdev(udpport); if (i->sock < 0) exit(-1); theRelay.ifcount++; fprintf(stderr, "NDN minimalrelay started, listening on UDP port %d\n", udpport); inet_aton(strtok(defaultgw,"/"), &sun.ip4.sin_addr); sun.ip4.sin_port = atoi(strtok(NULL, "")); fwd = (struct ccnl_forward_s *) ccnl_calloc(1, sizeof(*fwd)); fwd->prefix = ccnl_URItoPrefix(prefix, suite, NULL, NULL); fwd->suite = suite; fwd->face = ccnl_get_face_or_create(&theRelay, 0, &sun.sa, sizeof(sun.ip4)); fwd->face->flags |= CCNL_FACE_FLAGS_STATIC; theRelay.fib = fwd; ccnl_set_timer(1000000, ccnl_minimalrelay_ageing, &theRelay, 0); ccnl_io_loop(&theRelay); return 0; }
void ccnl_relay_config(struct ccnl_relay_s *relay, char *ethdev, int udpport, int tcpport, char *uxpath, int max_cache_entries, char *crypto_face_path) { struct ccnl_if_s *i; char h[1024]; DEBUGMSG(99, "ccnl_relay_config\n"); relay->max_cache_entries = max_cache_entries; #ifdef USE_SCHEDULER relay->defaultFaceScheduler = ccnl_relay_defaultFaceScheduler; relay->defaultInterfaceScheduler = ccnl_relay_defaultInterfaceScheduler; #endif #ifdef USE_ETHERNET // add (real) eth0 interface with index 0: if (ethdev) { i = &relay->ifs[relay->ifcount]; i->sock = ccnl_open_ethdev(ethdev, &i->addr.eth, CCNL_ETH_TYPE); i->mtu = 1500; i->reflect = 1; i->fwdalli = 1; if (i->sock >= 0) { relay->ifcount++; DEBUGMSG(99, "new ETH interface (%s %s) configured\n", ethdev, ccnl_addr2ascii(&i->addr)); if (relay->defaultInterfaceScheduler) i->sched = relay->defaultInterfaceScheduler(relay, ccnl_interface_CTS); } else fprintf(stderr, "sorry, could not open eth device\n"); } #endif // USE_ETHERNET if (udpport > 0) { i = &relay->ifs[relay->ifcount]; i->sock = ccnl_open_udpdev(udpport, &i->addr.ip4); // i->frag = CCNL_DGRAM_FRAG_NONE; i->mtu = CCN_DEFAULT_MTU; i->fwdalli = 1; if (i->sock >= 0) { relay->ifcount++; DEBUGMSG(99, "new UDP interface (ip4 %s) configured\n", ccnl_addr2ascii(&i->addr)); if (relay->defaultInterfaceScheduler) i->sched = relay->defaultInterfaceScheduler(relay, ccnl_interface_CTS); } else fprintf(stderr, "sorry, could not open udp device\n"); } #ifdef USE_HTTP_STATUS if (tcpport) { relay->http = ccnl_http_new(relay, tcpport); } #endif // USE_HTTP_STATUS #ifdef USE_UNIXSOCKET if (uxpath) { i = &relay->ifs[relay->ifcount]; i->sock = ccnl_open_unixpath(uxpath, &i->addr.ux); i->mtu = 4096; if (i->sock >= 0) { relay->ifcount++; DEBUGMSG(99, "new UNIX interface (%s) configured\n", ccnl_addr2ascii(&i->addr)); if (relay->defaultInterfaceScheduler) i->sched = relay->defaultInterfaceScheduler(relay, ccnl_interface_CTS); } else fprintf(stderr, "sorry, could not open unix datagram device\n"); } #ifdef USE_SIGNATURES if(crypto_face_path) { //sending interface + face i = &relay->ifs[relay->ifcount]; i->sock = ccnl_open_unixpath(crypto_face_path, &i->addr.ux); i->mtu = 4096; if (i->sock >= 0) { relay->ifcount++; DEBUGMSG(99, "new UNIX interface (%s) configured\n", ccnl_addr2ascii(&i->addr)); if (relay->defaultInterfaceScheduler) i->sched = relay->defaultInterfaceScheduler(relay, ccnl_interface_CTS); ccnl_crypto_create_ccnl_crypto_face(relay, crypto_face_path); relay->crypto_path = crypto_face_path; } else fprintf(stderr, "sorry, could not open unix datagram device\n"); //receiving interface memset(h,0,sizeof(h)); sprintf(h,"%s-2",crypto_face_path); i = &relay->ifs[relay->ifcount]; i->sock = ccnl_open_unixpath(h, &i->addr.ux); i->mtu = 4096; if (i->sock >= 0) { relay->ifcount++; DEBUGMSG(99, "new UNIX interface (%s) configured\n", ccnl_addr2ascii(&i->addr)); if (relay->defaultInterfaceScheduler) i->sched = relay->defaultInterfaceScheduler(relay, ccnl_interface_CTS); //create_ccnl_crypto_face(relay, crypto_face_path); } else fprintf(stderr, "sorry, could not open unix datagram device\n"); } #endif //USE_SIGNATURES #endif // USE_UNIXSOCKET ccnl_set_timer(1000000, ccnl_ageing, relay, 0); }
void ccnl_retransmit(void *relay, void *aux) { ccnl_do_retransmit(relay, aux); ccnl_set_timer(TIMEOUT_TO_US(CCNL_CHECK_RETRANSMIT_SEC, CCNL_CHECK_RETRANSMIT_USEC), ccnl_retransmit, relay, 0); }
void ccnl_relay_config(struct ccnl_relay_s *relay, char *ethdev, int udpport1, int udpport2, int httpport, char *uxpath, int suite, int max_cache_entries, char *crypto_face_path) { #if defined(USE_LINKLAYER) || defined(USE_UNIXSOCKET) struct ccnl_if_s *i; #endif DEBUGMSG(INFO, "configuring relay\n"); relay->max_cache_entries = max_cache_entries; #ifdef USE_SCHEDULER relay->defaultFaceScheduler = ccnl_relay_defaultFaceScheduler; relay->defaultInterfaceScheduler = ccnl_relay_defaultInterfaceScheduler; #endif #ifdef USE_LINKLAYER // add (real) eth0 interface with index 0: if (ethdev) { i = &relay->ifs[relay->ifcount]; i->sock = ccnl_open_ethdev(ethdev, &i->addr.linklayer, CCNL_ETH_TYPE); i->mtu = 1500; i->reflect = 1; i->fwdalli = 1; if (i->sock >= 0) { relay->ifcount++; DEBUGMSG(INFO, "ETH interface (%s %s) configured\n", ethdev, ccnl_addr2ascii(&i->addr)); if (relay->defaultInterfaceScheduler) i->sched = relay->defaultInterfaceScheduler(relay, ccnl_interface_CTS); } else DEBUGMSG(WARNING, "sorry, could not open eth device\n"); } #endif // USE_LINKLAYER #ifdef USE_IPV4 ccnl_relay_udp(relay, udpport1); ccnl_relay_udp(relay, udpport2); #endif #ifdef USE_HTTP_STATUS if (httpport > 0) { relay->http = ccnl_http_new(relay, httpport); } #endif // USE_HTTP_STATUS #ifdef USE_NFN relay->km = ccnl_calloc(1, sizeof(struct ccnl_krivine_s)); relay->km->configid = -1; #endif #ifdef USE_UNIXSOCKET if (uxpath) { i = &relay->ifs[relay->ifcount]; i->sock = ccnl_open_unixpath(uxpath, &i->addr.ux); i->mtu = 4096; if (i->sock >= 0) { relay->ifcount++; DEBUGMSG(INFO, "UNIX interface (%s) configured\n", ccnl_addr2ascii(&i->addr)); if (relay->defaultInterfaceScheduler) i->sched = relay->defaultInterfaceScheduler(relay, ccnl_interface_CTS); } else DEBUGMSG(WARNING, "sorry, could not open unix datagram device\n"); } #ifdef USE_SIGNATURES if(crypto_face_path) { char h[1024]; //sending interface + face i = &relay->ifs[relay->ifcount]; i->sock = ccnl_open_unixpath(crypto_face_path, &i->addr.ux); i->mtu = 4096; if (i->sock >= 0) { relay->ifcount++; DEBUGMSG(INFO, "new UNIX interface (%s) configured\n", ccnl_addr2ascii(&i->addr)); if (relay->defaultInterfaceScheduler) i->sched = relay->defaultInterfaceScheduler(relay, ccnl_interface_CTS); ccnl_crypto_create_ccnl_crypto_face(relay, crypto_face_path); relay->crypto_path = crypto_face_path; } else DEBUGMSG(WARNING, "sorry, could not open unix datagram device\n"); //receiving interface memset(h,0,sizeof(h)); sprintf(h,"%s-2",crypto_face_path); i = &relay->ifs[relay->ifcount]; i->sock = ccnl_open_unixpath(h, &i->addr.ux); i->mtu = 4096; if (i->sock >= 0) { relay->ifcount++; DEBUGMSG(INFO, "new UNIX interface (%s) configured\n", ccnl_addr2ascii(&i->addr)); if (relay->defaultInterfaceScheduler) i->sched = relay->defaultInterfaceScheduler(relay, ccnl_interface_CTS); //create_ccnl_crypto_face(relay, crypto_face_path); } else DEBUGMSG(WARNING, "sorry, could not open unix datagram device\n"); } #endif //USE_SIGNATURES #endif // USE_UNIXSOCKET ccnl_set_timer(1000000, ccnl_ageing, relay, 0); }
void ccnl_relay_config(struct ccnl_relay_s *relay, int max_cache_entries, int fib_threshold_prefix, int fib_threshold_aggregate) { struct ccnl_if_s *i; DEBUGMSG(99, "ccnl_relay_config\n"); relay->max_cache_entries = max_cache_entries; relay->fib_threshold_prefix = fib_threshold_prefix; relay->fib_threshold_aggregate = fib_threshold_aggregate; if (RIOT_MSG_IDX != relay->ifcount) { DEBUGMSG(1, "sorry, idx did not match: riot msg device\n"); } i = &relay->ifs[relay->ifcount]; i->sock = ccnl_open_riotmsgdev(); i->sendfunc = &riot_send_msg; i->mtu = 4000; i->reflect = 0; i->fwdalli = 0; if (i->sock >= 0) { relay->ifcount++; if (relay->defaultInterfaceScheduler) { i->sched = relay->defaultInterfaceScheduler(relay, ccnl_interface_CTS); } } else { DEBUGMSG(1, "sorry, could not open riot msg device\n"); } if (RIOT_TRANS_IDX != relay->ifcount) { DEBUGMSG(1, "sorry, idx did not match: riot trans device\n"); } i = &relay->ifs[relay->ifcount]; i->sock = ccnl_open_riottransdev(); i->sendfunc = &riot_send_transceiver; #ifdef USE_FRAG i->mtu = 120; #else i->mtu = 1500; #endif i->reflect = 0; i->fwdalli = 0; if (i->sock >= 0) { relay->ifcount++; if (relay->defaultInterfaceScheduler) { i->sched = relay->defaultInterfaceScheduler(relay, ccnl_interface_CTS); } } else { DEBUGMSG(1, "sorry, could not open riot trans device\n"); } /* create default boardcast face on transceiver interface */ struct ccnl_face_s * f = ccnl_get_face_or_create(relay, RIOT_TRANS_IDX, RIOT_BROADCAST); f->flags |= CCNL_FACE_FLAGS_STATIC; i->broadcast_face = f; ccnl_set_timer(TIMEOUT_TO_US(CCNL_CHECK_TIMEOUT_SEC, CCNL_CHECK_TIMEOUT_USEC), ccnl_ageing, relay, 0); ccnl_set_timer(TIMEOUT_TO_US(CCNL_CHECK_RETRANSMIT_SEC, CCNL_CHECK_RETRANSMIT_USEC), ccnl_retransmit, relay, 0); ccnl_set_timer(TIMEOUT_TO_US(CCNL_NONCE_TIMEOUT_SEC, CCNL_NONCE_TIMEOUT_USEC), ccnl_nonce_timeout, relay, 0); }
void ccnl_nonce_timeout(void *relay, void *aux) { ccnl_do_nonce_timeout(relay, aux); ccnl_set_timer(TIMEOUT_TO_US(CCNL_NONCE_TIMEOUT_SEC, CCNL_NONCE_TIMEOUT_USEC), ccnl_nonce_timeout, relay, 0); }
int ccnl_simu_init(int max_cache_entries) { static char dat[SIMU_CHUNK_SIZE]; static char init_was_visited; int i; if (init_was_visited) return 0; init_was_visited = 1; DEBUGMSG(TRACE, "ccnl_simu_init\n"); #ifdef USE_SCHEDULER // initialize the scheduling subsystem ccnl_sched_init(); #endif // define each node's eth address: ccnl_simu_init_node('A', "\x00\x00\x00\x00\x00\x0a", max_cache_entries); ccnl_simu_init_node('B', "\x00\x00\x00\x00\x00\x0b", max_cache_entries); ccnl_simu_init_node('C', "\x00\x00\x00\x00\x00\x0c", max_cache_entries); ccnl_simu_init_node('1', "\x00\x00\x00\x00\x00\x01", max_cache_entries); ccnl_simu_init_node('2', "\x00\x00\x00\x00\x00\x02", max_cache_entries); // install the system's forwarding pointers: ccnl_simu_add_fwd('A', "/ccnl/simu", '2'); ccnl_simu_add_fwd('B', "/ccnl/simu", '2'); ccnl_simu_add_fwd('2', "/ccnl/simu", '1'); ccnl_simu_add_fwd('1', "/ccnl/simu", 'C'); /* for (i = 0; i < 5; i++) ccnl_dump(0, CCNL_RELAY, relays+i); */ // turn node 'C' into a repository for three movies sprintf(dat, "%d", (int) sizeof(dat)); for (i = 0; i < SIMU_NUMBER_OF_CHUNKS; i++) { ccnl_simu_add2cache('C', "/ccnl/simu/movie1", i, dat, sizeof(dat)); ccnl_simu_add2cache('C', "/ccnl/simu/movie2", i, dat, sizeof(dat)); ccnl_simu_add2cache('C', "/ccnl/simu/movie3", i, dat, sizeof(dat)); } ccnl_set_timer(5000, ccnl_simu_ethernet, 0, 0); // start clients: ccnl_set_timer( 500000, ccnl_simu_client_start, char2relay('A'), 0); ccnl_set_timer(1000000, ccnl_simu_client_start, char2relay('B'), 0); phaseOne = 1; printf("Press ENTER to start the simulation\n"); while (getchar() != '\n'); return 0; }
void ccnl_simu_client_RX(struct ccnl_relay_s *relay, char *name, int seqn, char *data, int len) // receiving side { char node = relay2char(relay); struct ccnl_client_s *cl = relay->aux; int i; DEBUGMSG(INFO, "*** node %c received %d content bytes for name %s, seq=%d\n", node, len, name, seqn); if (strcmp(name, cl->name)) { DEBUGMSG(WARNING, "*** content name does not match our request!!\n" " <%s> instead of <%s>\n", name, cl->name); return; } for (i = 0; i < MAX_PIPELINE; i++) { if (cl->onthefly[i] == seqn) break; } if (i == MAX_PIPELINE) // must be old content, ignore return; if (seqn != (cl->last_received+1)) { DEBUGMSG(INFO, "*** content %d out of sequence (expected %d)\n", seqn, cl->last_received+1); cl->outofseq++; } cl->last_received = seqn; if (cl->to_handlers[i]) { ccnl_rem_timer(cl->to_handlers[i]); cl->to_handlers[i] = 0; } if (cl->nextseq > cl->lastseq) { DEBUGMSG(INFO, "*** node %c, client thread %d terminated, %d remaining\n", node, i, cl->threadcnt-1); cl->onthefly[i] = -1; cl->threadcnt--; if (cl->threadcnt <= 0) { pending_client_tasks--; DEBUGMSG(INFO, "task for node %c ended, %d retransmit(s), %d outofseq /%d\n", node, cl->retries, cl->outofseq, pending_client_tasks); if (pending_client_tasks <= 0) { if (phaseOne == 1){ DEBUGMSG(INFO, "Enter Phase-TWO (by node %c)\n\n", node); //make a fake zero log ccnl_set_timer(500000, ccnl_simu_phase_two, 0, 0); } else { DEBUGMSG(INFO, "all tasks of phase two terminated\n"); for (i = 0; i < MAX_PIPELINE; i++) { if (cl->to_handlers[i]) { ccnl_rem_timer(cl->to_handlers[i]); cl->to_handlers[i] = 0; } } // wait a little before cleaning up // (e.g. eth drive to drain its queue) ccnl_set_timer(2000000, ccnl_simu_cleanup, 0, 0); } } } return; } cl->onthefly[i] = cl->nextseq; cl->nextseq++; cl->nonces[i] = random(); cl->to_handlers[i] = ccnl_set_timer(TIMEOUT, ccnl_simu_client_timeout, relay, cl->to_handlers + i); ccnl_client_TX(node, cl->name, cl->onthefly[i], cl->nonces[i]); }
void ccnl_ageing(void *relay, void *aux) { ccnl_do_ageing(relay, aux); ccnl_set_timer(TIMEOUT_TO_US(CCNL_CHECK_TIMEOUT_SEC, CCNL_CHECK_TIMEOUT_USEC), ccnl_ageing, relay, 0); }