Commit c291fca3 authored by Kevin Fox's avatar Kevin Fox

Add fragmenter to UDP link module

parent 6955a8bc
......@@ -56,6 +56,7 @@ set(LIBATHENA_TCP_SOURCE_FILES
)
set(LIBATHENA_UDP_SOURCE_FILES
athena_Fragmenter.c
athena_TransportLinkModuleUDP.c
)
......
......@@ -241,7 +241,6 @@ LONGBOW_TEST_CASE(Global, athenaTransportLinkModuleETH_SendReceive)
size_t mtu = 1500; // forced MTU size to detect large messages
// Open a link we can send messages on
//sprintf(linkSpecificationURI, "eth://%s:%s/name=ETH_1", device, deviceMAC);
sprintf(linkSpecificationURI, "eth://%s/name=ETH_1/mtu=%zu", device, mtu);
connectionURI = parcURI_Parse(linkSpecificationURI);
result = athenaTransportLinkAdapter_Open(athenaTransportLinkAdapter, connectionURI);
......
......@@ -58,6 +58,7 @@ LONGBOW_TEST_FIXTURE(Global)
{
LONGBOW_RUN_TEST_CASE(Global, athenaTransportLinkModuleUDP_OpenClose);
LONGBOW_RUN_TEST_CASE(Global, athenaTransportLinkModuleUDP_SendReceive);
LONGBOW_RUN_TEST_CASE(Global, athenaTransportLinkModuleUDP_SendReceiveFragments);
LONGBOW_RUN_TEST_CASE(Global, athenaTransportLinkModuleUDP_MTU);
LONGBOW_RUN_TEST_CASE(Global, athenaTransportLinkModuleUDP_P2P);
LONGBOW_RUN_TEST_CASE(Global, athenaTransportLinkModuleUDP_Local);
......@@ -177,7 +178,6 @@ LONGBOW_TEST_CASE(Global, athenaTransportLinkModuleUDP_SendReceive)
assertNotNull(resultVector, "athenaTransportLinkAdapter_Send failed");
parcBitVector_Release(&resultVector);
ccnxMetaMessage_Release(&ccnxMetaMessage);
parcBitVector_Release(&sendVector);
usleep(1000);
......@@ -188,6 +188,97 @@ LONGBOW_TEST_CASE(Global, athenaTransportLinkModuleUDP_SendReceive)
parcBitVector_Release(&resultVector);
ccnxMetaMessage_Release(&ccnxMetaMessage);
// Try to send a large (>mtu) message
name = ccnxName_CreateFromCString("lci:/foo/bar");
ccnxMetaMessage = ccnxInterest_CreateSimple(name);
ccnxName_Release(&name);
size_t largePayloadSize = (64 * 1024) - 1;
char largePayload[largePayloadSize];
PARCBuffer *payload = parcBuffer_Wrap((void *)largePayload, largePayloadSize, 0, largePayloadSize);
ccnxInterest_SetPayload(ccnxMetaMessage, payload);
athena_EncodeMessage(ccnxMetaMessage);
resultVector = athenaTransportLinkAdapter_Send(athenaTransportLinkAdapter, ccnxMetaMessage, sendVector);
assertTrue(parcBitVector_NumberOfBitsSet(resultVector) == 0, "athenaTransportLinkAdapter_Send should have failed to send a large message");
parcBuffer_Release(&payload);
parcBitVector_Release(&sendVector);
parcBitVector_Release(&resultVector);
ccnxMetaMessage_Release(&ccnxMetaMessage);
// Close one end of the connection and send a message from the other.
int closeResult = athenaTransportLinkAdapter_CloseByName(athenaTransportLinkAdapter, "UDPListener");
assertTrue(closeResult == 0, "athenaTransportLinkAdapter_CloseByName failed (%s)", strerror(errno));
ccnxMetaMessage = athenaTransportLinkAdapter_Receive(athenaTransportLinkAdapter, &resultVector, 1);
assertNull(resultVector, "athenaTransportLinkAdapter_Receive should have failed");
closeResult = athenaTransportLinkAdapter_CloseByName(athenaTransportLinkAdapter, "UDP_1");
assertTrue(closeResult == 0, "athenaTransportLinkAdapter_CloseByName failed (%s)", strerror(errno));
athenaTransportLinkAdapter_Destroy(&athenaTransportLinkAdapter);
}
LONGBOW_TEST_CASE(Global, athenaTransportLinkModuleUDP_SendReceiveFragments)
{
PARCURI *connectionURI;
const char *result;
size_t mtu = 1500; // forced MTU size to make sure we fragment large messages
char linkSpecificationURI[MAXPATHLEN];
AthenaTransportLinkAdapter *athenaTransportLinkAdapter = athenaTransportLinkAdapter_Create(_removeLink, NULL);
assertNotNull(athenaTransportLinkAdapter, "athenaTransportLinkAdapter_Create returned NULL");
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);
assertTrue(result != NULL, "athenaTransportLinkAdapter_Open failed (%s)", strerror(errno));
parcURI_Release(&connectionURI);
sprintf(linkSpecificationURI, "udp://127.0.0.1:40000/name=UDP_1/mtu=%zu/fragmenter=BEFS", mtu);
connectionURI = parcURI_Parse(linkSpecificationURI);
result = athenaTransportLinkAdapter_Open(athenaTransportLinkAdapter, connectionURI);
assertTrue(result != NULL, "athenaTransportLinkAdapter_Open failed (%s)", strerror(errno));
parcURI_Release(&connectionURI);
athenaTransportLinkAdapter_Poll(athenaTransportLinkAdapter, 0);
CCNxName *name = ccnxName_CreateFromCString("lci:/foo/bar");
CCNxMetaMessage *ccnxMetaMessage = ccnxInterest_CreateSimple(name);
ccnxName_Release(&name);
size_t largePayloadSize = 3 * mtu;
char largePayload[largePayloadSize];
PARCBuffer *payload = parcBuffer_Wrap((void *)largePayload, largePayloadSize, 0, largePayloadSize);
ccnxInterest_SetPayload(ccnxMetaMessage, payload);
parcBuffer_Release(&payload);
PARCBitVector *sendVector = parcBitVector_Create();
int linkId = athenaTransportLinkAdapter_LinkNameToId(athenaTransportLinkAdapter, "UDP_1");
parcBitVector_Set(sendVector, linkId);
athena_EncodeMessage(ccnxMetaMessage);
PARCBitVector *resultVector;
resultVector = athenaTransportLinkAdapter_Send(athenaTransportLinkAdapter, ccnxMetaMessage, sendVector);
assertNotNull(resultVector, "athenaTransportLinkAdapter_Send failed");
assertTrue(resultVector, "athenaTransportLinkAdapter_Send failed");
assertTrue(parcBitVector_NumberOfBitsSet(resultVector) == 1, "athenaTransportLinkAdapter_Send failed to send large message");
parcBitVector_Release(&resultVector);
ccnxMetaMessage_Release(&ccnxMetaMessage);
parcBitVector_Release(&sendVector);
usleep(1000);
do {
ccnxMetaMessage = athenaTransportLinkAdapter_Receive(athenaTransportLinkAdapter, &resultVector, 0);
} while (ccnxMetaMessage == NULL);
assertNotNull(resultVector, "athenaTransportLinkAdapter_Receive failed");
assertTrue(parcBitVector_NumberOfBitsSet(resultVector) == 1, "athenaTransportLinkAdapter_Receive return message with more than one ingress link");
assertNotNull(ccnxMetaMessage, "athenaTransportLinkAdapter_Receive failed to provide message");
parcBitVector_Release(&resultVector);
ccnxMetaMessage_Release(&ccnxMetaMessage);
// Close one end of the connection and send a message from the other.
int closeResult = athenaTransportLinkAdapter_CloseByName(athenaTransportLinkAdapter, "UDPListener");
assertTrue(closeResult == 0, "athenaTransportLinkAdapter_CloseByName failed (%s)", strerror(errno));
......
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