Commit 624ebda4 authored by Pramod R Sanaga's avatar Pramod R Sanaga
Browse files

This is version used to generate the final flexlab paper udp results.

1) Packets due to EWOULDBLOCK are now being considered as losses.
2) Udp socket in KernelTcp is now non-blocing.
parent 7db2cce6
......@@ -40,6 +40,8 @@ namespace
pcap_t * KernelTcp::pcapDescriptor = NULL;
int KernelTcp::pcapfd = -1;
char KernelTcp::udpPacketBuffer[66000] = "";
struct pcap_stat pcapStats;
unsigned int currentPcapLoss = 0;
KernelTcp::KernelTcp()
: state(DISCONNECTED)
......@@ -92,6 +94,16 @@ void KernelTcp::connect(PlanetOrder & planet)
logWrite(ERROR, "Could not create a datagram socket in KernelTcp::connect");
}
int flags = fcntl(peersock, F_GETFL, 0);
flags = flags | O_NONBLOCK;
if( fcntl(peersock, F_SETFL, flags) < 0 )
{
logWrite(ERROR,"Could not set UDP socket to non-blocking");
}
udpLocalAddr.sin_family = AF_INET;
udpLocalAddr.sin_addr.s_addr = htonl(INADDR_ANY);
udpLocalAddr.sin_port = htons(0);
......@@ -385,7 +397,16 @@ int KernelTcp::writeUdpMessage(int size, WriteResult & result)
logWrite(ERROR, "Could not create a datagram socket in writeUdpMessage");
return -1;
}
}
int flags = fcntl(peersock, F_GETFL, 0);
flags = flags | O_NONBLOCK;
if( fcntl(peersock, F_SETFL, flags) < 0 )
{
logWrite(ERROR,"Could not set UDP socket to non-blocking");
}
}
// result.planet.ip and result.planet.remotePort denote the destination.
// result.planet.ip is in host order
// result.planet.remotePort is in host order
......@@ -416,8 +437,15 @@ int KernelTcp::writeUdpMessage(int size, WriteResult & result)
if(bytesWritten < 0)
{
logWrite(EXCEPTION, "Error writing to UDP socket in KernelTcp, errno = %d",errno);
return -1;
if(errno == EWOULDBLOCK)
{
logWrite(EXCEPTION,"UDP sendto returned EWOULDBLOCK");
}
else
{
logWrite(EXCEPTION, "Error writing to UDP socket in KernelTcp, errno = %d",errno);
return -1;
}
}
udpCurSeqNum++;
......@@ -900,6 +928,19 @@ namespace
}
}
static int counter = 0;
pcap_stats(KernelTcp::pcapDescriptor, &pcapStats);
if(counter%2000 == 0)
{
if(pcapStats.ps_drop > currentPcapLoss)
{
currentPcapLoss = pcapStats.ps_drop;
logWrite(SENSOR,"\nSTAT::Number of packets lost in libpcap = %d\n",currentPcapLoss);
}
}
counter++;
// We want to distinguish between packets that are outgoing and
// packets that are incoming. All other separation can be done
// inside the sensors themselves. We call these 'Send' and 'Ack'
......
......@@ -49,8 +49,9 @@ void UdpLossSensor::localAck(PacketInfo *packet)
while(vecIterator != unAckedPackets.end())
{
if(seqNum > (*vecIterator).seqNum + 10 || ( timeStamp > (*vecIterator).timeStamp + 10*( ewmaRtt + 4*ewmaDevRtt)) )
if(seqNum > ((*vecIterator).seqNum + 10) || ( timeStamp > (*vecIterator).timeStamp + 10*( ewmaRtt + 4*ewmaDevRtt)) )
{
logWrite(SENSOR,"UDP_LOSS_SENSOR: Lost packet seqNum=%d", (*vecIterator).seqNum);
tempIterator = vecIterator;
vecIterator++;
unAckedPackets.erase(tempIterator);
......
......@@ -76,8 +76,10 @@ void UdpPacketSensor::localSend(PacketInfo *packet)
{
tmpPacketInfo.seqNum = lastSeenSeqNum + i;
tmpPacketInfo.isFake = true;
tmpPacketInfo.timeStamp = 0;
sentPacketList.push_back(tmpPacketInfo);
logWrite(SENSOR,"Adding fake packet = %d", tmpPacketInfo.seqNum);
}
libpcapSendLoss += (seqNum - lastSeenSeqNum - 1);
......@@ -189,6 +191,7 @@ void UdpPacketSensor::localAck(PacketInfo *packet)
listIterator = find_if(sentPacketList.begin(), sentPacketList.end(), bind2nd(equalSeqNum(), redunSeqNum));
redunAckVector.push_back(redunSeqNum);
//logWrite(SENSOR,"For SeqNum=%d, Redun Ack=%d\n",seqNum,redunSeqNum);
// An unacked packet exists with this sequence number, delete it
// from the list and consider it acked.
......@@ -202,6 +205,7 @@ void UdpPacketSensor::localAck(PacketInfo *packet)
ackedPackets.push_back(tmpPacketInfo);
sentPacketList.erase(listIterator);
logWrite(SENSOR,"For SeqNum=%d, using Redun Ack=%d\n",seqNum,redunSeqNum);
}
else
{
......
......@@ -336,7 +336,7 @@ enum
enum
{
SNAPLEN_SIZE = 200
SNAPLEN_SIZE = 250
};
class ConnectionModel;
......
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