Commit df5def87 authored by Pramod R Sanaga's avatar Pramod R Sanaga
Browse files

1) Changed UdpServer to ignore loopback packets.

2) mindelay/maxdelay are now being sent in millisec. mindelay is
now being set on the reverse path too.
3) Added a check - not to send zero bandwidth values to the monitor.
4) Removed some debugging print statements from KernelTcp.
parent e713874a
......@@ -834,7 +834,6 @@ namespace
pos = global::planetMap.find(key);
if (pos != global::planetMap.end()) {
outgoing = false;
logWrite(PCAP, "Captured an Incoming UDP packet");
} else {
logWrite(ERROR,"Unable to find packet in planetMap");
return;
......@@ -890,7 +889,6 @@ namespace
// packets that are incoming. All other separation can be done
// inside the sensors themselves. We call these 'Send' and 'Ack'
// packets because my thinking was originally muddied about this.
logWrite(PCAP, "Before Capturing an Incoming UDP packet with UDP sensors");
if (outgoing) {
/*
* Outgoing packets
......@@ -901,7 +899,6 @@ logWrite(PCAP, "Before Capturing an Incoming UDP packet with UDP sensors");
/*
* Incoming packets
*/
logWrite(PCAP, "Capturing an Incoming UDP packet with UDP sensors");
packet.packetType = PACKET_INFO_ACK_COMMAND;
pos->second->capturePacket(&packet);
}
......
......@@ -7,7 +7,7 @@
#include "UdpServer.h"
#define MAX_MSG 1524
#define SNAPLEN 1600
#define SNAPLEN 128
// Libpcap file descriptor.
pcap_t *pcapDescriptor = NULL;
......@@ -312,8 +312,17 @@ void handleUDP_Version_2(struct pcap_pkthdr const *pcap_info, struct udphdr cons
// we saw, then send an acknowledgement for it. Otherwise, ignore the
// packet - it arrived out of order.
//printf("Received seqNum = %d, from IP = %s, port = %d\n", packetSeqNum, inet_ntoa(ipPacket->ip_src),sourcePort );
printf("%s:%d Received seqNum=%d,size=%d\n", inet_ntoa(ipPacket->ip_src),sourcePort , packetSeqNum,recvPacketLen);
// printf("Packet loss = %d\n", clientIter->second.packetLoss);
if(packetSeqNum == clientIter->second.curSeqNum)
{
printf("This is a duplicate packet\n\n");
return;
}
// Ignore loopback packets.
if(ipPacket->ip_src.s_addr == ipPacket->ip_dst.s_addr)
return;
// TODO:Take wrap around into account.
{
if(packetSeqNum > (clientIter->second.curSeqNum + 1))
......@@ -401,6 +410,7 @@ void handleUDP_Version_2(struct pcap_pkthdr const *pcap_info, struct udphdr cons
// This indicates where the redundant ACKs start in the packet.
int redunAckStart = 1 + 2*globalConsts::USHORT_INT_SIZE + 2*globalConsts::ULONG_LONG_SIZE;
int index = (clientIter->second.queueEndPtr + 1 - numAcks + ackQueueSize)%ackQueueSize;
printf("#Redundant Acks=%d\n", numAcks);
// Copy the redundant ACKs.
for(int i = 0;i < numAcks; i++)
{
......@@ -415,9 +425,11 @@ void handleUDP_Version_2(struct pcap_pkthdr const *pcap_info, struct udphdr cons
// Copy the time diffrence between when this packet was received
// and when the latest packet being ACKed was received here.
memcpy(&appAck[redunAckStart + i*ackSize + 2*globalConsts::USHORT_INT_SIZE], &timeDiff, globalConsts::ULONG_LONG_SIZE);
printf("Redun Ack=%d,TimeDiff=%llu,byte=%d\n",clientIter->second.ackQueue[index].seqNo, timeDiff, redunAckStart + i*ackSize);
index = (index + 1)%ackQueueSize;
}
printf("\n");
// Always maintain the sequence numbers and ack send times
// of the last ackQueueSize(120) ACK packets.
......@@ -601,7 +613,7 @@ int main(int argc, char *argv[])
cliLen = sizeof(cliAddr);
outFile.open("Throughput.log", std::ios::out);
outFile.open("ServerThroughput.log", std::ios::out);
/* server infinite loop */
while(true)
......
......@@ -218,17 +218,21 @@ void UdpAvgThroughputSensor::calculateTput(unsigned long long timeStamp, PacketI
throughputKbps = 8000000.0*( static_cast<double> (packetSizeSum )) / ( static_cast<double>(timePeriod)*1024.0 );
int tputValue = static_cast<int>(throughputKbps);
//Avoid sending a zero throughput value to the monitor.
if(tputValue == 0)
tputValue = 1;
// Send a message to the monitor with the new bandwidth.
if(lossSensor->getPacketLoss() == 0 )
{
if(static_cast<int>(throughputKbps) > lastSeenThroughput )
if(tputValue > lastSeenThroughput )
{
// Send this available bandwidth as a tentative value.
// To be used for dummynet events only if it is greater
// than the last seen value.
ostringstream messageBuffer;
messageBuffer << static_cast<int>( throughputKbps );
messageBuffer << tputValue;
global::output->genericMessage(TENTATIVE_THROUGHPUT, messageBuffer.str(), packet->elab);
}
logWrite(SENSOR, "AVGTPUT:TIME=%llu,TENTATIVE=%f",timeStamp,throughputKbps);
......@@ -237,7 +241,7 @@ void UdpAvgThroughputSensor::calculateTput(unsigned long long timeStamp, PacketI
else
{
ostringstream messageBuffer;
messageBuffer << static_cast<int>( throughputKbps );
messageBuffer << tputValue;
global::output->genericMessage(AUTHORITATIVE_BANDWIDTH, messageBuffer.str(), packet->elab);
// Send this as the authoritative available bandwidth value.
logWrite(SENSOR, "AVGTPUT:TIME=%llu,AUTHORITATIVE=%f",timeStamp,throughputKbps);
......@@ -245,6 +249,6 @@ void UdpAvgThroughputSensor::calculateTput(unsigned long long timeStamp, PacketI
(const_cast<UdpLossSensor *>(lossSensor))->resetLoss();
}
lastSeenThroughput = static_cast<int>(throughputKbps);
lastSeenThroughput = tputValue;
logWrite(SENSOR, "STAT:TOTAL_LOSS = %d",lossSensor->getTotalPacketLoss());
}
......@@ -79,7 +79,7 @@ void UdpMaxDelaySensor::localAck(PacketInfo *packet)
{
// Report the maximum delay
ostringstream messageBuffer;
messageBuffer<<"MAXINQ="<<maxDelay;
messageBuffer<<"MAXINQ="<<(maxDelay)/1000;
global::output->eventMessage(messageBuffer.str(), packet->elab);
logWrite(SENSOR,"VALUE::New Max Delay = %llu",maxDelay);
......
......@@ -82,8 +82,9 @@ void UdpMinDelaySensor::localAck(PacketInfo *packet)
if(eventFlag == true)
{
ostringstream messageBuffer;
messageBuffer << "delay="<<minDelay;
messageBuffer << "delay="<<(minDelay)/1000;
global::output->eventMessage(messageBuffer.str(), packet->elab, CommandOutput::FORWARD_PATH);
global::output->eventMessage(messageBuffer.str(), packet->elab, CommandOutput::BACKWARD_PATH);
logWrite(SENSOR,"VALUE::New Min delay = %llu",minDelay);
}
logWrite(SENSOR,"MIND:TIME=%llu,MIND=%llu",timeStamp,minDelay);
......
......@@ -91,6 +91,8 @@ void UdpPacketSensor::localSend(PacketInfo *packet)
tmpPacketInfo.timeStamp = packet->packetTime.toMicroseconds();
tmpPacketInfo.isFake = false;
logWrite(SENSOR_COMPLETE,"%s:%d SEND:SeqNum=%d,size=%d at %llu from %s:%d",inet_ntoa(packet->ip->ip_dst), ntohs(packet->udp->dest),seqNum,packetSize, tmpPacketInfo.timeStamp, inet_ntoa(packet->ip->ip_src), ntohs(packet->udp->source));
sentPacketList.push_back(tmpPacketInfo);
}
......@@ -107,6 +109,8 @@ void UdpPacketSensor::localAck(PacketInfo *packet)
unsigned short int seqNum = *(unsigned short int *)(packet->payload + 1);
logWrite(SENSOR_COMPLETE,"%s:%d ACK SeqNum=%d at %llu to %s:%d",inet_ntoa(packet->ip->ip_src), ntohs(packet->udp->source),seqNum, packet->packetTime.toMicroseconds(), inet_ntoa(packet->ip->ip_dst), ntohs(packet->udp->dest));
// Find the entry for the packet this ACK is acknowledging, and
// remove it from the sent(&unacked) packet list.
list<UdpPacketInfo >::iterator listIterator;
......
Supports Markdown
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