Commit 7f9a4ddb authored by Jonathon Duerig's avatar Jonathon Duerig
Browse files

Added support for both Rubenstein & wavelet post-processing to the withLibpcap...

Added support for both Rubenstein & wavelet post-processing to the withLibpcap code. wavelet needs no extra steps, Rubenstein requires the use of the delay2dump script.
parent 81122822
# delay2dump.pl
if ($ARGV != 2)
{
die ("Usage: delay2dump.pl <in-file> <out-path>");
}
open (IN, "<".$ARGV[0]) or die("Cannot open ".$ARGV[0]);
open (OUT_SOURCE, ">".$ARGV[1]."/source.dump") or die("Cannot open source");
open (OUT_DEST1, ">".$ARGV[1]."/dest1.dump") or die("Cannot open dest 1");
open (OUT_DEST2, ">".$ARGV[1]."/dest2.dump") or die("Cannot open dest 2");
$sequence = 0;
while ($line = <IN>)
{
$line =~ /^([0-9.]+) ([0-9.]+) ([0-9.]+) ([0-9.]+)$/;
$send1 = $1;
$send2 = $2;
$delay1 = $3;
$delay2 = $4;
if ($send1 ne -9999 && $send2 ne -9999)
{
print (OUT_SOURCE, $send1." 10.0.0.2 ".$sequence);
print (OUT_SOURCE, $send2." 10.0.0.3 ".$sequence);
print (OUT_DEST1, ($send1 + $delay1)." 10.0.0.1 ".$sequence);
print (OUT_DEST2, ($send2 + $delay2)." 10.0.0.1 ".$sequence);
}
$sequence++;
}
...@@ -9,7 +9,7 @@ pathTwoDelayList = [] ...@@ -9,7 +9,7 @@ pathTwoDelayList = []
for delayLine in delayFileHandle.readlines(): for delayLine in delayFileHandle.readlines():
#{ #{
pathOneDelay, pathTwoDelay = delayLine.split() pathOneDelay, pathTwoDelay, ignore1, ignore2 = delayLine.split()
pathOneDelay = int(pathOneDelay) pathOneDelay = int(pathOneDelay)
pathTwoDelay = int(pathTwoDelay) pathTwoDelay = int(pathTwoDelay)
......
#include <stdlib.h> #include <stdlib.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include <string.h> #include <string.h>
#include <sys/time.h> #include <sys/time.h>
#include <pcap.h> #include <pcap.h>
#include <errno.h> #include <errno.h>
#include <netinet/in.h> #include <netinet/in.h>
...@@ -34,6 +34,7 @@ pcap_t *pcapDescriptor = NULL; ...@@ -34,6 +34,7 @@ pcap_t *pcapDescriptor = NULL;
using namespace std; using namespace std;
vector< vector< vector< vector<double> > > > sendTimesArray;
vector< vector< vector< vector<int> > > > delaySequenceArray; vector< vector< vector< vector<int> > > > delaySequenceArray;
vector< vector< vector< map<unsigned long long, int> > > > packetTimeMaps; vector< vector< vector< map<unsigned long long, int> > > > packetTimeMaps;
vector< vector< vector< map<string, unsigned long long> > > > actualTimeMaps; vector< vector< vector< map<string, unsigned long long> > > > actualTimeMaps;
...@@ -92,6 +93,7 @@ void handleUDP(struct pcap_pkthdr const *pcap_info, struct udphdr const *udpHdr, ...@@ -92,6 +93,7 @@ void handleUDP(struct pcap_pkthdr const *pcap_info, struct udphdr const *udpHdr,
cout <<" Orig timestamp was "<< tmpStrStream.str() << " , actual time = "<< actualTimeMaps[xIndex][yIndex][hostIndex][tmpStrStream.str()]<<"\n"; cout <<" Orig timestamp was "<< tmpStrStream.str() << " , actual time = "<< actualTimeMaps[xIndex][yIndex][hostIndex][tmpStrStream.str()]<<"\n";
cout <<"Packet time map Index = "<< packetTimeMaps[xIndex][yIndex][hostIndex][origTimestamp] << ", host index = " << hostIndex << " \n"; cout <<"Packet time map Index = "<< packetTimeMaps[xIndex][yIndex][hostIndex][origTimestamp] << ", host index = " << hostIndex << " \n";
delaySequenceArray[xIndex][yIndex][hostIndex][packetTimeMaps[xIndex][yIndex][hostIndex][origTimestamp]] = oneWayDelay - ( actualTimeMaps[xIndex][yIndex][hostIndex][tmpStrStream.str()] - origTimestamp); delaySequenceArray[xIndex][yIndex][hostIndex][packetTimeMaps[xIndex][yIndex][hostIndex][origTimestamp]] = oneWayDelay - ( actualTimeMaps[xIndex][yIndex][hostIndex][tmpStrStream.str()] - origTimestamp);
sendTimesArray[xIndex][yIndex][hostIndex][packetTimeMaps[xIndex][yIndex][hostIndex][origTimestamp]] = actualTimeMaps[xIndex][yIndex][hostIndex][tmpStrStream.str()];
if(oneWayDelay < 50000 && oneWayDelay > -50000 && (delaySequenceArray[xIndex][yIndex][hostIndex][packetTimeMaps[xIndex][yIndex][hostIndex][origTimestamp]] > 100000 || delaySequenceArray[xIndex][yIndex][hostIndex][packetTimeMaps[xIndex][yIndex][hostIndex][origTimestamp]] < -100000 ) ) if(oneWayDelay < 50000 && oneWayDelay > -50000 && (delaySequenceArray[xIndex][yIndex][hostIndex][packetTimeMaps[xIndex][yIndex][hostIndex][origTimestamp]] > 100000 || delaySequenceArray[xIndex][yIndex][hostIndex][packetTimeMaps[xIndex][yIndex][hostIndex][origTimestamp]] < -100000 ) )
{ {
...@@ -172,7 +174,7 @@ void pcapCallback(u_char *user, const struct pcap_pkthdr *pcap_info, const u_cha ...@@ -172,7 +174,7 @@ void pcapCallback(u_char *user, const struct pcap_pkthdr *pcap_info, const u_cha
// Ignore the IP options for now - but count their length. // Ignore the IP options for now - but count their length.
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
u_char *udpPacketStart = (u_char *)(pkt_data + sizeof(struct ether_header) + ipHeaderLength*4); u_char *udpPacketStart = (u_char *)(pkt_data + sizeof(struct ether_header) + ipHeaderLength*4);
struct udphdr const *udpPacket; struct udphdr const *udpPacket;
...@@ -212,7 +214,7 @@ void init_pcap( char *ipAddress) ...@@ -212,7 +214,7 @@ void init_pcap( char *ipAddress)
exit(1); exit(1);
} }
pcap_compile(pcapDescriptor, &bpfProg, filter, 1, netp); pcap_compile(pcapDescriptor, &bpfProg, filter, 1, netp);
pcap_setfilter(pcapDescriptor, &bpfProg); pcap_setfilter(pcapDescriptor, &bpfProg);
pcap_setnonblock(pcapDescriptor, 1, errBuf); pcap_setnonblock(pcapDescriptor, 1, errBuf);
...@@ -238,7 +240,7 @@ int main(int argc, char **argv) ...@@ -238,7 +240,7 @@ int main(int argc, char **argv)
ifstream inputFileHandle; ifstream inputFileHandle;
localhostEnt = gethostbyname(argv[3]); localhostEnt = gethostbyname(argv[3]);
memcpy((char *) &localHostAddr.sin_addr.s_addr, memcpy((char *) &localHostAddr.sin_addr.s_addr,
localhostEnt->h_addr_list[0], localhostEnt->h_length); localhostEnt->h_addr_list[0], localhostEnt->h_length);
init_pcap(inet_ntoa(localHostAddr.sin_addr)); init_pcap(inet_ntoa(localHostAddr.sin_addr));
int pcapfd = pcap_get_selectable_fd(pcapDescriptor); int pcapfd = pcap_get_selectable_fd(pcapDescriptor);
...@@ -257,7 +259,7 @@ int main(int argc, char **argv) ...@@ -257,7 +259,7 @@ int main(int argc, char **argv)
while(!inputFileHandle.eof()) while(!inputFileHandle.eof())
{ {
inputFileHandle.getline(tmpStr, 80); inputFileHandle.getline(tmpStr, 80);
tmpString = tmpStr; tmpString = tmpStr;
if(tmpString.size() < 3) if(tmpString.size() < 3)
...@@ -272,7 +274,7 @@ int main(int argc, char **argv) ...@@ -272,7 +274,7 @@ int main(int argc, char **argv)
for(int test = 0;test < hostList.size(); test++) for(int test = 0;test < hostList.size(); test++)
printf("%s\n", hostList[test].c_str()); printf("%s\n", hostList[test].c_str());
// We don't need to run the probe client on this node - just exit. // We don't need to run the probe client on this node - just exit.
if(enableClientFlag == false) if(enableClientFlag == false)
exit(0); exit(0);
...@@ -293,6 +295,7 @@ int main(int argc, char **argv) ...@@ -293,6 +295,7 @@ int main(int argc, char **argv)
fcntl(clientSocket, F_SETFL, flags | O_NONBLOCK); fcntl(clientSocket, F_SETFL, flags | O_NONBLOCK);
delaySequenceArray.resize(numHosts-1); delaySequenceArray.resize(numHosts-1);
sendTimesArray.resize(numHosts - 1);
packetTimeMaps.resize(numHosts-1); packetTimeMaps.resize(numHosts-1);
actualTimeMaps.resize(numHosts-1); actualTimeMaps.resize(numHosts-1);
...@@ -300,31 +303,31 @@ int main(int argc, char **argv) ...@@ -300,31 +303,31 @@ int main(int argc, char **argv)
{ {
host1 = NULL; host1 = NULL;
host1 = gethostbyname(hostList[i].c_str()); host1 = gethostbyname(hostList[i].c_str());
if(host1 == NULL) if(host1 == NULL)
{ {
printf("ERROR: Unknown host %s\n", hostList[i].c_str()); printf("ERROR: Unknown host %s\n", hostList[i].c_str());
exit(1); exit(1);
} }
remoteServAddr1.sin_family = host1->h_addrtype; remoteServAddr1.sin_family = host1->h_addrtype;
memcpy((char *) &remoteServAddr1.sin_addr.s_addr, memcpy((char *) &remoteServAddr1.sin_addr.s_addr,
host1->h_addr_list[0], host1->h_length); host1->h_addr_list[0], host1->h_length);
remoteServAddr1.sin_port = htons(REMOTE_SERVER_PORT); remoteServAddr1.sin_port = htons(REMOTE_SERVER_PORT);
cout << "First host IP = "<<inet_ntoa(remoteServAddr1.sin_addr)<<"\n"; cout << "First host IP = "<<inet_ntoa(remoteServAddr1.sin_addr)<<"\n";
delaySequenceArray[i].resize(numHosts - i - 1); delaySequenceArray[i].resize(numHosts - i - 1);
sendTimesArray[i].resize(numHosts - i - 1);
packetTimeMaps[i].resize(numHosts - i - 1); packetTimeMaps[i].resize(numHosts - i - 1);
actualTimeMaps[i].resize(numHosts -i - 1); actualTimeMaps[i].resize(numHosts -i - 1);
for( int j = i+1; j < numHosts; j++) for( int j = i+1; j < numHosts; j++)
{ {
printf("PROGRESS: i = %d/%d, j = %d/%d\n",i, numHosts - 2, j, numHosts - 1); printf("PROGRESS: i = %d/%d, j = %d/%d\n",i, numHosts - 2, j, numHosts - 1);
host2 = NULL; host2 = NULL;
host2 = gethostbyname(hostList[j].c_str()); host2 = gethostbyname(hostList[j].c_str());
if(host2 == NULL) if(host2 == NULL)
{ {
printf("ERROR: Unknown host %s\n", hostList[j].c_str()); printf("ERROR: Unknown host %s\n", hostList[j].c_str());
exit(1); exit(1);
...@@ -339,19 +342,22 @@ int main(int argc, char **argv) ...@@ -339,19 +342,22 @@ int main(int argc, char **argv)
//system(iperfCmd2.c_str()); //system(iperfCmd2.c_str());
////////////////////////////// //////////////////////////////
remoteServAddr2.sin_family = host2->h_addrtype; remoteServAddr2.sin_family = host2->h_addrtype;
memcpy((char *) &remoteServAddr2.sin_addr.s_addr, memcpy((char *) &remoteServAddr2.sin_addr.s_addr,
host2->h_addr_list[0], host2->h_length); host2->h_addr_list[0], host2->h_length);
remoteServAddr2.sin_port = htons(REMOTE_SERVER_PORT); remoteServAddr2.sin_port = htons(REMOTE_SERVER_PORT);
delaySequenceArray[i][j-i-1].resize(2); delaySequenceArray[i][j-i-1].resize(2);
sendTimesArray[i][j - i - 1].resize(2);
packetTimeMaps[i][j-i-1].resize(2); packetTimeMaps[i][j-i-1].resize(2);
actualTimeMaps[i][j-i-1].resize(2); actualTimeMaps[i][j-i-1].resize(2);
delaySequenceArray[i][j-i-1][0].resize(0); delaySequenceArray[i][j-i-1][0].resize(0);
delaySequenceArray[i][j-i-1][1].resize(0); delaySequenceArray[i][j-i-1][1].resize(0);
sendTimesArray[i][j - i - 1][0].resize(0);
sendTimesArray[i][j - i - 1][1].resize(0);
packetTimeMaps[i][j-i-1][0].clear(); packetTimeMaps[i][j-i-1][0].clear();
packetTimeMaps[i][j-i-1][1].clear(); packetTimeMaps[i][j-i-1][1].clear();
...@@ -447,13 +453,14 @@ int main(int argc, char **argv) ...@@ -447,13 +453,14 @@ int main(int argc, char **argv)
memcpy(&messageString[1 + sizeof(short int)], &xIndex, sizeof(short int)); memcpy(&messageString[1 + sizeof(short int)], &xIndex, sizeof(short int));
memcpy(&messageString[1 + 2*sizeof(short int)], &yIndex, sizeof(short int)); memcpy(&messageString[1 + 2*sizeof(short int)], &yIndex, sizeof(short int));
memcpy(&messageString[1 + 3*sizeof(short int)], &sendTime, sizeof(unsigned long long)); memcpy(&messageString[1 + 3*sizeof(short int)], &sendTime, sizeof(unsigned long long));
rc = sendto(clientSocket, messageString, 1 + 3*sizeof(short int) + sizeof(unsigned long long), flags, rc = sendto(clientSocket, messageString, 1 + 3*sizeof(short int) + sizeof(unsigned long long), flags,
(struct sockaddr *) &remoteServAddr1, (struct sockaddr *) &remoteServAddr1,
sizeof(remoteServAddr1)); sizeof(remoteServAddr1));
if(rc < 0) if(rc < 0)
printf("ERROR sending first udp message\n"); printf("ERROR sending first udp message\n");
packetTimeMaps[i][j-i-1][0][sendTime] = packetCounter; packetTimeMaps[i][j-i-1][0][sendTime] = packetCounter;
delaySequenceArray[i][j-i-1][0].push_back(-9999); delaySequenceArray[i][j-i-1][0].push_back(-9999);
sendTimesArray[i][j-i-1][0].push_back(-9999);
cout<< "TO " << hostList[i] << " :Counter=" << packetCounter << " :SendTime= " << sendTime << endl; cout<< "TO " << hostList[i] << " :Counter=" << packetCounter << " :SendTime= " << sendTime << endl;
sendTime = getTimeMilli(); sendTime = getTimeMilli();
...@@ -463,14 +470,15 @@ int main(int argc, char **argv) ...@@ -463,14 +470,15 @@ int main(int argc, char **argv)
memcpy(&messageString[1 + sizeof(short int)], &xIndex, sizeof(short int)); memcpy(&messageString[1 + sizeof(short int)], &xIndex, sizeof(short int));
memcpy(&messageString[1 + 2*sizeof(short int)], &yIndex, sizeof(short int)); memcpy(&messageString[1 + 2*sizeof(short int)], &yIndex, sizeof(short int));
memcpy(&messageString[1 + 3*sizeof(short int)], &sendTime, sizeof(unsigned long long)); memcpy(&messageString[1 + 3*sizeof(short int)], &sendTime, sizeof(unsigned long long));
rc = sendto(clientSocket, messageString, 1 + 3*sizeof(short int) + sizeof(unsigned long long), flags, rc = sendto(clientSocket, messageString, 1 + 3*sizeof(short int) + sizeof(unsigned long long), flags,
(struct sockaddr *) &remoteServAddr2, (struct sockaddr *) &remoteServAddr2,
sizeof(remoteServAddr2)); sizeof(remoteServAddr2));
if(rc < 0) if(rc < 0)
printf("ERROR sending second udp message\n"); printf("ERROR sending second udp message\n");
packetTimeMaps[i][j-i-1][1][sendTime] = packetCounter; packetTimeMaps[i][j-i-1][1][sendTime] = packetCounter;
delaySequenceArray[i][j-i-1][1].push_back(-9999); delaySequenceArray[i][j-i-1][1].push_back(-9999);
sendTimesArray[i][j-i-1][0].push_back(-9999);
cout<< "TO " << hostList[j] << " :Counter=" << packetCounter << " :SendTime= " << sendTime << endl; cout<< "TO " << hostList[j] << " :Counter=" << packetCounter << " :SendTime= " << sendTime << endl;
lastSentTime = getTimeMilli(); lastSentTime = getTimeMilli();
...@@ -563,7 +571,10 @@ int main(int argc, char **argv) ...@@ -563,7 +571,10 @@ int main(int argc, char **argv)
// Interpolate delays for the missing packets in this range. // Interpolate delays for the missing packets in this range.
int y = 0; int y = 0;
for (int x = k, y = 1; x < lastInRange; x++, y++) for (int x = k, y = 1; x < lastInRange; x++, y++)
{
delaySequenceArray[xIndex][yIndex][0][x] = delaySequenceArray[xIndex][yIndex][0][k-1] + y*step ; delaySequenceArray[xIndex][yIndex][0][x] = delaySequenceArray[xIndex][yIndex][0][k-1] + y*step ;
sendTimesArray[xIndex][yIndex][0][x] -9999;
}
} }
if (delaySequenceArray[xIndex][yIndex][1][k] == -9999) if (delaySequenceArray[xIndex][yIndex][1][k] == -9999)
{ {
...@@ -588,7 +599,10 @@ int main(int argc, char **argv) ...@@ -588,7 +599,10 @@ int main(int argc, char **argv)
// Interpolate delays for the missing packets in this range. // Interpolate delays for the missing packets in this range.
int y = 0; int y = 0;
for (int x = k, y = 1; x < lastInRange; x++, y++) for (int x = k, y = 1; x < lastInRange; x++, y++)
{
delaySequenceArray[xIndex][yIndex][1][x] = delaySequenceArray[xIndex][yIndex][1][k-1] + y*step ; delaySequenceArray[xIndex][yIndex][1][x] = delaySequenceArray[xIndex][yIndex][1][k-1] + y*step ;
sendTimesArray[xIndex][yIndex][1][x] = -9999;
}
} }
} }
} }
...@@ -602,7 +616,19 @@ int main(int argc, char **argv) ...@@ -602,7 +616,19 @@ int main(int argc, char **argv)
{ {
for (int k = firstSeenIndex; k < lastSeenIndex + 1; k++) for (int k = firstSeenIndex; k < lastSeenIndex + 1; k++)
{ {
outputFileHandle << delaySequenceArray[xIndex][yIndex][0][k] << " " << delaySequenceArray[xIndex][yIndex][1][k] << "\n"; // Output the delay of the first packet, the delay
// of the second packet, the send time of the first
// packet, the send time of the second packet.
//
// The sequence numbers are implicit in the order.
outputFileHandle << delaySequenceArray[xIndex][yIndex][0][k]
<< " "
<< delaySequenceArray[xIndex][yIndex][1][k]
<< " "
<< sendTimesArray[xIndex][yIndex][0][k]
<< " "
<< sendTimesArray[xIndex][yIndex][1][k]
<< "\n";
} }
} }
outputFileHandle.close(); outputFileHandle.close();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment