Commit 62213728 authored by Kevin Fox's avatar Kevin Fox

Added fragmenter debug messages

parent bb60136e
......@@ -115,6 +115,7 @@ _nameToLibrary(const char *name)
static void
_destroy(AthenaFragmenter **athenaFragmenter)
{
parcLog_Debug(athenaTransportLink_GetLogger((*athenaFragmenter)->athenaTransportLink), "Detached %s", (*athenaFragmenter)->moduleName);
if ((*athenaFragmenter)->fini) {
(*athenaFragmenter)->fini(*athenaFragmenter);
}
......@@ -160,6 +161,7 @@ athenaFragmenter_Create(AthenaTransportLink *athenaTransportLink, const char *fr
errno = ENODEV;
return NULL;
}
parcLog_Debug(athenaTransportLink_GetLogger(athenaFragmenter->athenaTransportLink), "Attached %s", athenaFragmenter->moduleName);
return athenaFragmenter;
}
......@@ -172,6 +174,8 @@ PARCBuffer *
athenaFragmenter_ReceiveFragment(AthenaFragmenter *athenaFragmenter, PARCBuffer *wireFormatBuffer)
{
if (athenaFragmenter && athenaFragmenter->receiveFragment) {
parcLog_Debug(athenaTransportLink_GetLogger(athenaFragmenter->athenaTransportLink),
"%s received fragment (%zu)", athenaFragmenter->moduleName, parcBuffer_Remaining(wireFormatBuffer));
return athenaFragmenter->receiveFragment(athenaFragmenter, wireFormatBuffer);
}
return wireFormatBuffer;
......@@ -181,6 +185,8 @@ CCNxCodecEncodingBufferIOVec *
athenaFragmenter_CreateFragment(AthenaFragmenter *athenaFragmenter, PARCBuffer *message, size_t mtu, int fragmentNumber)
{
if (athenaFragmenter && athenaFragmenter->createFragment) {
parcLog_Debug(athenaTransportLink_GetLogger(athenaFragmenter->athenaTransportLink),
"%s created fragment (%zu)", athenaFragmenter->moduleName, mtu);
return athenaFragmenter->createFragment(athenaFragmenter, message, mtu, fragmentNumber);
} else {
errno = ENOENT;
......
......@@ -614,6 +614,7 @@ athenaTransportLinkAdapter_Open(AthenaTransportLinkAdapter *athenaTransportLinkA
if (athenaTransportLink == NULL) {
return NULL;
}
athenaTransportLink_SetLogLevel(athenaTransportLink, parcLog_GetLevel(athenaTransportLinkAdapter->log));
return athenaTransportLink_GetName(athenaTransportLink);
}
......
......@@ -279,18 +279,24 @@ _BEFS_ReceiveAndReassemble(AthenaFragmenter *athenaFragmenter, PARCBuffer *wireF
// If we're idle and the message is a begin fragment then continue on.
if (fragmenterData->idle) {
if (_hopByHopHeader_GetBFlag(header)) {
parcLog_Debug(athenaTransportLink_GetLogger(athenaFragmenter->athenaTransportLink), "Received begin fragment");
_BEFS_ClearFragmenterData(athenaFragmenter);
fragmenterData->idle = false;
} else {
parcLog_Debug(athenaTransportLink_GetLogger(athenaFragmenter->athenaTransportLink), "Received fragment while idle");
return NULL;
}
} else {
// If it's not a sequence number we were expecting, clean everything out and start over.
if (_compareSequenceNumbers(seqnum, fragmenterData->receiveSequenceNumber) != 0) {
parcLog_Debug(athenaTransportLink_GetLogger(athenaFragmenter->athenaTransportLink),
"Received fragment out of sequence (%zu != %zu)",
seqnum, fragmenterData->receiveSequenceNumber);
parcBuffer_Release(&wireFormatBuffer);
_BEFS_ClearFragmenterData(athenaFragmenter);
return NULL;
}
parcLog_Debug(athenaTransportLink_GetLogger(athenaFragmenter->athenaTransportLink), "Received fragment %zu", seqnum);
}
// Gather buffers until we receive an end frame
......@@ -299,6 +305,7 @@ _BEFS_ReceiveAndReassemble(AthenaFragmenter *athenaFragmenter, PARCBuffer *wireF
_hopByHopHeader_SetReceiveSequenceNumber(fragmenterData, seqnum);
if (_hopByHopHeader_GetEFlag(header)) {
parcLog_Debug(athenaTransportLink_GetLogger(athenaFragmenter->athenaTransportLink), "Received end fragment");
PARCBuffer *reassembledBuffer = parcBuffer_Allocate(fragmenterData->reassembledSize);
// Currently we cannot decode from an IO vector, so must copy into a buffer (See BugzID: 903)
while (parcDeque_Size(fragmenterData->fragments) > 0) {
......@@ -315,6 +322,7 @@ _BEFS_ReceiveAndReassemble(AthenaFragmenter *athenaFragmenter, PARCBuffer *wireF
// If it's an Idle frame, make sure we're clear and ready.
if (_hopByHopHeader_GetIFlag(header)) {
parcLog_Debug(athenaTransportLink_GetLogger(athenaFragmenter->athenaTransportLink), "Received idle fragment");
_BEFS_ClearFragmenterData(athenaFragmenter);
}
......@@ -343,12 +351,16 @@ _BEFS_CreateFragment(AthenaFragmenter *athenaFragmenter, PARCBuffer *message, si
_HopByHopHeader *fragmentHeader = parcBuffer_Overlay(fragmentHeaderBuffer, 0);
if (fragmentNumber == 0) {
parcLog_Debug(athenaTransportLink_GetLogger(athenaFragmenter->athenaTransportLink),
"Creating %zu fragment number %zu", mtu, fragmentNumber);
_hopByHopHeader_SetBFlag(fragmentHeader);
}
_hopByHopHeader_SetSendSequenceNumber(fragmenterData, fragmentHeader);
if (remaining < maxPayloadSize) {
parcLog_Debug(athenaTransportLink_GetLogger(athenaFragmenter->athenaTransportLink),
"Creating %zu end fragment number %zu", mtu, fragmentNumber);
payloadLength = remaining;
_hopByHopHeader_SetEFlag(fragmentHeader);
}
......@@ -370,6 +382,8 @@ _BEFS_CreateFragment(AthenaFragmenter *athenaFragmenter, PARCBuffer *message, si
fragmentIoVec = ccnxCodecEncodingBuffer_CreateIOVec(encodingBufferSlice);
ccnxCodecEncodingBuffer_Release(&encodingBufferSlice);
parcLog_Debug(athenaTransportLink_GetLogger(athenaFragmenter->athenaTransportLink),
"Created %zu fragment number %zu", mtu, fragmentNumber);
}
parcBuffer_Release(&fragmentHeaderBuffer);
......@@ -380,12 +394,16 @@ _BEFS_CreateFragment(AthenaFragmenter *athenaFragmenter, PARCBuffer *message, si
static void
_athenaFragmenter_BEFS_Fini(AthenaFragmenter *athenaFragmenter)
{
parcLog_Debug(athenaTransportLink_GetLogger(athenaFragmenter->athenaTransportLink),
"Destroying BEFS fragmenter");
_BEFS_DestroyFragmenterData(athenaFragmenter);
}
AthenaFragmenter *
athenaFragmenter_BEFS_Init(AthenaFragmenter *athenaFragmenter)
{
parcLog_Debug(athenaTransportLink_GetLogger(athenaFragmenter->athenaTransportLink),
"Creating BEFS fragmenter");
athenaFragmenter->fragmenterData = _BEFS_CreateFragmenterData();
athenaFragmenter->createFragment = (AthenaFragmenter_CreateFragment *)_BEFS_CreateFragment;
athenaFragmenter->receiveFragment = (AthenaFragmenter_ReceiveFragment *)_BEFS_ReceiveAndReassemble;
......
......@@ -234,8 +234,6 @@ LONGBOW_TEST_CASE(Global, athenaTransportLinkModuleUDP_SendReceiveFragments)
AthenaTransportLinkAdapter *athenaTransportLinkAdapter = athenaTransportLinkAdapter_Create(_removeLink, NULL);
assertNotNull(athenaTransportLinkAdapter, "athenaTransportLinkAdapter_Create returned NULL");
athenaTransportLinkAdapter_SetLogLevel(athenaTransportLinkAdapter, PARCLogLevel_Debug);
sprintf(linkSpecificationURI, "udp://127.0.0.1:40000/Listener/name=UDPListener/mtu=%zu/fragmenter=BEFS", mtu);
connectionURI = parcURI_Parse(linkSpecificationURI);
result = athenaTransportLinkAdapter_Open(athenaTransportLinkAdapter, connectionURI);
......@@ -248,6 +246,8 @@ LONGBOW_TEST_CASE(Global, athenaTransportLinkModuleUDP_SendReceiveFragments)
assertTrue(result != NULL, "athenaTransportLinkAdapter_Open failed (%s)", strerror(errno));
parcURI_Release(&connectionURI);
athenaTransportLinkAdapter_SetLogLevel(athenaTransportLinkAdapter, PARCLogLevel_Debug);
athenaTransportLinkAdapter_Poll(athenaTransportLinkAdapter, 0);
CCNxName *name = ccnxName_CreateFromCString("lci:/foo/bar");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment