Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

how to change packet length in the packet header for every incoming packet

I am getting "Frame 1 too long(18109400 bytes)" error. How to solve this? Thanks in advance.

click to hide/show revision 2
None

how to change packet length in the packet header for every incoming packet

I am getting "Frame 1 too long(18109400 bytes)" error. How to solve this? Thanks in advance.

how to change packet length in the packet header for every incoming packet

Why am I am getting "Frame 1 too long(18109400 bytes)" error. How errors when capturing from a pipe to solve this? Thanks which my program is writing?

"#include <windows.h>" "#include <conio.h>" "#include <iostream>" "#include <string.h>" "#include <stdio.h>" "#include <stdlib.h>" "#include <tchar.h>" "#include <fstream>"

using namespace std;

// To read incoming data from serial port

bool ReadComString(HANDLE hCreateNamedPipe, char* pPuffer, int MaxLen) {

BOOL    bRetValue;
char    cZeichen;              //character
int     nZaehler = 0;          // counter
DWORD   nGelesen = 0;    // read 
do
{
    nGelesen = 0;
    do      // Timeout still set !!
        bRetValue = ReadFile(hCreateNamedPipe, &cZeichen, 1, &nGelesen, NULL);
    while ((0 == nGelesen) && bRetValue);

    if ((false == bRetValue) || (0 == nGelesen)) {
        cout << "Read failed" << GetLastError() << endl;
        return false;
    } //cout << "Read file success" << endl;

    switch (cZeichen)
    {
    case 0:
    case 0x0d:                  // CR They are used to mark a line break in advance.a text file.
        continue;
        break;
    case 0x0a:                  // LF  It is a control character used to reset the position of the cursor to the beginning of the next line of a text file.
        if (0 == nZaehler)      // Ignore at the beginning of the line
            continue;
        *pPuffer = 0;           // String abschließen  
        return true;            // Back to the call.
        break;

    default:
        *pPuffer = cZeichen;
        pPuffer++;
        nZaehler++;
    }
} while (nZaehler < MaxLen);
*(pPuffer - 1) = 0;               // String abschließen  
return true;

}

//Interpreting the string

int InterpretiereCulString(const char* pStringPuffer, char* pOutPuffer) {

char sConvBuffer[] = "0xzz";
int  nAnzahlZahlen = 0; //number of counters
unsigned int nIntWert;
int  nRetValue;
if ('A' != *pStringPuffer)
    return -1; // return error
pStringPuffer++;

while (true)
{
    if (0 == *pStringPuffer)
        return nAnzahlZahlen;
    sConvBuffer[2] = *pStringPuffer;
    pStringPuffer++;
    if (0 == *pStringPuffer)
        return -1; // return error meaning 2 consecutive zeros must not be present in  the packet data
    sConvBuffer[3] = *pStringPuffer;
    pStringPuffer++;
    nRetValue = sscanf_s(sConvBuffer, "%i", &nIntWert); // converts char to int and storing in the location of IntWert
    if (1 != nRetValue)
        return -1;
    //      nIntWert = atoi(sConvBuffer);
    *pOutPuffer = nIntWert;
    nAnzahlZahlen++;
    pOutPuffer++;
}
return 0;

}

bool WriteComString(HANDLE hCreateNamedPipe, const char* pPuffer) {

BOOL    bRetValue;
int     nAnzahlZeichen = 0; // Number of characters
DWORD   nAnzahlGeschrieben = 0; // number Posted

nAnzahlZeichen = strlen(pPuffer);
bRetValue = WriteFile(hCreateNamedPipe, pPuffer, nAnzahlZeichen, &nAnzahlGeschrieben, NULL);
if ((false == bRetValue) || (nAnzahlGeschrieben != nAnzahlZeichen))
{
    cout << "write file failed" << GetLastError() << endl;
    return false;
}
cout << "Write file success" << endl;
return true;

}

static HANDLE hPipe = NULL;

static void print_last_error(void) {

LPVOID lpMsgBuf;

FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
    NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
    (LPTSTR)& lpMsgBuf, 0, NULL);
MessageBox(NULL, (LPCSTR)lpMsgBuf, "GetLastError", MB_OK | MB_ICONINFORMATION);
LocalFree(lpMsgBuf);

}

// creating named pipe

static void named_pipe_create(void) {

hPipe = CreateNamedPipe(
    "\\\\.\\pipe\\wireshark",
    PIPE_ACCESS_OUTBOUND,
    PIPE_TYPE_MESSAGE | PIPE_WAIT,
    1, 65536, 65536,
    300,
    NULL);
if (hPipe == INVALID_HANDLE_VALUE) {
    print_last_error();
    return;
}
cout << "Pipe generated, wait for ConnectNamedPipe." << endl;
ConnectNamedPipe(hPipe, NULL);
cout << "pipe connected." << endl;

}

// Function to write packet data to the pipe

DWORD data_write(const void* ptr, size_t size, size_t nitems) {

DWORD cbWritten = 0;

(void)WriteFile(hPipe, ptr, size * nitems, &cbWritten, NULL);

return cbWritten;

}

void cleanup(void) {

if (hPipe) {
    FlushFileBuffers(hPipe);
    DisconnectNamedPipe(hPipe);
    CloseHandle(hPipe);
}

}

// Global header

pragma pack (push, 1)

typedef struct pcap_hdr_s {

uint32_t magic_number;
uint16_t version_major;
uint16_t version_minor;
int32_t thiszone;
uint32_t sigfigs;
uint32_t snaplen;
uint32_t network;

};

pragma pack (pop,1)

pragma pack (push,1)

typedef struct pcaprec_hdr_s {

uint32_t ts_sec; /*timestamp seconds */
uint32_t ts_usec; /*timestamp microseconds */
uint16_t incl_len; /*number of octets of packet saved in file */
uint16_t orig_len; /*actual length of packet */

} pcaprec_hdr_t;

pragma pack (pop,1)

int main(int argc, char* argv[]) {

COMMTIMEOUTS timeouts;
COMMCONFIG dcbSerialParams;

// To read serial port data

HANDLE hSerial = CreateFile(_T("COM6"), GENERIC_READ | GENERIC_WRITE,
    0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);

if (hSerial == INVALID_HANDLE_VALUE) {
    if (GetLastError() == ERROR_FILE_NOT_FOUND) {
        printf(" serial port does not exist \n");
    }
    printf(" some other error occured. Inform user.\n");
}

//DCB     dcbSerialParams ;
GetCommState(hSerial, &dcbSerialParams.dcb);
if (!GetCommState(hSerial, &dcbSerialParams.dcb)) {
    printf("error getting state \n");
}

dcbSerialParams.dcb.DCBlength = sizeof(dcbSerialParams.dcb);
dcbSerialParams.dcb.BaudRate = CBR_1200;
dcbSerialParams.dcb.ByteSize = 8;
dcbSerialParams.dcb.StopBits = ONESTOPBIT;
dcbSerialParams.dcb.Parity = NOPARITY;
dcbSerialParams.dcb.fBinary = TRUE;
dcbSerialParams.dcb.fDtrControl = DTR_CONTROL_DISABLE;
dcbSerialParams.dcb.fRtsControl = RTS_CONTROL_DISABLE;
dcbSerialParams.dcb.fOutxCtsFlow = FALSE;
dcbSerialParams.dcb.fOutxDsrFlow = FALSE;
dcbSerialParams.dcb.fDsrSensitivity = FALSE;
dcbSerialParams.dcb.fAbortOnError = TRUE;

if (!SetCommState(hSerial, &dcbSerialParams.dcb)) {
    printf(" error setting serial port state \n");
}

GetCommTimeouts(hSerial, &timeouts);
timeouts.ReadIntervalTimeout = 1000;
timeouts.ReadTotalTimeoutConstant = 1000;
timeouts.ReadTotalTimeoutMultiplier = 1000;
timeouts.WriteTotalTimeoutConstant = 1000;
timeouts.WriteTotalTimeoutMultiplier = 1000;

if (!SetCommTimeouts(hSerial, &timeouts)) {
    printf("error setting port state \n");
}

char RxPuffer[128];
bool bRetValue = false;
cout << "Initialising CUL" << endl;
bRetValue = WriteComString(hSerial, "V\r");
if (!bRetValue)
{
    CloseHandle(hSerial);
    cerr << "Error sending version query to port" << endl;
    return EXIT_FAILURE;
}
bRetValue = ReadComString(hSerial, RxPuffer, 255);
if (!bRetValue)
{
    CloseHandle(hSerial);
    cerr << "Error receiving version query on port" << endl;
    return EXIT_FAILURE;
}

cout << "Version validation CUL delivers: " << RxPuffer << endl;


char OutPuffer[200] = {0};
bRetValue = WriteComString(hSerial, "Ar\r");
if (!bRetValue)
{
    cerr << "Error sending the start command of the CUL to port" << endl;
    CloseHandle(hSerial);
    return EXIT_FAILURE;
}


cout << "Everything ready. Waiting for data from the CUL." << endl;

bool bLaufen = true;
int nAnzahlByte =0;
int counter = 0;

// Create and connect named pipe 

named_pipe_create(); //Function call
//Sleep(1000);

cout << "Start sending packages:" << endl;

// Set global header parameters

pcap_hdr_s pcap_hdr_tr;
pcap_hdr_tr.magic_number = 0xa1b2c3d4;
pcap_hdr_tr.version_major = 3;
pcap_hdr_tr.version_minor = 1;
pcap_hdr_tr.thiszone = 0;
pcap_hdr_tr.sigfigs = 0;
pcap_hdr_tr.snaplen = 65535;
pcap_hdr_tr.network = 0;


for (unsigned int i = 0; i < sizeof(pcap_hdr_tr); i++) {
    cout << " This is the global header :"<< hex << (unsigned int)((unsigned char*)&pcap_hdr_tr)[i] << endl;
}
    size_t num_read = 0;
num_read = sizeof(pcap_hdr_tr);
for (int i = 0; i < num_read; i++) {
    data_write(&pcap_hdr_tr, 1, num_read); // Function call to write global header to pipe 
}
cout << "Global header sent." << endl;

FILE* ptr_myfile;
ptr_myfile = fopen("test.pcap", "wb");
if (!ptr_myfile)
{
    printf("Unable to open file!");
    return 1;
}
fwrite((char*)&pcap_hdr_tr,sizeof(pcap_hdr_tr), 1, ptr_myfile);
printf("Global header written!");
fclose(ptr_myfile);

// while loop to continuously read the incoming data

while (bLaufen)
{

    bRetValue = ReadComString(hSerial, RxPuffer, 255);
    if (!bRetValue)
    {
        cerr << "Fehler beim Empfang eines Datenpaketes vom CUL an Port: " << endl;
        CloseHandle(hSerial);
        return EXIT_FAILURE;
    }

    nAnzahlByte = InterpretiereCulString(RxPuffer, OutPuffer);

//Setting packet header parameters

    pcaprec_hdr_s pcaprec_hdr_t;
    pcaprec_hdr_t.ts_sec = 0x885EB341;
    pcaprec_hdr_t.ts_usec = 0x0DD80400;
    pcaprec_hdr_t.incl_len = nAnzahlByte;
    pcaprec_hdr_t.orig_len = nAnzahlByte;



    for (unsigned int i = 0; i < sizeof(pcaprec_hdr_t); i++) {
        cout << " this is the packet header :" << hex << (unsigned int)((unsigned char*)&pcaprec_hdr_t)[i] << endl;
    }

    num_read = sizeof(pcaprec_hdr_t);
    for (int j = 0; j < num_read; j++) {
        data_write(&pcaprec_hdr_t, 1, num_read); // Function call to write packet header to pipe
    }
    cout << "Record sent." << endl;

    ptr_myfile = fopen("test.pcap", "wb");
    if (!ptr_myfile)
    {
        printf("Unable to open file!");
        return 1;
    }

    fwrite((char*)& pcaprec_hdr_t,sizeof(pcaprec_hdr_t), 1, ptr_myfile);
    printf("Packet header written!");
    fwrite((char*)&OutPuffer, sizeof(OutPuffer), 1, ptr_myfile);
    printf("Packet data written!");
    fclose(ptr_myfile);


    size_t num = 0;
    num = sizeof(OutPuffer);
    //data_write(&OutPuffer, nAnzahlByte, num);

        cout << "packet" << endl;
        //cout << hex << (unsigned int)((unsigned char*)OutPuffer) << endl;
        cout << "CUL liefert: " << RxPuffer << endl;
        //DWORD dwReadBufferSize = sizeof(OutPuffer);
        //DWORD dwNoBytesRead;

        for (int i = 0; i < nAnzahlByte; i++) {
            //(void)WriteFile(hPipe, &OutPuffer[i], dwReadBufferSize, &dwNoBytesRead, NULL);
            data_write(&OutPuffer[i], 1, 1); // Function call to write packet data to pipe

        }
        cout << "packet sent " << endl;


}
cleanup();


system("pause");
return EXIT_SUCCESS;

}

click to hide/show revision 4
No.4 Revision

Why am I getting "Frame 1 too long(18109400 bytes)" errors when capturing from a pipe to which my program is writing?

"#include <windows.h>" "#include <conio.h>" "#include <iostream>" "#include <string.h>" "#include <stdio.h>" "#include <stdlib.h>" "#include <tchar.h>" "#include <fstream>"

using namespace std;

// To read incoming data from serial port

bool ReadComString(HANDLE hCreateNamedPipe, char* pPuffer, int MaxLen) {

BOOL    bRetValue;
char    cZeichen;              //character
int     nZaehler = 0;          // counter
DWORD   nGelesen = 0;    // read 
do
{
    nGelesen = 0;
    do      // Timeout still set !!
        bRetValue = ReadFile(hCreateNamedPipe, &cZeichen, 1, &nGelesen, NULL);
    while ((0 == nGelesen) && bRetValue);

    if ((false == bRetValue) || (0 == nGelesen)) {
        cout << "Read failed" << GetLastError() << endl;
        return false;
    } //cout << "Read file success" << endl;

    switch (cZeichen)
    {
    case 0:
    case 0x0d:                  // CR They are used I am getting "Frame 1 too long(18109400 bytes)" error. How to mark a line break solve this?
Thanks in a text file.
        continue;
        break;
    case 0x0a:                  // LF  It is a control character used to reset the position of the cursor to the beginning of the next line of a text file.
        if (0 == nZaehler)      // Ignore at the beginning of the line
            continue;
        *pPuffer = 0;           // String abschließen  
        return true;            // Back to the call.
        break;

    default:
        *pPuffer = cZeichen;
        pPuffer++;
        nZaehler++;
    }
} while (nZaehler < MaxLen);
*(pPuffer - 1) = 0;               // String abschließen  
return true;

}

//Interpreting the string

int InterpretiereCulString(const char* pStringPuffer, char* pOutPuffer) {

char sConvBuffer[] = "0xzz";
int  nAnzahlZahlen = 0; //number of counters
unsigned int nIntWert;
int  nRetValue;
if ('A' != *pStringPuffer)
    return -1; // return error
pStringPuffer++;

while (true)
{
    if (0 == *pStringPuffer)
        return nAnzahlZahlen;
    sConvBuffer[2] = *pStringPuffer;
    pStringPuffer++;
    if (0 == *pStringPuffer)
        return -1; // return error meaning 2 consecutive zeros must not be present in  the packet data
    sConvBuffer[3] = *pStringPuffer;
    pStringPuffer++;
    nRetValue = sscanf_s(sConvBuffer, "%i", &nIntWert); // converts char to int and storing in the location of IntWert
    if (1 != nRetValue)
        return -1;
    //      nIntWert = atoi(sConvBuffer);
    *pOutPuffer = nIntWert;
    nAnzahlZahlen++;
    pOutPuffer++;
}
return 0;

}

bool WriteComString(HANDLE hCreateNamedPipe, const char* pPuffer) {

BOOL    bRetValue;
int     nAnzahlZeichen = 0; // Number of characters
DWORD   nAnzahlGeschrieben = 0; // number Posted

nAnzahlZeichen = strlen(pPuffer);
bRetValue = WriteFile(hCreateNamedPipe, pPuffer, nAnzahlZeichen, &nAnzahlGeschrieben, NULL);
if ((false == bRetValue) || (nAnzahlGeschrieben != nAnzahlZeichen))
{
    cout << "write file failed" << GetLastError() << endl;
    return false;
}
cout << "Write file success" << endl;
return true;

}

static HANDLE hPipe = NULL;

static void print_last_error(void) {

LPVOID lpMsgBuf;

FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
    NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
    (LPTSTR)& lpMsgBuf, 0, NULL);
MessageBox(NULL, (LPCSTR)lpMsgBuf, "GetLastError", MB_OK | MB_ICONINFORMATION);
LocalFree(lpMsgBuf);

}

// creating named pipe

static void named_pipe_create(void) {

hPipe = CreateNamedPipe(
    "\\\\.\\pipe\\wireshark",
    PIPE_ACCESS_OUTBOUND,
    PIPE_TYPE_MESSAGE | PIPE_WAIT,
    1, 65536, 65536,
    300,
    NULL);
if (hPipe == INVALID_HANDLE_VALUE) {
    print_last_error();
    return;
}
cout << "Pipe generated, wait for ConnectNamedPipe." << endl;
ConnectNamedPipe(hPipe, NULL);
cout << "pipe connected." << endl;

}

// Function to write packet data to the pipe

DWORD data_write(const void* ptr, size_t size, size_t nitems) {

DWORD cbWritten = 0;

(void)WriteFile(hPipe, ptr, size * nitems, &cbWritten, NULL);

return cbWritten;

}

void cleanup(void) {

if (hPipe) {
    FlushFileBuffers(hPipe);
    DisconnectNamedPipe(hPipe);
    CloseHandle(hPipe);
}

}

// Global header

pragma pack (push, 1)

typedef struct pcap_hdr_s {

uint32_t magic_number;
uint16_t version_major;
uint16_t version_minor;
int32_t thiszone;
uint32_t sigfigs;
uint32_t snaplen;
uint32_t network;

};

pragma pack (pop,1)

pragma pack (push,1)

typedef struct pcaprec_hdr_s {

uint32_t ts_sec; /*timestamp seconds */
uint32_t ts_usec; /*timestamp microseconds */
uint16_t incl_len; /*number of octets of packet saved in file */
uint16_t orig_len; /*actual length of packet */

} pcaprec_hdr_t;

pragma pack (pop,1)

int main(int argc, char* argv[]) {

COMMTIMEOUTS timeouts;
COMMCONFIG dcbSerialParams;

// To read serial port data

HANDLE hSerial = CreateFile(_T("COM6"), GENERIC_READ | GENERIC_WRITE,
    0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);

if (hSerial == INVALID_HANDLE_VALUE) {
    if (GetLastError() == ERROR_FILE_NOT_FOUND) {
        printf(" serial port does not exist \n");
    }
    printf(" some other error occured. Inform user.\n");
}

//DCB     dcbSerialParams ;
GetCommState(hSerial, &dcbSerialParams.dcb);
if (!GetCommState(hSerial, &dcbSerialParams.dcb)) {
    printf("error getting state \n");
}

dcbSerialParams.dcb.DCBlength = sizeof(dcbSerialParams.dcb);
dcbSerialParams.dcb.BaudRate = CBR_1200;
dcbSerialParams.dcb.ByteSize = 8;
dcbSerialParams.dcb.StopBits = ONESTOPBIT;
dcbSerialParams.dcb.Parity = NOPARITY;
dcbSerialParams.dcb.fBinary = TRUE;
dcbSerialParams.dcb.fDtrControl = DTR_CONTROL_DISABLE;
dcbSerialParams.dcb.fRtsControl = RTS_CONTROL_DISABLE;
dcbSerialParams.dcb.fOutxCtsFlow = FALSE;
dcbSerialParams.dcb.fOutxDsrFlow = FALSE;
dcbSerialParams.dcb.fDsrSensitivity = FALSE;
dcbSerialParams.dcb.fAbortOnError = TRUE;

if (!SetCommState(hSerial, &dcbSerialParams.dcb)) {
    printf(" error setting serial port state \n");
}

GetCommTimeouts(hSerial, &timeouts);
timeouts.ReadIntervalTimeout = 1000;
timeouts.ReadTotalTimeoutConstant = 1000;
timeouts.ReadTotalTimeoutMultiplier = 1000;
timeouts.WriteTotalTimeoutConstant = 1000;
timeouts.WriteTotalTimeoutMultiplier = 1000;

if (!SetCommTimeouts(hSerial, &timeouts)) {
    printf("error setting port state \n");
}

char RxPuffer[128];
bool bRetValue = false;
cout << "Initialising CUL" << endl;
bRetValue = WriteComString(hSerial, "V\r");
if (!bRetValue)
{
    CloseHandle(hSerial);
    cerr << "Error sending version query to port" << endl;
    return EXIT_FAILURE;
}
bRetValue = ReadComString(hSerial, RxPuffer, 255);
if (!bRetValue)
{
    CloseHandle(hSerial);
    cerr << "Error receiving version query on port" << endl;
    return EXIT_FAILURE;
}

cout << "Version validation CUL delivers: " << RxPuffer << endl;


char OutPuffer[200] = {0};
bRetValue = WriteComString(hSerial, "Ar\r");
if (!bRetValue)
{
    cerr << "Error sending the start command of the CUL to port" << endl;
    CloseHandle(hSerial);
    return EXIT_FAILURE;
}


cout << "Everything ready. Waiting for data from the CUL." << endl;

bool bLaufen = true;
int nAnzahlByte =0;
int counter = 0;

// Create and connect named pipe 

named_pipe_create(); //Function call
//Sleep(1000);

cout << "Start sending packages:" << endl;

// Set global header parameters

pcap_hdr_s pcap_hdr_tr;
pcap_hdr_tr.magic_number = 0xa1b2c3d4;
pcap_hdr_tr.version_major = 3;
pcap_hdr_tr.version_minor = 1;
pcap_hdr_tr.thiszone = 0;
pcap_hdr_tr.sigfigs = 0;
pcap_hdr_tr.snaplen = 65535;
pcap_hdr_tr.network = 0;


for (unsigned int i = 0; i < sizeof(pcap_hdr_tr); i++) {
    cout << " This is the global header :"<< hex << (unsigned int)((unsigned char*)&pcap_hdr_tr)[i] << endl;
}
    size_t num_read = 0;
num_read = sizeof(pcap_hdr_tr);
for (int i = 0; i < num_read; i++) {
    data_write(&pcap_hdr_tr, 1, num_read); // Function call to write global header to pipe 
}
cout << "Global header sent." << endl;

FILE* ptr_myfile;
ptr_myfile = fopen("test.pcap", "wb");
if (!ptr_myfile)
{
    printf("Unable to open file!");
    return 1;
}
fwrite((char*)&pcap_hdr_tr,sizeof(pcap_hdr_tr), 1, ptr_myfile);
printf("Global header written!");
fclose(ptr_myfile);

// while loop to continuously read the incoming data

while (bLaufen)
{

    bRetValue = ReadComString(hSerial, RxPuffer, 255);
    if (!bRetValue)
    {
        cerr << "Fehler beim Empfang eines Datenpaketes vom CUL an Port: " << endl;
        CloseHandle(hSerial);
        return EXIT_FAILURE;
    }

    nAnzahlByte = InterpretiereCulString(RxPuffer, OutPuffer);

//Setting packet header parameters

    pcaprec_hdr_s pcaprec_hdr_t;
    pcaprec_hdr_t.ts_sec = 0x885EB341;
    pcaprec_hdr_t.ts_usec = 0x0DD80400;
    pcaprec_hdr_t.incl_len = nAnzahlByte;
    pcaprec_hdr_t.orig_len = nAnzahlByte;



    for (unsigned int i = 0; i < sizeof(pcaprec_hdr_t); i++) {
        cout << " this is the packet header :" << hex << (unsigned int)((unsigned char*)&pcaprec_hdr_t)[i] << endl;
    }

    num_read = sizeof(pcaprec_hdr_t);
    for (int j = 0; j < num_read; j++) {
        data_write(&pcaprec_hdr_t, 1, num_read); // Function call to write packet header to pipe
    }
    cout << "Record sent." << endl;

    ptr_myfile = fopen("test.pcap", "wb");
    if (!ptr_myfile)
    {
        printf("Unable to open file!");
        return 1;
    }

    fwrite((char*)& pcaprec_hdr_t,sizeof(pcaprec_hdr_t), 1, ptr_myfile);
    printf("Packet header written!");
    fwrite((char*)&OutPuffer, sizeof(OutPuffer), 1, ptr_myfile);
    printf("Packet data written!");
    fclose(ptr_myfile);


    size_t num = 0;
    num = sizeof(OutPuffer);
    //data_write(&OutPuffer, nAnzahlByte, num);

        cout << "packet" << endl;
        //cout << hex << (unsigned int)((unsigned char*)OutPuffer) << endl;
        cout << "CUL liefert: " << RxPuffer << endl;
        //DWORD dwReadBufferSize = sizeof(OutPuffer);
        //DWORD dwNoBytesRead;

        for (int i = 0; i < nAnzahlByte; i++) {
            //(void)WriteFile(hPipe, &OutPuffer[i], dwReadBufferSize, &dwNoBytesRead, NULL);
            data_write(&OutPuffer[i], 1, 1); // Function call to write packet data to pipe

        }
        cout << "packet sent " << endl;


}
cleanup();


system("pause");
return EXIT_SUCCESS;

}advance.