Skip to content

Commit

Permalink
Improved logging of sent packets, it is working now
Browse files Browse the repository at this point in the history
  • Loading branch information
basilkohler committed Apr 29, 2014
1 parent 20ebba3 commit 3e1e86e
Show file tree
Hide file tree
Showing 21 changed files with 748 additions and 334 deletions.
42 changes: 21 additions & 21 deletions ccnl-core.c
Expand Up @@ -40,7 +40,7 @@ int ccnl_crypto(struct ccnl_relay_s *ccnl, struct ccnl_buf_s *orig,
void
ccnl_nfn_continue_computation(struct ccnl_relay_s *ccnl, int configid);

static struct ccnl_interest_s*
static struct ccnl_interest_s*
ccnl_interest_remove(struct ccnl_relay_s *ccnl, struct ccnl_interest_s *i);

// ----------------------------------------------------------------------
Expand Down Expand Up @@ -120,7 +120,7 @@ dehead(unsigned char **buf, int *len, int *num, int *typ)
return 0;
}
val = (val << 7) | c;
}
}
return -1;
}

Expand Down Expand Up @@ -449,8 +449,8 @@ ccnl_interface_enqueue(void (tx_done)(void*, int, int), struct ccnl_face_s *f,
r = ifc->queue + ((ifc->qfront + ifc->qlen) % CCNL_MAX_IF_QLEN);
r->buf = buf;
memcpy(&r->dst, dest, sizeof(sockunion));
r->txdone = tx_done;
r->txdone_face = f;
r->txdone = tx_done;
r->txdone_face = f;
ifc->qlen++;

#ifdef USE_SCHEDULER
Expand Down Expand Up @@ -644,9 +644,9 @@ ccnl_interest_propagate(struct ccnl_relay_s *ccnl, struct ccnl_interest_s *i)
{
struct ccnl_forward_s *fwd;
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
Expand All @@ -663,12 +663,12 @@ ccnl_interest_propagate(struct ccnl_relay_s *ccnl, struct ccnl_interest_s *i)
#ifdef CCNL_NFN_MONITOR
char monitorpacket[CCNL_MAX_PACKET_SIZE];
int l = create_packet_log(inet_ntoa(fwd->face->peer.ip4.sin_addr),
ntohs(fwd->face->peer.ip4.sin_port),
ntohs(fwd->face->peer.ip4.sin_port),
i->prefix, NULL, 0, monitorpacket);
sendtomonitor(ccnl, monitorpacket, l);
#endif
#endif
}

}
return;
}
Expand Down Expand Up @@ -805,7 +805,7 @@ ccnl_content_serve_pending(struct ccnl_relay_s *ccnl, struct ccnl_content_s *c)
i->minsuffix, i->maxsuffix, c)) {
i = i->next;
continue;
}
}
// CONFORM: "Data MUST only be transmitted in response to
// an Interest that matches the Data."
for (pi = i->pending; pi; pi = pi->next) {
Expand All @@ -816,16 +816,16 @@ ccnl_content_serve_pending(struct ccnl_relay_s *ccnl, struct ccnl_content_s *c)
DEBUGMSG(6, " forwarding content <%s>\n",
ccnl_prefix_to_path(c->name));
ccnl_print_stats(ccnl, STAT_SND_C); //log sent c

DEBUGMSG("--- Serve to: %d", pi->face->faceid);
ccnl_face_enqueue(ccnl, pi->face, buf_dup(c->pkt));
#ifdef CCNL_NFN_MONITOR
char monitorpacket[CCNL_MAX_PACKET_SIZE];
int l = create_packet_log(inet_ntoa(pi->face->peer.ip4.sin_addr),
ntohs(pi->face->peer.ip4.sin_port),
ntohs(pi->face->peer.ip4.sin_port),
c->name, c->content, c->contentlen, monitorpacket);
sendtomonitor(ccnl, monitorpacket, l);
#endif
#endif
} else // upcall to deliver content to local client
ccnl_app_RX(ccnl, c);
c->served_cnt++;
Expand Down Expand Up @@ -957,7 +957,7 @@ ccnl_core_RX_i_or_c(struct ccnl_relay_s *ccnl, struct ccnl_face_s *from,
// CONFORM: Step 2: check whether interest is already known
for (i = ccnl->pit; i; i = i->next) {
if (!ccnl_prefix_cmp(i->prefix, NULL, p, CMP_EXACT) &&
i->minsuffix == minsfx && i->maxsuffix == maxsfx &&
i->minsuffix == minsfx && i->maxsuffix == maxsfx &&
((!ppkd && !i->ppkd) || buf_equal(ppkd, i->ppkd)) )
break;
}
Expand Down Expand Up @@ -1016,22 +1016,22 @@ ccnl_core_RX_i_or_c(struct ccnl_relay_s *ccnl, struct ccnl_face_s *from,
} else { // content
DEBUGMSG(6, " content=<%s>\n", ccnl_prefix_to_path(p));
ccnl_print_stats(ccnl, STAT_RCV_C); //log count recv_content

#ifdef USE_SIGNATURES
if (p->compcnt == 2 && !memcmp(p->comp[0], "ccnx", 4)
&& !memcmp(p->comp[1], "crypto", 6) &&
from == ccnl->crypto_face) {
rc = ccnl_crypto(ccnl, buf, p, from); goto Done;
}
#endif /*USE_SIGNATURES*/

// CONFORM: Step 1:
for (c = ccnl->contents; c; c = c->next)
if (buf_equal(c->pkt, buf)) goto Skip; // content is dup
c = ccnl_content_new(ccnl, &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;
Expand All @@ -1053,11 +1053,11 @@ ccnl_core_RX_i_or_c(struct ccnl_relay_s *ccnl, struct ccnl_face_s *from,
int found = 0;
for(i_it = ccnl->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
//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){
&& i_it->from->faceid < 0){
ccnl_content_add2cache(ccnl, c);
int configid = -i_it->from->faceid;
i_it = ccnl_interest_remove(ccnl, i_it);
Expand All @@ -1070,7 +1070,7 @@ ccnl_core_RX_i_or_c(struct ccnl_relay_s *ccnl, struct ccnl_face_s *from,
if(found) goto Done;
DEBUGMSG(99, "no running computation found \n");
}
#endif
#endif
if (!ccnl_content_serve_pending(ccnl, c)) { // unsolicited content
// CONFORM: "A node MUST NOT forward unsolicited data [...]"
DEBUGMSG(7, " removed because no matching interest\n");
Expand Down
24 changes: 12 additions & 12 deletions json.c
Expand Up @@ -7,7 +7,7 @@

#define CCNL_MAX_PACKET_SIZE 8192

static char
static char
encoding_table[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
Expand All @@ -20,7 +20,7 @@ encoding_table[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
static char *decoding_table = NULL;
static int mod_table[] = {0, 2, 1};

void
void
build_decoding_table() {

decoding_table = malloc(256);
Expand All @@ -30,7 +30,7 @@ build_decoding_table() {
}


char
char
*base64_encode(const unsigned char *data,
size_t input_length,
size_t *output_length) {
Expand Down Expand Up @@ -61,7 +61,7 @@ char
}


unsigned char
unsigned char
*base64_decode(const char *data,
size_t input_length,
size_t *output_length) {
Expand Down Expand Up @@ -97,21 +97,21 @@ unsigned char
return decoded_data;
}

void
void
base64_cleanup() {
free(decoding_table);
}

int
int
create_packet_log(/*long fromip, int fromport,*/ char* toip, int toport,
struct ccnl_prefix_s *prefix, char *data, int datalen, char *res)
{
char name[CCNL_MAX_PACKET_SIZE];
int len = 0;
for(int i = 0; i < prefix->compcnt; ++i){
len += sprintf(name+len, "/%s", prefix->comp[i]);
len += sprintf(name+len, "/%s", prefix->comp[i]);
}

len = 0;
len += sprintf(res + len, "{\n");
len += sprintf(res + len, "\"packetLog\":{\n");
Expand All @@ -134,7 +134,7 @@ create_packet_log(/*long fromip, int fromport,*/ char* toip, int toport,
long timestamp_milli =
((tv.tv_sec) * 1000 + (tv.tv_usec / 1000)); // convert tv_sec & tv_usec to millisecond
len += sprintf(res + len, "\"timestamp\": %lu,\n", timestamp_milli);

len += sprintf(res + len, "\"packet\":{\n");
len += sprintf(res + len, "\"type\": \"%s\",\n", data != NULL ? "content" : "interest" );
len += sprintf(res + len, "\"name\": \"%s\"\n", name);
Expand Down Expand Up @@ -166,11 +166,11 @@ int udp_sendto(int sock, char *address, int port, char *data, int len){
return rc;
}

int
int
sendtomonitor(struct ccnl_relay_s *ccnl, char *content, int contentlen){
char *address = "127.0.0.1";
int port = 10666;
//int s = socket(PF_INET, SOCK_DGRAM, 0);
int s = ccnl->ifs[0].sock;
return udp_sendto(s, address, port, content, contentlen);
}
return udp_sendto(s, address, port, content, contentlen);
}
8 changes: 4 additions & 4 deletions nfn/c_xml.txt
@@ -1,8 +1,8 @@
<contentobj>
<name>
<component>
<data size="691" dt="binary.base64">
YWRkIChjYWxsIDIgL25mbl9zZXJ2aWNlX2ltcGxfV29yZENvdW50U2VydmljZSAvZG9jUmVwbzQvZG9jcy9kb2M4KSAoYWRkIChjYWxsIDIgL25mbl9zZXJ2aWNlX2ltcGxfV29yZENvdW50U2VydmljZSAvZG9jUmVwbzQvZG9jcy9kb2M0KSAoYWRkIChjYWxsIDIgL25mbl9zZXJ2aWNlX2ltcGxfV29yZENvdW50U2VydmljZSAvZG9jUmVwbzMvZG9jcy9kb2MxKSAoYWRkIChjYWxsIDIgL25mbl9zZXJ2aWNlX2ltcGxfV29yZENvdW50U2VydmljZSAvZG9jUmVwbzMvZG9jcy9kb2MzKSAoYWRkIChjYWxsIDIgL25mbl9zZXJ2aWNlX2ltcGxfV29yZENvdW50U2VydmljZSAvZG9jUmVwbzIvZG9jcy9kb2M5KSAoYWRkIChjYWxsIDIgL25mbl9zZXJ2aWNlX2ltcGxfV29yZENvdW50U2VydmljZSAvZG9jUmVwbzIvZG9jcy9kb2M2KSAoYWRkIChjYWxsIDIgL25mbl9zZXJ2aWNlX2ltcGxfV29yZENvdW50U2VydmljZSAvZG9jUmVwbzIvZG9jcy9kb2MyKSAoYWRkIChjYWxsIDIgL25mbl9zZXJ2aWNlX2ltcGxfV29yZENvdW50U2VydmljZSAvZG9jUmVwbzEvZG9jcy9kb2M3KSAoYWRkIChjYWxsIDIgL25mbl9zZXJ2aWNlX2ltcGxfV29yZENvdW50U2VydmljZSAvZG9jUmVwbzEvZG9jcy9kb2M1KSAoY2FsbCAyIC9uZm5fc2VydmljZV9pbXBsX1dvcmRDb3VudFNlcnZpY2UgL2RvY1JlcG8xL2RvY3MvZG9jMCkpKSkpKSkpKQ==
<data size="61" dt="binary.base64">
Y2FsbCAyIC9uZm5fc2VydmljZV9pbXBsX1dvcmRDb3VudFNlcnZpY2UgL2RvY1JlcG8xL2RvY3MvZG9jMA==
</data>
</component>
<component>
Expand All @@ -12,8 +12,8 @@
</component>
</name>
<content>
<data size="2" dt="binary.base64">
NDY=
<data size="1" dt="binary.base64">
MQ==
</data>
</content>
</contentobj>
43 changes: 43 additions & 0 deletions nfn/omnetintegration/.tkenvlog
Expand Up @@ -646,3 +646,46 @@ Tcl error: tkenv.cc#966: can't read "labelid": no such variable
"redrawTimeline"


----------------------------------------------------------------------


Tcl error: tkenv.cc#966: can't read "labelid": no such variable
while executing
"$c insert $labelid end ",...""
(procedure "redrawTimeline" line 104)
invoked from within
"redrawTimeline"


Tcl error: tkenv.cc#966: can't read "labelid": no such variable
while executing
"$c insert $labelid end ",...""
(procedure "redrawTimeline" line 104)
invoked from within
"redrawTimeline"


Tcl error: tkenv.cc#966: can't read "labelid": no such variable
while executing
"$c insert $labelid end ",...""
(procedure "redrawTimeline" line 104)
invoked from within
"redrawTimeline"


Tcl error: tkenv.cc#966: can't read "labelid": no such variable
while executing
"$c insert $labelid end ",...""
(procedure "redrawTimeline" line 104)
invoked from within
"redrawTimeline"


Tcl error: tkenv.cc#966: can't read "labelid": no such variable
while executing
"$c insert $labelid end ",...""
(procedure "redrawTimeline" line 104)
invoked from within
"redrawTimeline"


2 changes: 1 addition & 1 deletion nfn/omnetintegration/.tkenvrc
@@ -1,3 +1,3 @@
# Partial Tkenv config file -- see $HOME/.tkenvrc as well
inspector "NFNNetwork" "NFNNetwork" "2" "627x283+5+27:normal"
inspector "NFNNetwork" "NFNNetwork" "2" "905x586+5+27:normal"

59 changes: 46 additions & 13 deletions nfn/omnetintegration/NFNNetwork.ned
Expand Up @@ -21,23 +21,56 @@ simple ComputeNode extends Node
@display("i=,gold");
}

simple DefaultNode extends Node
{
parameters:
@display("i=,gray");
}

network NFNNetwork
{
submodules:
Some(NFNNode): Some(docRepo4);
Some(ComputeNode): Some(docRepo1compute);
Some(ComputeNode): Some(docRepo0compute);
Some(NFNNode): Some(docRepo1);
Some(NFNNode): Some(docRepo0);
Some(ComputeNode): Some(docRepo2compute);
Some(NFNNode): Some(docRepo3);
Some(ComputeNode): Some(docRepo3compute);
Some(NFNNode): Some(docRepo2);
Some(ComputeNode): Some(docRepo4compute);
docRepo1: NFNNode;
docRepo3: NFNNode;
docRepo3compute: ComputeNode;
docRepo1compute: ComputeNode;
docRepo4: NFNNode;
docRepo0compute: ComputeNode;
docRepo2compute: ComputeNode;
docRepo2: NFNNode;
docRepo0: NFNNode;
docRepo4compute: ComputeNode;
connections:
Some(ComputeNode).out++ --> { delay = 1ms; } --> Some(NFNNode).in++;
Some(NFNNode).out++ --> { delay = 1ms; } --> Some(NFNNode).in++;
Some(NFNNode).out++ --> { delay = 1ms; } --> Some(ComputeNode).in++;
docRepo3.out++ --> { delay = 1ms; } --> docRepo4.in++;
docRepo3.out++ --> { delay = 1ms; } --> docRepo3compute.in++;
docRepo3.out++ --> { delay = 1ms; } --> docRepo2.in++;
docRepo3.out++ --> { delay = 1ms; } --> docRepo0.in++;
docRepo3.out++ --> { delay = 1ms; } --> docRepo1.in++;
docRepo0.out++ --> { delay = 1ms; } --> docRepo2.in++;
docRepo0.out++ --> { delay = 1ms; } --> docRepo3.in++;
docRepo0.out++ --> { delay = 1ms; } --> docRepo4.in++;
docRepo0.out++ --> { delay = 1ms; } --> docRepo0compute.in++;
docRepo0.out++ --> { delay = 1ms; } --> docRepo1.in++;
docRepo4.out++ --> { delay = 1ms; } --> docRepo1.in++;
docRepo4.out++ --> { delay = 1ms; } --> docRepo4compute.in++;
docRepo4.out++ --> { delay = 1ms; } --> docRepo2.in++;
docRepo4.out++ --> { delay = 1ms; } --> docRepo3.in++;
docRepo4.out++ --> { delay = 1ms; } --> docRepo0.in++;
docRepo2.out++ --> { delay = 1ms; } --> docRepo0.in++;
docRepo2.out++ --> { delay = 1ms; } --> docRepo2compute.in++;
docRepo2.out++ --> { delay = 1ms; } --> docRepo4.in++;
docRepo2.out++ --> { delay = 1ms; } --> docRepo1.in++;
docRepo2.out++ --> { delay = 1ms; } --> docRepo3.in++;
docRepo1compute.out++ --> { delay = 1ms; } --> docRepo1.in++;
docRepo2compute.out++ --> { delay = 1ms; } --> docRepo2.in++;
docRepo0compute.out++ --> { delay = 1ms; } --> docRepo0.in++;
docRepo1.out++ --> { delay = 1ms; } --> docRepo2.in++;
docRepo1.out++ --> { delay = 1ms; } --> docRepo0.in++;
docRepo1.out++ --> { delay = 1ms; } --> docRepo4.in++;
docRepo1.out++ --> { delay = 1ms; } --> docRepo3.in++;
docRepo1.out++ --> { delay = 1ms; } --> docRepo1compute.in++;
docRepo3compute.out++ --> { delay = 1ms; } --> docRepo3.in++;
docRepo4compute.out++ --> { delay = 1ms; } --> docRepo4.in++;
}


0 comments on commit 3e1e86e

Please sign in to comment.