add 8 reserved bytes to -z protocol

pull/112/merge
bert hubert 2020-04-27 23:30:06 +02:00
parent 35e9195af8
commit 7c8ac749f7
3 changed files with 12 additions and 3 deletions

View File

@ -14,6 +14,7 @@
#include "zstdwrap.hh"
#include "CLI/CLI.hpp"
#include "version.hh"
#include <netinet/tcp.h>
static char program[]="navrecv";
@ -141,6 +142,7 @@ void writeToDisk(time_t s, uint64_t sourceid, std::string_view message)
// note that this moves the socket
void recvSession2(Socket&& uns, ComboAddress client)
{
string secret = SRead(uns, 8); // ignored for now
cerr << "Entering compressed session for "<<client.toStringWithPort()<<endl;
ZStdReader zsr(uns);
int s = zsr.getFD();
@ -174,6 +176,9 @@ void recvSession2(Socket&& uns, ComboAddress client)
denum = htonl(denum);
// cerr<<"Received message "<<denum<< " "<<nmm.localutcseconds()<<" " << nmm.localutcnanoseconds()/1000000000.0<<endl;
writeToDisk(nmm.localutcseconds(), nmm.sourceid(), out);
SSetsockopt(uns, IPPROTO_TCP, TCP_CORK, 1 );
SWrite(uns, num);
}
}

View File

@ -6,7 +6,7 @@
#include "navmon.hh"
#include <algorithm>
#include "zstdwrap.hh"
#include <netinet/tcp.h>
using namespace std;
void NMMSender::sendTCPThread(Destination* d)
@ -45,7 +45,8 @@ void NMMSender::sendTCPThread(Destination* d)
};
std::unique_ptr<ZStdCompressor> zsc;
if(d_compress) {
sc.writen("RNIE"); // the other magic value is "bert". hence.
sc.writen("RNIE00000000"); // the other magic value is "bert". hence.
// the 00000000 is a placeholder for a "secret" we might implement later
zsc = std::make_unique<ZStdCompressor>(emit, 20);
}
bool hadMessage=false;
@ -111,6 +112,9 @@ void NMMSender::sendTCPThread(Destination* d)
}
hadMessage = false;
usleep(100000);
#ifdef __linux__
SSetsockopt(s, IPPROTO_TCP, TCP_CORK, 1 );
#endif
}
}

View File

@ -566,7 +566,7 @@ int main(int argc, char** argv)
}
if (doDEBUG && m8t) { cerr<<humanTimeNow()<<" Detected timing module"<<endl; }
if (doDEBUG) { cerr<<humanTimeNow()<<" Sending serial number query"<<endl; }
msg = buildUbxMessage(0x27, 0x03, {});
msg = buildUbxMessage(0x27, 0x03, {}); // UBX-SEC-UNIQID
um1=sendAndWaitForUBX(fd, 1, msg, 0x27, 0x03); // ask for serial
serialno = fmt::sprintf("%02x%02x%02x%02x%02x",
um1.getPayload()[4],