summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2014-10-27 14:25:00 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2014-10-27 14:25:00 -0700
commit295f6a20e0e0c9e4d99472f1580963ffc424619c (patch)
tree99433fb5bc2a71cabe8e8583d015e034511c572d
parent6a94a4a51b44eede88971b6be699abf60eca716c (diff)
downloadinfinitytier-295f6a20e0e0c9e4d99472f1580963ffc424619c.tar.gz
infinitytier-295f6a20e0e0c9e4d99472f1580963ffc424619c.zip
Testnet works! sort of...
-rw-r--r--testnet.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/testnet.cpp b/testnet.cpp
index 7a77b8d9..d68b63ce 100644
--- a/testnet.cpp
+++ b/testnet.cpp
@@ -28,6 +28,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
+#include <string.h>
#include <string>
#include <map>
@@ -467,10 +468,10 @@ static void doListPeers(const std::vector<std::string> &cmd)
static void doUnicast(const std::vector<std::string> &cmd)
{
- volatile union {
+ union {
uint64_t ts;
unsigned char data[2800];
- } pkt,inpkt;
+ } pkt;
if (cmd.size() < 5) {
doHelp(cmd);
@@ -523,7 +524,7 @@ static void doUnicast(const std::vector<std::string> &cmd)
if ((stap)&&(rtap)) {
pkt.ts = Utils::now();
- tap->injectPacketFromHost(stap->mac(),rtap->mac(),0xdead,pkt.data,frameLen);
+ stap->injectPacketFromHost(stap->mac(),rtap->mac(),0xdead,pkt.data,frameLen);
printf("%s -> %s etherType 0xdead network %.16llx length %u"ZT_EOL_S,s->toString().c_str(),r->toString().c_str(),nwid,frameLen);
} else if (stap)
printf("%s -> !%s (receiver not a member of %.16llx)"ZT_EOL_S,s->toString().c_str(),r->toString().c_str(),nwid);
@@ -533,7 +534,7 @@ static void doUnicast(const std::vector<std::string> &cmd)
}
}
- printf("---------- waiting up to %llu seconds...",tout / 1000ULL);
+ printf("---------- waiting up to %llu seconds..."ZT_EOL_S,tout / 1000ULL);
std::set<Address> receivedFrom;
uint64_t toutend = Utils::now() + tout;
@@ -547,11 +548,22 @@ static void doUnicast(const std::vector<std::string> &cmd)
for(std::vector<TestEthernetTap::TestFrame>::iterator f(frames.begin());f!=frames.end();++f) {
if ((f->len == frameLen)&&(!memcmp(f->data + 8,pkt.data + 8,frameLen - 8))) {
receivedFrom.insert(*r);
+ uint64_t ints = 0;
+ memcpy(&ints,f->data,8);
+ printf("%s received test packet, latency == %llums"ZT_EOL_S,r->toString().c_str(),f->timestamp - ints);
+ } else {
+ printf("%s received spurious packet, length == %u, etherType == %.4x"ZT_EOL_S,r->toString().c_str(),f->len,f->etherType);
}
}
}
}
} while ((receivedFrom.size() < receivers.size())&&(Utils::now() < toutend));
+
+ for(std::vector<Address>::iterator r(receivers.begin());r!=receivers.end();++r) {
+ if (!receivedFrom.count(*r)) {
+ printf("%s did not receive test packet: timed out"ZT_EOL_S,r->toString().c_str());
+ }
+ }
}
int main(int argc,char **argv)