cleanup
commit
61e9d8311a
|
|
@ -0,0 +1,164 @@
|
|||
cmake_minimum_required(VERSION 3.11)
|
||||
|
||||
# set the project name
|
||||
project(norm VERSION 1.5.8)
|
||||
|
||||
set(COMMON src/common)
|
||||
|
||||
option(NORM_BUILD_EXAMPLES "Enables building of the examples in /examples." OFF)
|
||||
|
||||
include(CheckCXXSymbolExists)
|
||||
check_cxx_symbol_exists(dirfd "dirent.h" HAVE_DIRFD)
|
||||
if(HAVE_DIRFD)
|
||||
list(APPEND PLATFORM_DEFINITIONS HAVE_DIRFD)
|
||||
endif()
|
||||
|
||||
check_cxx_symbol_exists(lockf "unistd.h" HAVE_LOCKF)
|
||||
if(HAVE_LOCKF)
|
||||
list(APPEND PLATFORM_DEFINITIONS HAVE_LOCKF)
|
||||
endif()
|
||||
|
||||
check_cxx_symbol_exists(flock "sys/file.h" HAVE_FLOCK)
|
||||
if(HAVE_FLOCK)
|
||||
list(APPEND PLATFORM_DEFINITIONS HAVE_FLOCK)
|
||||
endif()
|
||||
|
||||
# Check for libraries
|
||||
find_package(protokit QUIET)
|
||||
|
||||
if(NOT protokit_FOUND)
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
protokit
|
||||
GIT_REPOSITORY https://github.com/USNavalResearchLaboratory/protolib.git
|
||||
GIT_TAG origin/master
|
||||
)
|
||||
FetchContent_MakeAvailable(protokit)
|
||||
endif()
|
||||
|
||||
# List header files
|
||||
list(APPEND PUBLIC_HEADER_FILES
|
||||
include/galois.h
|
||||
include/normApi.h
|
||||
include/normEncoder.h
|
||||
include/normEncoderMDP.h
|
||||
include/normEncoderRS16.h
|
||||
include/normEncoderRS8.h
|
||||
include/normFile.h
|
||||
include/normMessage.h
|
||||
include/normNode.h
|
||||
include/normObject.h
|
||||
include/normPostProcess.h
|
||||
include/normSegment.h
|
||||
include/normSession.h
|
||||
include/normSimAgent.h
|
||||
include/normVersion.h
|
||||
)
|
||||
|
||||
# List platform-independent source files
|
||||
list(APPEND COMMON_SOURCE_FILES
|
||||
${COMMON}/galois.cpp
|
||||
${COMMON}/normApi.cpp
|
||||
${COMMON}/normEncoder.cpp
|
||||
${COMMON}/normEncoderMDP.cpp
|
||||
${COMMON}/normEncoderRS16.cpp
|
||||
${COMMON}/normEncoderRS8.cpp
|
||||
${COMMON}/normFile.cpp
|
||||
${COMMON}/normMessage.cpp
|
||||
${COMMON}/normNode.cpp
|
||||
${COMMON}/normObject.cpp
|
||||
${COMMON}/normSegment.cpp
|
||||
${COMMON}/normSession.cpp )
|
||||
|
||||
# Setup platform independent include directory
|
||||
list(APPEND INCLUDE_DIRS ${CMAKE_CURRENT_LIST_DIR}/include )
|
||||
|
||||
# Setup platform dependent libraries, defines, source file and compiler flags
|
||||
if(MSVC)
|
||||
list(APPEND PLATFORM_LIBS Shell32)
|
||||
list(APPEND PLATFORM_DEFINITIONS _CONSOLE)
|
||||
list(APPEND PLATFORM_SOURCE_FILES src/win32/win32PostProcess.cpp)
|
||||
elseif(UNIX)
|
||||
list(APPEND PLATFORM_SOURCE_FILES src/unix/unixPostProcess.cpp)
|
||||
endif()
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
# Setup target
|
||||
add_library(norm ${PLATFORM_SOURCE_FILES} ${COMMON_SOURCE_FILES} ${PUBLIC_HEADER_FILES})
|
||||
target_link_libraries(norm PRIVATE ${PLATFORM_LIBS} protokit::protokit)
|
||||
target_compile_definitions(norm PUBLIC ${PLATFORM_DEFINITIONS})
|
||||
target_compile_options(norm PUBLIC ${PLATFORM_FLAGS})
|
||||
target_include_directories(norm PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_include_directories(norm PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>)
|
||||
|
||||
# Install target
|
||||
install( TARGETS norm EXPORT normTargets
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} )
|
||||
|
||||
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/norm)
|
||||
|
||||
install( EXPORT normTargets
|
||||
FILE normTargets.cmake
|
||||
NAMESPACE norm::
|
||||
DESTINATION ${INSTALL_CONFIGDIR}
|
||||
)
|
||||
|
||||
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/norm)
|
||||
|
||||
# Create a ConfigVersion.cmake file
|
||||
include(CMakePackageConfigHelpers)
|
||||
write_basic_package_version_file(
|
||||
${CMAKE_CURRENT_BINARY_DIR}/normConfigVersion.cmake
|
||||
VERSION ${PROJECT_VERSION}
|
||||
COMPATIBILITY AnyNewerVersion
|
||||
)
|
||||
|
||||
configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/cmake/normConfig.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/normConfig.cmake
|
||||
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
|
||||
)
|
||||
|
||||
# Install the config, configversion and custom find modules
|
||||
install(FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/normConfig.cmake
|
||||
${CMAKE_CURRENT_BINARY_DIR}/normConfigVersion.cmake
|
||||
DESTINATION ${INSTALL_CONFIGDIR}
|
||||
)
|
||||
|
||||
##############################################
|
||||
# Exporting from the build tree
|
||||
export(EXPORT normTargets
|
||||
FILE ${CMAKE_CURRENT_BINARY_DIR}/normTargets.cmake
|
||||
NAMESPACE norm::)
|
||||
|
||||
# Register package in user's package registry
|
||||
export(PACKAGE norm)
|
||||
|
||||
if(NORM_BUILD_EXAMPLES)
|
||||
# Setup examples
|
||||
list(APPEND examples
|
||||
#normDataExample
|
||||
normDataRecv
|
||||
normDataSend
|
||||
normFileRecv
|
||||
normFileSend
|
||||
normStreamRecv
|
||||
normStreamSend
|
||||
normMsgr
|
||||
normStreamer
|
||||
normCast
|
||||
normClient
|
||||
normServer
|
||||
#wintest
|
||||
)
|
||||
|
||||
foreach(example ${examples})
|
||||
add_executable(${example} examples/${example}.cpp examples/normSocket.cpp)
|
||||
target_link_libraries(${example} PRIVATE norm protokit::protokit)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
|
|
@ -33,6 +33,10 @@
|
|||
|
||||
This is a release of the NRL NORM source code.
|
||||
|
||||
A Google Groups forum is available at
|
||||
|
||||
https://groups.google.com/forum/#!forum/norm-dev
|
||||
|
||||
|
||||
SOURCE CODE
|
||||
===========
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
include(CMakeFindDependencyMacro)
|
||||
|
||||
# Same syntax as find_package
|
||||
find_dependency(protokit REQUIRED)
|
||||
|
||||
# Add the targets file
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/normTargets.cmake")
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
#include "normApi.h"
|
||||
#include <stdio.h> // for printf(), etc
|
||||
#include <stdlib.h> // for atoi(), etc
|
||||
#include <cassert>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
// NOTE: These are debugging routines available
|
||||
// (not necessary for normal app use)
|
||||
// (Need to include "protolib/common/protoDebug.h" for this
|
||||
// (Need to include "common/protoDebug.h" for this
|
||||
//SetDebugLevel(2);
|
||||
// Uncomment to turn on debug NORM message tracing
|
||||
//NormSetMessageTrace(session, true);
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
// NOTE: These are some debugging routines available
|
||||
// (not necessary for normal app use)
|
||||
// (Need to include "protolib/common/protoDebug.h" for this
|
||||
// (Need to include "common/protoDebug.h" for this
|
||||
//SetDebugLevel(2);
|
||||
// Uncomment to turn on debug NORM message tracing
|
||||
NormSetMessageTrace(session, true);
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
// NOTE: These are debugging routines available
|
||||
// (not necessary for normal app use)
|
||||
// (Need to include "protolib/common/protoDebug.h" for this
|
||||
// (Need to include "common/protoDebug.h" for this
|
||||
NormSetDebugLevel(3);
|
||||
// Uncomment to turn on debug NORM message tracing
|
||||
NormSetMessageTrace(session, true);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ int main(int argc, char** argv)
|
|||
|
||||
Win32InputHandler inputHandler;
|
||||
|
||||
inputHandler.Start();
|
||||
inputHandler.Open();
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
|
@ -51,7 +51,7 @@ int main(int argc, char** argv)
|
|||
DWORD dwWritten;
|
||||
BOOL fSuccess = WriteFile(hStdout, buffer, numBytes, &dwWritten, NULL);
|
||||
}
|
||||
inputHandler.Stop();
|
||||
inputHandler.Close();
|
||||
|
||||
return 0;
|
||||
} // end main()
|
||||
|
|
|
|||
|
|
@ -17,6 +17,12 @@ static inline int dirfd(DIR *dir) {return (dir->dd_fd);}
|
|||
#endif // HAVE_DIRFD
|
||||
#endif // if/else WIN32
|
||||
|
||||
#ifdef HAVE_FLOCK
|
||||
#include <sys/file.h>
|
||||
#elif defined(HAVE_LOCKF)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32_WCE
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -2,7 +2,6 @@
|
|||
// Assumes UDP packets in tcpdump trace file (pcap file) are
|
||||
// MGEN packets and parses to build an MGEN log file
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <pcap.h>
|
||||
#include <sys/socket.h> // for PF_ types (protocol family)
|
||||
|
|
@ -12,92 +11,95 @@
|
|||
|
||||
#include "normSession.h"
|
||||
|
||||
void NormTrace2(const struct timeval& currentTime,
|
||||
const NormMsg& msg,
|
||||
const ProtoAddress& srcAddr,
|
||||
const ProtoAddress& dstAddr);
|
||||
void NormTrace2(const struct timeval ¤tTime,
|
||||
const NormMsg &msg,
|
||||
const ProtoAddress &srcAddr,
|
||||
const ProtoAddress &dstAddr);
|
||||
void Usage()
|
||||
{
|
||||
fprintf(stderr, "pcap2norm [pcapInputFile [outputFile]]\n");
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// Use stdin/stdout by default
|
||||
FILE* infile = stdin;
|
||||
FILE* outfile = stdout;
|
||||
switch(argc)
|
||||
FILE *infile = stdin;
|
||||
FILE *outfile = stdout;
|
||||
switch (argc)
|
||||
{
|
||||
case 1:
|
||||
// using default stdin/stdout
|
||||
break;
|
||||
case 2:
|
||||
// using named input pcap file and stdout
|
||||
if (NULL == (infile = fopen(argv[1], "r")))
|
||||
{
|
||||
perror("pcap2norm: error opening input file");
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
// use name input and output files
|
||||
if (NULL == (infile = fopen(argv[1], "r")))
|
||||
{
|
||||
perror("pcap2norm: error opening input file");
|
||||
return -1;
|
||||
}
|
||||
if (NULL == (outfile = fopen(argv[2], "w+")))
|
||||
{
|
||||
perror("pcap2norm: error opening output file");
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "pcap2norm: error: too many arguments!\n");
|
||||
Usage();
|
||||
case 1:
|
||||
// using default stdin/stdout
|
||||
break;
|
||||
case 2:
|
||||
// using named input pcap file and stdout
|
||||
if (NULL == (infile = fopen(argv[1], "r")))
|
||||
{
|
||||
perror("pcap2norm: error opening input file");
|
||||
return -1;
|
||||
} // end switch(argc)
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
// use name input and output files
|
||||
if (NULL == (infile = fopen(argv[1], "r")))
|
||||
{
|
||||
perror("pcap2norm: error opening input file");
|
||||
return -1;
|
||||
}
|
||||
if (NULL == (outfile = fopen(argv[2], "w+")))
|
||||
{
|
||||
perror("pcap2norm: error opening output file");
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "pcap2norm: error: too many arguments!\n");
|
||||
Usage();
|
||||
return -1;
|
||||
} // end switch(argc)
|
||||
|
||||
char pcapErrBuf[PCAP_ERRBUF_SIZE+1];
|
||||
char pcapErrBuf[PCAP_ERRBUF_SIZE + 1];
|
||||
pcapErrBuf[PCAP_ERRBUF_SIZE] = '\0';
|
||||
pcap_t* pcapDevice = pcap_fopen_offline(infile, pcapErrBuf);
|
||||
pcap_t *pcapDevice = pcap_fopen_offline(infile, pcapErrBuf);
|
||||
if (NULL == pcapDevice)
|
||||
{
|
||||
fprintf(stderr, "pcap2norm: pcap_fopen_offline() error: %s\n", pcapErrBuf);
|
||||
if (stdin != infile) fclose(infile);
|
||||
if (stdout != outfile) fclose(outfile);
|
||||
if (stdin != infile)
|
||||
fclose(infile);
|
||||
if (stdout != outfile)
|
||||
fclose(outfile);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int deviceType = pcap_datalink(pcapDevice);
|
||||
|
||||
UINT32 alignedBuffer[4096/4]; // 4096 byte buffer for packet parsing
|
||||
UINT16* ethBuffer = ((UINT16*)alignedBuffer) + 1;
|
||||
unsigned int maxBytes = 4096 - 2; // due to offset, can only use 4094 bytes of buffer
|
||||
UINT32 alignedBuffer[4096 / 4]; // 4096 byte buffer for packet parsing
|
||||
UINT16 *ethBuffer = ((UINT16 *)alignedBuffer) + 1;
|
||||
unsigned int maxBytes = 4096 - 2; // due to offset, can only use 4094 bytes of buffer
|
||||
|
||||
pcap_pkthdr hdr;
|
||||
const u_char* pktData;
|
||||
while(NULL != (pktData = pcap_next(pcapDevice, &hdr)))
|
||||
const u_char *pktData;
|
||||
while (NULL != (pktData = pcap_next(pcapDevice, &hdr)))
|
||||
{
|
||||
unsigned int numBytes = maxBytes;
|
||||
if (hdr.caplen < numBytes) numBytes = hdr.caplen;
|
||||
if (hdr.caplen < numBytes)
|
||||
numBytes = hdr.caplen;
|
||||
ProtoPktETH::Type ethType;
|
||||
unsigned int payloadLength;
|
||||
UINT32* payloadPtr;
|
||||
UINT32 *payloadPtr;
|
||||
if (DLT_NULL == deviceType)
|
||||
{
|
||||
// pcap was captured from "loopback" device
|
||||
memcpy(alignedBuffer, pktData, numBytes);
|
||||
switch (alignedBuffer[0])
|
||||
{
|
||||
case PF_INET:
|
||||
ethType = ProtoPktETH::IP;
|
||||
break;
|
||||
case PF_INET6:
|
||||
ethType = ProtoPktETH::IPv6;
|
||||
break;
|
||||
default:
|
||||
continue; // not an IP packet
|
||||
case PF_INET:
|
||||
ethType = ProtoPktETH::IP;
|
||||
break;
|
||||
case PF_INET6:
|
||||
ethType = ProtoPktETH::IPv6;
|
||||
break;
|
||||
default:
|
||||
continue; // not an IP packet
|
||||
}
|
||||
payloadLength = numBytes - 4;
|
||||
payloadPtr = alignedBuffer + 1;
|
||||
|
|
@ -114,7 +116,7 @@ int main(int argc, char* argv[])
|
|||
ethType = ethPkt.GetType();
|
||||
payloadLength = ethPkt.GetPayloadLength();
|
||||
// This is done know we offset the ethBuffer above
|
||||
payloadPtr = alignedBuffer + (2 + ethPkt.GetLength() - ethPkt.GetPayloadLength())/4;
|
||||
payloadPtr = alignedBuffer + (2 + ethPkt.GetLength() - ethPkt.GetPayloadLength()) / 4;
|
||||
//payloadPtr = (UINT32*)ethPkt.AccessPayload();
|
||||
}
|
||||
|
||||
|
|
@ -130,25 +132,25 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
switch (ipPkt.GetVersion())
|
||||
{
|
||||
case 4:
|
||||
{
|
||||
ProtoPktIPv4 ip4Pkt(ipPkt);
|
||||
ip4Pkt.GetDstAddr(dstAddr);
|
||||
ip4Pkt.GetSrcAddr(srcAddr);
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
ProtoPktIPv6 ip6Pkt(ipPkt);
|
||||
ip6Pkt.GetDstAddr(dstAddr);
|
||||
ip6Pkt.GetSrcAddr(srcAddr);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
PLOG(PL_ERROR,"pcap2norm Error: Invalid IP pkt version.\n");
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
ProtoPktIPv4 ip4Pkt(ipPkt);
|
||||
ip4Pkt.GetDstAddr(dstAddr);
|
||||
ip4Pkt.GetSrcAddr(srcAddr);
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
ProtoPktIPv6 ip6Pkt(ipPkt);
|
||||
ip6Pkt.GetDstAddr(dstAddr);
|
||||
ip6Pkt.GetSrcAddr(srcAddr);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
PLOG(PL_ERROR, "pcap2norm Error: Invalid IP pkt version.\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
//PLOG(PL_ALWAYS, "pcap2norm IP packet dst>%s ", dstAddr.GetHostString());
|
||||
//PLOG(PL_ALWAYS," src>%s length>%d\n", srcAddr.GetHostString(), ipPkt.GetLength());
|
||||
|
|
@ -157,13 +159,15 @@ int main(int argc, char* argv[])
|
|||
{
|
||||
fprintf(stderr, "eth type = %d\n", ethType);
|
||||
}
|
||||
if (!srcAddr.IsValid()) continue; // wasn't an IP packet
|
||||
if (!srcAddr.IsValid())
|
||||
continue; // wasn't an IP packet
|
||||
|
||||
ProtoPktUDP udpPkt;
|
||||
if (!udpPkt.InitFromPacket(ipPkt)) continue; // not a UDP packet
|
||||
if (!udpPkt.InitFromPacket(ipPkt))
|
||||
continue; // not a UDP packet
|
||||
|
||||
NormMsg msg;
|
||||
if (msg.CopyFromBuffer((const char*)udpPkt.GetPayload(), udpPkt.GetPayloadLength()))
|
||||
if (msg.CopyFromBuffer((const char *)udpPkt.GetPayload(), udpPkt.GetPayloadLength()))
|
||||
{
|
||||
srcAddr.SetPort(udpPkt.GetSrcPort());
|
||||
msg.AccessAddress() = srcAddr;
|
||||
|
|
@ -174,49 +178,45 @@ int main(int argc, char* argv[])
|
|||
{
|
||||
fprintf(stderr, "pcap2norm warning: UDP packet not an MGEN packet?\n");
|
||||
}
|
||||
} // end while (pcap_next())
|
||||
|
||||
} // end main()
|
||||
} // end while (pcap_next())
|
||||
|
||||
} // end main()
|
||||
|
||||
static UINT8 lastFecId = 0;
|
||||
|
||||
void NormTrace2(const struct timeval& currentTime,
|
||||
const NormMsg& msg,
|
||||
const ProtoAddress& srcAddr,
|
||||
const ProtoAddress& dstAddr)
|
||||
void NormTrace2(const struct timeval ¤tTime,
|
||||
const NormMsg &msg,
|
||||
const ProtoAddress &srcAddr,
|
||||
const ProtoAddress &dstAddr)
|
||||
{
|
||||
|
||||
UINT8 fecM = 8; // NOTE - this assumes 16-bit RS code for fec_id == 2
|
||||
UINT8 fecM = 8; // NOTE - this assumes 16-bit RS code for fec_id == 2
|
||||
|
||||
static const char* MSG_NAME[] =
|
||||
{
|
||||
"INVALID",
|
||||
"INFO",
|
||||
"DATA",
|
||||
"CMD",
|
||||
"NACK",
|
||||
"ACK",
|
||||
"REPORT"
|
||||
};
|
||||
static const char* CMD_NAME[] =
|
||||
{
|
||||
"CMD(INVALID)",
|
||||
"CMD(FLUSH)",
|
||||
"CMD(EOT)",
|
||||
"CMD(SQUELCH)",
|
||||
"CMD(CC)",
|
||||
"CMD(REPAIR_ADV)",
|
||||
"CMD(ACK_REQ)",
|
||||
"CMD(APP)"
|
||||
};
|
||||
static const char* REQ_NAME[] =
|
||||
{
|
||||
"INVALID",
|
||||
"WATERMARK",
|
||||
"RTT",
|
||||
"APP"
|
||||
};
|
||||
static const char *MSG_NAME[] =
|
||||
{
|
||||
"INVALID",
|
||||
"INFO",
|
||||
"DATA",
|
||||
"CMD",
|
||||
"NACK",
|
||||
"ACK",
|
||||
"REPORT"};
|
||||
static const char *CMD_NAME[] =
|
||||
{
|
||||
"CMD(INVALID)",
|
||||
"CMD(FLUSH)",
|
||||
"CMD(EOT)",
|
||||
"CMD(SQUELCH)",
|
||||
"CMD(CC)",
|
||||
"CMD(REPAIR_ADV)",
|
||||
"CMD(ACK_REQ)",
|
||||
"CMD(APP)"};
|
||||
static const char *REQ_NAME[] =
|
||||
{
|
||||
"INVALID",
|
||||
"WATERMARK",
|
||||
"RTT",
|
||||
"APP"};
|
||||
|
||||
NormMsg::Type msgType = msg.GetType();
|
||||
UINT16 length = msg.GetLength();
|
||||
|
|
@ -226,55 +226,52 @@ void NormTrace2(const struct timeval& currentTime,
|
|||
srcAddr.GetHostString(src, 63);
|
||||
dstAddr.GetHostString(dst, 63);
|
||||
|
||||
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
struct tm timeStruct;
|
||||
timeStruct.tm_hour = currentTime.tv_sec / 3600;
|
||||
unsigned long hourSecs = 3600 * timeStruct.tm_hour;
|
||||
timeStruct.tm_min = (currentTime.tv_sec - (hourSecs)) / 60;
|
||||
timeStruct.tm_sec = currentTime.tv_sec - (hourSecs) - (60*timeStruct.tm_min);
|
||||
timeStruct.tm_sec = currentTime.tv_sec - (hourSecs) - (60 * timeStruct.tm_min);
|
||||
timeStruct.tm_hour = timeStruct.tm_hour % 24;
|
||||
struct tm* ct = &timeStruct;
|
||||
struct tm *ct = &timeStruct;
|
||||
#else
|
||||
time_t secs = (time_t)currentTime.tv_sec;
|
||||
struct tm* ct = gmtime(&secs);
|
||||
struct tm *ct = gmtime(&secs);
|
||||
#endif // if/else _WIN32_WCE
|
||||
|
||||
|
||||
PLOG(PL_ALWAYS, "trace>%02d:%02d:%02d.%06lu ",
|
||||
(int)ct->tm_hour, (int)ct->tm_min, (int)ct->tm_sec, (unsigned int)currentTime.tv_usec);
|
||||
(int)ct->tm_hour, (int)ct->tm_min, (int)ct->tm_sec, (unsigned int)currentTime.tv_usec);
|
||||
PLOG(PL_ALWAYS, "src>%s/%hu dst>%s/%hu id>0x%08x ", src, srcAddr.GetPort(), dst, dstAddr.GetPort(), (UINT32)msg.GetSourceId());
|
||||
|
||||
bool clrFlag = false;
|
||||
switch (msgType)
|
||||
{
|
||||
case NormMsg::INFO:
|
||||
{
|
||||
const NormInfoMsg& info = (const NormInfoMsg&)msg;
|
||||
lastFecId = info.GetFecId();
|
||||
PLOG(PL_ALWAYS, "inst>%hu seq>%hu INFO obj>%hu ",
|
||||
info.GetInstanceId(), seq, (UINT16)info.GetObjectId());
|
||||
break;
|
||||
}
|
||||
case NormMsg::DATA:
|
||||
{
|
||||
const NormDataMsg& data = (const NormDataMsg&)msg;
|
||||
lastFecId = data.GetFecId();
|
||||
PLOG(PL_ALWAYS, "inst>%hu seq>%hu DATA obj>%hu blk>%u seg>%04hu ",
|
||||
data.GetInstanceId(),
|
||||
seq,
|
||||
//data.IsData() ? "DATA" : "PRTY",
|
||||
(UINT16)data.GetObjectId(),
|
||||
(UINT32)data.GetFecBlockId(fecM).GetValue(),
|
||||
(UINT16)data.GetFecSymbolId(fecM));
|
||||
case NormMsg::INFO:
|
||||
{
|
||||
const NormInfoMsg &info = (const NormInfoMsg &)msg;
|
||||
lastFecId = info.GetFecId();
|
||||
PLOG(PL_ALWAYS, "inst>%hu seq>%hu INFO obj>%hu ",
|
||||
info.GetInstanceId(), seq, (UINT16)info.GetObjectId());
|
||||
break;
|
||||
}
|
||||
case NormMsg::DATA:
|
||||
{
|
||||
const NormDataMsg &data = (const NormDataMsg &)msg;
|
||||
lastFecId = data.GetFecId();
|
||||
PLOG(PL_ALWAYS, "inst>%hu seq>%hu DATA obj>%hu blk>%u seg>%04hu ",
|
||||
data.GetInstanceId(),
|
||||
seq,
|
||||
//data.IsData() ? "DATA" : "PRTY",
|
||||
(UINT16)data.GetObjectId(),
|
||||
(UINT32)data.GetFecBlockId(fecM).GetValue(),
|
||||
(UINT16)data.GetFecSymbolId(fecM));
|
||||
|
||||
if (data.IsStream())
|
||||
{
|
||||
UINT32 offset = NormDataMsg::ReadStreamPayloadOffset(data.GetPayload());
|
||||
PLOG(PL_ALWAYS, "offset>%lu ", offset);
|
||||
}
|
||||
/*
|
||||
if (data.IsStream())
|
||||
{
|
||||
UINT32 offset = NormDataMsg::ReadStreamPayloadOffset(data.GetPayload());
|
||||
PLOG(PL_ALWAYS, "offset>%lu ", offset);
|
||||
}
|
||||
/*
|
||||
if (data.IsData() && data.IsStream())
|
||||
{
|
||||
//if (NormDataMsg::StreamPayloadFlagIsSet(data.GetPayload(), NormDataMsg::FLAG_MSG_START))
|
||||
|
|
@ -288,124 +285,124 @@ void NormTrace2(const struct timeval& currentTime,
|
|||
PLOG(PL_ALWAYS, "(stream end) ");
|
||||
}
|
||||
*/
|
||||
break;
|
||||
}
|
||||
case NormMsg::CMD:
|
||||
{
|
||||
const NormCmdMsg &cmd = static_cast<const NormCmdMsg &>(msg);
|
||||
NormCmdMsg::Flavor flavor = cmd.GetFlavor();
|
||||
PLOG(PL_ALWAYS, "inst>%hu seq>%hu %s ", cmd.GetInstanceId(), seq, CMD_NAME[flavor]);
|
||||
switch (flavor)
|
||||
{
|
||||
case NormCmdMsg::ACK_REQ:
|
||||
{
|
||||
int index = ((const NormCmdAckReqMsg &)msg).GetAckType();
|
||||
index = MIN(index, 3);
|
||||
PLOG(PL_ALWAYS, "(%s) ", REQ_NAME[index]);
|
||||
break;
|
||||
}
|
||||
case NormMsg::CMD:
|
||||
case NormCmdMsg::SQUELCH:
|
||||
{
|
||||
const NormCmdMsg& cmd = static_cast<const NormCmdMsg&>(msg);
|
||||
NormCmdMsg::Flavor flavor = cmd.GetFlavor();
|
||||
PLOG(PL_ALWAYS, "inst>%hu seq>%hu %s ", cmd.GetInstanceId(), seq, CMD_NAME[flavor]);
|
||||
switch (flavor)
|
||||
{
|
||||
case NormCmdMsg::ACK_REQ:
|
||||
{
|
||||
int index = ((const NormCmdAckReqMsg&)msg).GetAckType();
|
||||
index = MIN(index, 3);
|
||||
PLOG(PL_ALWAYS, "(%s) ", REQ_NAME[index]);
|
||||
break;
|
||||
}
|
||||
case NormCmdMsg::SQUELCH:
|
||||
{
|
||||
const NormCmdSquelchMsg& squelch =
|
||||
static_cast<const NormCmdSquelchMsg&>(msg);
|
||||
PLOG(PL_ALWAYS, " obj>%hu blk>%lu seg>%hu ",
|
||||
(UINT16)squelch.GetObjectId(),
|
||||
(UINT32)squelch.GetFecBlockId(fecM).GetValue(),
|
||||
(UINT16)squelch.GetFecSymbolId(fecM));
|
||||
break;
|
||||
}
|
||||
case NormCmdMsg::FLUSH:
|
||||
{
|
||||
const NormCmdFlushMsg& flush =
|
||||
static_cast<const NormCmdFlushMsg&>(msg);
|
||||
PLOG(PL_ALWAYS, " obj>%hu blk>%lu seg>%hu ",
|
||||
(UINT16)flush.GetObjectId(),
|
||||
(UINT32)flush.GetFecBlockId(fecM).GetValue(),
|
||||
(UINT16)flush.GetFecSymbolId(fecM));
|
||||
const NormCmdSquelchMsg &squelch =
|
||||
static_cast<const NormCmdSquelchMsg &>(msg);
|
||||
PLOG(PL_ALWAYS, " obj>%hu blk>%lu seg>%hu ",
|
||||
(UINT16)squelch.GetObjectId(),
|
||||
(UINT32)squelch.GetFecBlockId(fecM).GetValue(),
|
||||
(UINT16)squelch.GetFecSymbolId(fecM));
|
||||
break;
|
||||
}
|
||||
case NormCmdMsg::FLUSH:
|
||||
{
|
||||
const NormCmdFlushMsg &flush =
|
||||
static_cast<const NormCmdFlushMsg &>(msg);
|
||||
PLOG(PL_ALWAYS, " obj>%hu blk>%lu seg>%hu ",
|
||||
(UINT16)flush.GetObjectId(),
|
||||
(UINT32)flush.GetFecBlockId(fecM).GetValue(),
|
||||
(UINT16)flush.GetFecSymbolId(fecM));
|
||||
|
||||
// Print acking node list (if any)
|
||||
UINT16 nodeCount = flush.GetAckingNodeCount();
|
||||
if (nodeCount > 0)
|
||||
{
|
||||
PLOG(PL_ALWAYS, "ackers>");
|
||||
for (UINT16 i = 0; i < nodeCount; i++)
|
||||
{
|
||||
if (i > 0) PLOG(PL_ALWAYS, ",");
|
||||
PLOG(PL_ALWAYS,"0x%08x", (UINT32)flush.GetAckingNodeId(i));
|
||||
}
|
||||
PLOG(PL_ALWAYS, " ");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NormCmdMsg::CC:
|
||||
// Print acking node list (if any)
|
||||
UINT16 nodeCount = flush.GetAckingNodeCount();
|
||||
if (nodeCount > 0)
|
||||
{
|
||||
PLOG(PL_ALWAYS, "ackers>");
|
||||
for (UINT16 i = 0; i < nodeCount; i++)
|
||||
{
|
||||
const NormCmdCCMsg& cc = static_cast<const NormCmdCCMsg&>(msg);
|
||||
PLOG(PL_ALWAYS, " seq>%u ", cc.GetCCSequence());
|
||||
NormHeaderExtension ext;
|
||||
while (cc.GetNextExtension(ext))
|
||||
{
|
||||
if (NormHeaderExtension::CC_RATE == ext.GetType())
|
||||
{
|
||||
UINT16 sendRate = ((NormCCRateExtension&)ext).GetSendRate();
|
||||
PLOG(PL_ALWAYS, " rate>%f ", 8.0e-03 * NormUnquantizeRate(sendRate));
|
||||
break;
|
||||
}
|
||||
}
|
||||
struct timeval sendTime;
|
||||
cc.GetSendTime(sendTime);
|
||||
double delay = ProtoTime::Delta(ProtoTime(currentTime), ProtoTime(sendTime));
|
||||
PLOG(PL_ALWAYS, "delay>%lf ", delay);
|
||||
break;
|
||||
if (i > 0)
|
||||
PLOG(PL_ALWAYS, ",");
|
||||
PLOG(PL_ALWAYS, "0x%08x", (UINT32)flush.GetAckingNodeId(i));
|
||||
}
|
||||
default:
|
||||
break;
|
||||
PLOG(PL_ALWAYS, " ");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case NormMsg::ACK:
|
||||
case NormMsg::NACK:
|
||||
case NormCmdMsg::CC:
|
||||
{
|
||||
PLOG(PL_ALWAYS, "%s ", MSG_NAME[msgType]);
|
||||
// look for NormCCFeedback extension
|
||||
const NormCmdCCMsg &cc = static_cast<const NormCmdCCMsg &>(msg);
|
||||
PLOG(PL_ALWAYS, " seq>%u ", cc.GetCCSequence());
|
||||
NormHeaderExtension ext;
|
||||
while (msg.GetNextExtension(ext))
|
||||
while (cc.GetNextExtension(ext))
|
||||
{
|
||||
if (NormHeaderExtension::CC_FEEDBACK == ext.GetType())
|
||||
if (NormHeaderExtension::CC_RATE == ext.GetType())
|
||||
{
|
||||
clrFlag = ((NormCCFeedbackExtension&)ext).CCFlagIsSet(NormCC::CLR);
|
||||
// Print ccRtt (only valid if pcap file is from sender node)
|
||||
double ccRtt = NormUnquantizeRtt(((NormCCFeedbackExtension&)ext).GetCCRtt());
|
||||
double ccLoss = NormUnquantizeLoss32(((NormCCFeedbackExtension&)ext).GetCCLoss32());
|
||||
PLOG(PL_ALWAYS, "ccRtt:%lf ccLoss:%lf ", ccRtt, ccLoss);
|
||||
UINT16 sendRate = ((NormCCRateExtension &)ext).GetSendRate();
|
||||
PLOG(PL_ALWAYS, " rate>%f ", 8.0e-03 * NormUnquantizeRate(sendRate));
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Print locally measured rtt (only valid if pcap file is from sender node)
|
||||
struct timeval grttResponse;
|
||||
if (NormMsg::NACK == msgType)
|
||||
static_cast<const NormNackMsg&>(msg).GetGrttResponse(grttResponse);
|
||||
else
|
||||
static_cast<const NormAckMsg&>(msg).GetGrttResponse(grttResponse);
|
||||
|
||||
double rtt = ProtoTime::Delta(ProtoTime(currentTime), ProtoTime(grttResponse));
|
||||
PLOG(PL_ALWAYS, "rtt:%lf ", rtt);
|
||||
|
||||
PLOG(PL_ALWAYS, "len>%hu %s\n", length, clrFlag ? "(CLR)" : "");
|
||||
if (NormMsg::NACK == msgType)
|
||||
{
|
||||
const NormNackMsg& nack = static_cast<const NormNackMsg&>(msg);
|
||||
PLOG(PL_ALWAYS, "repair content for sender id 0x%08x)\n", nack.GetSenderId());
|
||||
LogRepairContent(nack.GetRepairContent(), nack.GetRepairContentLength(), lastFecId, fecM);
|
||||
}
|
||||
return;
|
||||
struct timeval sendTime;
|
||||
cc.GetSendTime(sendTime);
|
||||
double delay = ProtoTime::Delta(ProtoTime(currentTime), ProtoTime(sendTime));
|
||||
PLOG(PL_ALWAYS, "delay>%lf ", delay);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
PLOG(PL_ALWAYS, "%s ", MSG_NAME[msgType]);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case NormMsg::ACK:
|
||||
case NormMsg::NACK:
|
||||
{
|
||||
PLOG(PL_ALWAYS, "%s ", MSG_NAME[msgType]);
|
||||
// look for NormCCFeedback extension
|
||||
NormHeaderExtension ext;
|
||||
while (msg.GetNextExtension(ext))
|
||||
{
|
||||
if (NormHeaderExtension::CC_FEEDBACK == ext.GetType())
|
||||
{
|
||||
clrFlag = ((NormCCFeedbackExtension &)ext).CCFlagIsSet(NormCC::CLR);
|
||||
// Print ccRtt (only valid if pcap file is from sender node)
|
||||
double ccRtt = NormUnquantizeRtt(((NormCCFeedbackExtension &)ext).GetCCRtt());
|
||||
double ccLoss = NormUnquantizeLoss32(((NormCCFeedbackExtension &)ext).GetCCLoss32());
|
||||
PLOG(PL_ALWAYS, "ccRtt:%lf ccLoss:%lf ", ccRtt, ccLoss);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Print locally measured rtt (only valid if pcap file is from sender node)
|
||||
struct timeval grttResponse;
|
||||
if (NormMsg::NACK == msgType)
|
||||
static_cast<const NormNackMsg &>(msg).GetGrttResponse(grttResponse);
|
||||
else
|
||||
static_cast<const NormAckMsg &>(msg).GetGrttResponse(grttResponse);
|
||||
|
||||
double rtt = ProtoTime::Delta(ProtoTime(currentTime), ProtoTime(grttResponse));
|
||||
PLOG(PL_ALWAYS, "rtt:%lf ", rtt);
|
||||
|
||||
PLOG(PL_ALWAYS, "len>%hu %s\n", length, clrFlag ? "(CLR)" : "");
|
||||
if (NormMsg::NACK == msgType)
|
||||
{
|
||||
const NormNackMsg &nack = static_cast<const NormNackMsg &>(msg);
|
||||
PLOG(PL_ALWAYS, "repair content for sender id 0x%08x)\n", nack.GetSenderId());
|
||||
LogRepairContent(nack.GetRepairContent(), nack.GetRepairContentLength(), lastFecId, fecM);
|
||||
}
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
PLOG(PL_ALWAYS, "%s ", MSG_NAME[msgType]);
|
||||
break;
|
||||
}
|
||||
PLOG(PL_ALWAYS, "len>%hu %s\n", length, clrFlag ? "(CLR)" : "");
|
||||
} // end NormTrace2();
|
||||
|
||||
} // end NormTrace2();
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
*/
|
||||
|
||||
// Some portions of this code
|
||||
// Copyright © 1996 Netscape Communications Corporation,
|
||||
// Copyright <EFBFBD> 1996 Netscape Communications Corporation,
|
||||
// all rights reserved.
|
||||
|
||||
#include "normPostProcess.h"
|
||||
|
|
|
|||
Loading…
Reference in New Issue