The extendPdu example demonstrates how to replace Logger's default handling for a DIS PDU kind with a custom PDU class, keep encode/decode registration in sync with connection lifecycle, and update filter/UI naming so operators see the custom PDU name.
Table of Contents
What This Example Addresses
This plugin and class pair address three major Logger extension tasks:
- Extend the set of PDUs the Logger can decode, capture, and record.
- Re-register a PDU kind that Logger normally has by default.
- In this example, kind 200 is normally associated with an existing/default entry (for example, the NP Collision mapping in a default DIS descriptor).
- Conceptually, the example replaces that default NP Collision kind mapping with TestPduKind (kind 200) handled by ExtendPdu.
- The plugin re-registers kind 200 to use the example's TestPduKind and custom class/encoder path instead.
- Update filtering/UI naming to show the extended PDU name.
- The plugin rebuilds descriptor copies so kind 200 appears as "ExtendCustomPdu".
- This allows filter controls (including PDU type filter dialogs) to show the new name instead of the default one.
The ExtendPdu Class (extendPdu.h / extendPdu.cxx)
Purpose
ExtendPdu is a DtPdu subclass that demonstrates a variable-length DIS PDU layout while keeping a fixed PDU kind value (kind 200).
Network Representation
The class uses this layout concept:
- Header (DtNetPduHeader)
- Field a (int32)
- Field b (variable-length int32 array with cardinality a)
- Field c (float32, placed after b)
Because b is variable-length, c is located using byte arithmetic at runtime.
Key Behavior
The extendPdu Plugin (extendPduPlugin.cxx)
Responsibilities
The plugin installs a custom DIS protocol registration and does the following:
- Re-map kind 200 to the custom ExtendPdu creator/decoder.
- Re-register encoder handling for kind 200 (ExtendPduEncoder).
- Rename kind 200 in descriptor copies to "ExtendCustomPdu" so filters and related UI present the custom name.
- Keep registration valid across reconnects by re-registering after ExerciseConn changes in driver tick().
Runtime Flow
- EnableLoggerPlugin registers ExtendPduDisProtocolRegistration.
- That registration creates a custom DIS sim driver/interface stack.
- The driver:
- updates DIS descriptors with the custom name,
- re-registers creator/encoder when the active ExerciseConn changes,
- synchronizes the PDU filter descriptor copy so filter dialogs match.
- The interface also renames its descriptor copy to keep GUI-side reads aligned.
Why Rename and Re-register
Without these steps:
- Logger may continue decoding kind 200 using default behavior,
- filters can still display the old/default PDU name,
- reconnect events can drop custom creator/encoder registration.
This plugin explicitly handles all three concerns.
How To Run
Build the Plugin
- Build the extendPdu example target so the plugin library is produced (extendPduDIS on DIS builds).
- Confirm the built plugin is in Logger's plugin search path (typically bin/bin64 depending on platform/configuration).
Update lgrConfigDIS.xml
Update the DIS config so Logger loads this plugin as the protocol library.
In the <defaults> section:
- Set protocolLibrary to "extendPduDIS"
- Keep protocolGuiLibrary as the DIS GUI library (for example lgrSimGuiDIS)
Example:
<var name="protocolLibrary" type="string" value="extendPduDIS"/>
<var name="protocolGuiLibrary" type="string" value="lgrSimGuiDIS"/>
Why this is required:
- This plugin replaces the default DIS protocol registration path.
- If protocolLibrary remains the default (for example lgrSimDIS), the default registration may remain active and the custom kind-200 behavior is not guaranteed.
Start Logger and Verify
- Start Logger using the DIS config that references extendPduDIS.
- Connect to DIS traffic containing kind-200 packets.
- Verify in Logger/filter UI that kind 200 appears as "ExtendCustomPdu".
- Verify capture/record path processes these packets through the custom registration.
Optional Notes
- If you disconnect/reconnect, the plugin driver re-registers custom handlers when ExerciseConn changes.
- If you customize the PDU name/kind, update both descriptor rewrite logic and factory registration points consistently.
Source Code
extendPdu.h
#pragma once
#if DtDIS
#include <vl/pdu.h>
#include <vl/exerciseConnDIS.h>
{
{
public:
ExtendPdu(DtBufferPtr buffer = DtUSE_INTERNAL_BUFFER);
DtBufferPtr buffer = DtUSE_INTERNAL_BUFFER, DtPduFactory* pduFactory = 0);
virtual void setA(
int val);
virtual void setB(
int index,
int val);
virtual int b(
int index)
const;
virtual void setC(
float val);
public:
DtBufferPtr buffer = DtUSE_INTERNAL_BUFFER, DtPduFactory* pduFactory = 0);
protected:
};
#endif
extendPdu.cxx
#if DtDIS
#include <vl/pduFactory.h>
#include <iostream>
{
int minimalSize = sizeof(DtNetPduHeader) + sizeof(DtNetInt32) +
sizeof(DtFloat32);
initPdu(minimalSize, buffer);
}
{
}
{
initPdu(initial, buffer, pduFactory);
}
{}
{
if (this == &orig)
{
return *this;
}
DtPdu::operator=(orig);
return *this;
}
{
std::cout <<
"A: " <<
a() <<
"\n"
<< "B: \n";
for (
int index = 0; index <
a(); index++)
{
std::cout <<
b(index) <<
'\n';
}
std::cout <<
"C: " <<
c() << std::endl;
}
{
if (val > oldA)
{
(val - oldA) * sizeof(DtNetInt32));
}
else if (val < oldA)
{
deleteBytes(&(
netTestPdu()->
b[val]), (oldA - val) *
sizeof(DtNetInt32));
}
}
{
}
{
if (index < 0 || index >
a())
{
std::cout << "TestPdu::setB(): index out of range.\n";
return;
}
}
{
if (index < 0 || index >
a())
{
std::cout << "ExtendPdu::b(): index out of range.\n";
return 0;
}
}
{
DtNetFloat32* netC = (DtNetFloat32*)&(
netTestPdu()->
b[
a()]);
*netC = val;
}
{
DtNetFloat32* netC = (DtNetFloat32*)&(
netTestPdu()->
b[
a()]);
return *netC;
}
{
}
{
}
{
}
{
conn->addPduCallback(
TestPduKind, (DtPduCallbackFcn)cb, usr);
}
{
conn->removePduCallback(
TestPduKind, (DtPduCallbackFcn)cb, usr);
}
{
}
#endif
extendPduPlugin.cxx
#ifdef _WIN32
#ifdef EXTENDPDU_EXPORTS
#define DT_DLL_EXTPDU __declspec(dllexport)
#else
#define DT_DLL_EXTPDU __declspec(dllimport)
#endif
#else
#define DT_DLL_EXTPDU
#endif
#define DT_LGR_PLUGIN_EXPORT_MACRO DT_DLL_EXTPDU
#if DtDIS
#include <vl/exerciseConn.h>
#include <vl/pduEncoderFactory.h>
#include <vl/pduFactory.h>
#include <vl/pduEncoder.h>
namespace
{
{
if (!descRef)
{
return;
}
int entityIdOffset = 0;
int entityTypeOffset = 0;
if (testPduDesc)
{
}
{
{
}
}
delete descRef;
descRef = updatedDesc;
}
{
{
return;
}
setExtendCustomPduName(updatedDesc);
}
class ExtendPduEncoder : public DtPduEncoder
{
public:
virtual void encode(
DtPdu* pdu)
{
(void)pdu;
}
virtual DtPduEncoder* clone() const
{
return new ExtendPduEncoder(*this);
}
};
{
if (!exConn)
{
return;
}
setExtendCustomPduName(simManager);
DtPduEncoder* oldEncoder =
exConn->pduEncoderFactory()->addEncoder(
TestPduKind,
new ExtendPduEncoder());
delete oldEncoder;
}
class ExtendPduDisSimDriver;
{
public:
const ExtendPduDisSimDriver& driver);
protected:
};
{
public:
: MAKLogger::DtLgrDisSimDriver(driver)
, myRegisteredConn(0)
{
syncPduTypeFilterDescription();
}
{
return new ExtendPduDisSimDriver(driver);
}
{
if (!exConn)
{
myRegisteredConn = 0;
return;
}
if (exConn != myRegisteredConn)
{
registerExtendPdu(exConn, simMgr);
syncPduTypeFilterDescription();
myRegisteredConn = exConn;
}
}
private:
void syncPduTypeFilterDescription()
{
{
}
}
};
{
if (registration)
{
const ExtendPduDisSimDriver* simDriver =
dynamic_cast<const ExtendPduDisSimDriver*
>(mutableRegistration->
simDriver());
if (simDriver)
{
ExtendPduDisSimInterface* commandInterface =
ExtendPduDisSimInterface::createNonThreadsafe(logger, *simDriver);
return commandInterface;
}
}
return 0;
}
ExtendPduDisSimInterface* ExtendPduDisSimInterface::createNonThreadsafe(
{
return new ExtendPduDisSimInterface(logger, driver);
}
ExtendPduDisSimInterface::ExtendPduDisSimInterface(
: MAKLogger::DtLgrDisSimInterface(logger, driver)
{
setExtendCustomPduName(myDisDescriptor);
}
{
public:
: MAKLogger::DtLgrProtocolRegistration(&MAKLogger::DtDisStateObject::createBase,
&ExtendPduDisSimInterface::createBase,
MAKLogger::DtLgrCommandType::Protocol_DIS,
DtString("DIS"),
ExtendPduDisSimDriver::create(logger.driver()),
0)
{
MAKLogger::DtLgrEntityTracker::setCreator(MAKLogger::DtLgrDisEntityTracker::createBase);
&MAKLogger::DtLgrPduTypeFilter::createBase);
&MAKLogger::DtLgrDisEntityTypeFilter::createBase);
&MAKLogger::DtLgrEntityIdFilter::createBase);
&MAKLogger::DtLgrDisMarkingFilter::createBase);
&MAKLogger::DtLgrDisVRFMessageFilter::createBase);
MAKLogger::DtLgrDataViewSet::setCreator(&MAKLogger::DtLgrDisDataViewSet::createBase);
}
};
}
#endif
extern "C"
{
{
}
{
#if DtDIS
#else
(void)logger;
#endif
}
{
(void)loggerApp;
}
{
}
}