diff --git a/ccnl-core.c b/ccnl-core.c index bde2dc6120d3..8335bcdee159 100644 --- a/ccnl-core.c +++ b/ccnl-core.c @@ -640,7 +640,7 @@ ccnl_interest_propagate(struct ccnl_relay_s *ccnl, struct ccnl_interest_s *i) DEBUGMSG(99, "ccnl_interest_propagate\n"); ccnl_print_stats(ccnl, STAT_SND_I); // log_send_i - + // CONFORM: "A node MUST implement some strategy rule, even if it is only to // transmit an Interest Message on all listed dest faces in sequence." // CCNL strategy: we forward on all FWD entries with a prefix match @@ -969,14 +969,33 @@ ccnl_core_RX_i_or_c(struct ccnl_relay_s *relay, struct ccnl_face_s *from, if (buf_equal(c->pkt, buf)) goto Skip; // content is dup c = ccnl_content_new(relay, &buf, &p, &ppkd, content, contlen); if (c) { // CONFORM: Step 2 (and 3) + + #ifdef CCNL_NFN + fprintf(stderr, "PIT Entries: \n"); + struct ccnl_interest_s *i_it; + for(i_it = relay->pit; i_it; i_it = i_it->next){ + int it; + fprintf(stderr, " - "); + for(it = 0; it < i_it->prefix->compcnt; ++it){ + fprintf(stderr, "/%s", i_it->prefix->comp[it]); + } + fprintf(stderr, " --- from-faceid: %d propagate: %d \n", i_it->from->faceid, i_it->propagate); + } + fprintf(stderr, "Content name: "); + int it = 0; + for(it = 0; it < c->name->compcnt; ++it){ + fprintf(stderr, "/%s", c->name->comp[it]); + }fprintf(stderr, "\n"); if(!memcmp(c->name->comp[c->name->compcnt-1], "NFN", 3)){ struct ccnl_interest_s *i_it = NULL; int found = 0; for(i_it = relay->pit; i_it; i_it = i_it->next){ int md = i_it->prefix->compcnt - c->name->compcnt == 1 ? compute_ccnx_digest(c->pkt) : NULL; - //Check if prefix match and it is a nfn request - if(ccnl_prefix_cmp(c->name, md, i_it->prefix, CMP_EXACT) + //Check if prefix match and it is a nfn request + int cmp = ccnl_prefix_cmp(c->name, md, i_it->prefix, CMP_MATCH); + DEBUGMSG(99, "CMP: %d, faceid: %d \n", cmp, i_it->from->faceid); + if( ccnl_prefix_cmp(c->name, md, i_it->prefix, CMP_MATCH) && i_it->from->faceid < 0){ ccnl_content_add2cache(relay, c); int threadid = -i_it->from->faceid; diff --git a/ccnl-ext-nfn.c b/ccnl-ext-nfn.c index ff298847a5c7..275b78fa2b11 100644 --- a/ccnl-ext-nfn.c +++ b/ccnl-ext-nfn.c @@ -114,7 +114,9 @@ ccnl_nfn_thread(void *arg) { ccnl_nfn_delete_prefix(prefix); }*/ - //pthread_exit ((void *) 0); + struct thread_s *thread1 = main_thread; + pthread_cond_broadcast(&thread1->cond); + pthread_exit ((void *) 0); return 0; } diff --git a/krivine-common.c b/krivine-common.c index 59bdc2a6b40a..62058dffa472 100644 --- a/krivine-common.c +++ b/krivine-common.c @@ -446,10 +446,10 @@ isLocalAvailable(struct ccnl_relay_s *ccnl, struct configuration_s *config, char interest->propagate = 0; int found = 0; struct ccnl_content_s *c; - if((c = ccnl_nfn_local_content_search(ccnl, interest, CMP_MATCH)) != NULL){ //todo: exact match not only prefix + if((c = ccnl_nfn_local_content_search(ccnl, interest, CMP_EXACT)) != NULL){ //todo: exact match not only prefix found = 1; } - //interest = ccnl_interest_remove(ccnl, interest); + interest = ccnl_interest_remove(ccnl, interest); return found; } diff --git a/krivine.c b/krivine.c index 2308cc974218..d65246e74f83 100644 --- a/krivine.c +++ b/krivine.c @@ -699,9 +699,11 @@ ZAM_term(struct ccnl_relay_s *ccnl, struct configuration_s *configuration, if(thunk_request){ //if thunk_request push thunkid on the stack --(*num_of_required_thunks); + DEBUGMSG(99, "%d thunks are required\n", *num_of_required_thunks); char * thunkid = ccnl_nfn_add_thunk(ccnl, configuration, c->name); push_to_stack(&configuration->result_stack, thunkid); if( *num_of_required_thunks <= 0){ + DEBUGMSG(99, "All thunks are available\n"); ccnl_nfn_reply_thunk(ccnl, original_prefix); } } diff --git a/test/ccnb/nfn/computation_dummy_thunk.ccnb b/test/ccnb/nfn/computation_dummy_thunk.ccnb new file mode 100644 index 000000000000..94c2ab835c6c Binary files /dev/null and b/test/ccnb/nfn/computation_dummy_thunk.ccnb differ diff --git a/test/scripts/nfn/compute_thunk_demo.sh b/test/scripts/nfn/compute_thunk_demo.sh new file mode 100644 index 000000000000..ddb8d3089cc4 --- /dev/null +++ b/test/scripts/nfn/compute_thunk_demo.sh @@ -0,0 +1,31 @@ +killall ccn-lite-relay +killall python + +$CCNL_HOME/ccn-lite-relay -v 99 -u 9000 -x /tmp/mgmt1.sock 2> /tmp/r0.log & +$CCNL_HOME/ccn-lite-relay -v 99 -u 9001 -x /tmp/mgmt2.sock 2> /tmp/r1.log & + +sleep 3 + +$CCNL_HOME/util/ccn-lite-ctrl -x /tmp/mgmt1.sock newUDPface any 127.0.0.1 9001 | $CCNL_HOME/util/ccn-lite-ccnb2xml +$CCNL_HOME/util/ccn-lite-ctrl -x /tmp/mgmt2.sock newUDPface any 127.0.0.1 9002 | $CCNL_HOME/util/ccn-lite-ccnb2xml + +sleep 3 + +$CCNL_HOME/util/ccn-lite-ctrl -x /tmp/mgmt1.sock prefixreg /test 2 | $CCNL_HOME/util/ccn-lite-ccnb2xml +$CCNL_HOME/util/ccn-lite-ctrl -x /tmp/mgmt2.sock prefixreg /COMPUTE 2 | $CCNL_HOME/util/ccn-lite-ccnb2xml + +sleep 3 + +$CCNL_HOME/util/ccn-lite-ctrl -x /tmp/mgmt2.sock addContentToCache $CCNL_HOME/test/ccnb/nfn/computation_content.ccnb | $CCNL_HOME/util/ccn-lite-ccnb2xml + +sleep 3 + +python $CCNL_HOME/test/scripts/nfn/dummyanswer.py & > /dev/null + +sleep 3 + +$CCNL_HOME/util/ccn-lite-peekcomputation -t -u 127.0.0.1/9000 -w 100 "(@x add 6 (call 1 x))" "/test/data" | $CCNL_HOME/util/ccn-lite-ccnb2hex + +sleep 5 + +$CCNL_HOME/util/ccn-lite-peekcomputation -u 127.0.0.1/9000 -w 100 "(@x add 6 (call 1 x))" "/test/data" | $CCNL_HOME/util/ccn-lite-ccnb2hex diff --git a/test/scripts/nfn/dummyanswer.py b/test/scripts/nfn/dummyanswer.py index 3bac76c3f4b9..db71b047c2cd 100644 --- a/test/scripts/nfn/dummyanswer.py +++ b/test/scripts/nfn/dummyanswer.py @@ -20,7 +20,7 @@ while True: data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes print "received message:", data - time.sleep(2) +# time.sleep(2) if "THUNK" in data: sock.sendto(c_t, ("127.0.0.1", 9001)) else: