Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
a5528c69
Commit
a5528c69
authored
Feb 21, 2007
by
Pramod R Sanaga
Browse files
1) Decreased the SNAPLEN to a 100 bytes.
2) Removed some unnecessary debug statements.
parent
8289ad1f
Changes
1
Hide whitespace changes
Inline
Side-by-side
pelab/magent/UDP/UdpServerDir/UdpServer.cc
View file @
a5528c69
...
...
@@ -7,7 +7,7 @@
#include
"UdpServer.h"
#define MAX_MSG 1524
#define SNAPLEN 1
28
#define SNAPLEN 1
00
// Libpcap file descriptor.
pcap_t
*
pcapDescriptor
=
NULL
;
...
...
@@ -31,6 +31,8 @@ int localServerPort;
std
::
map
<
struct
ClientAddress
,
ClientInfo
,
CompareAddresses
>
ClientMap
;
bool
useMinAcksFlag
=
true
;
struct
pcap_stat
pcapStats
;
long
currentPcapLoss
=
0
;
// Convert the argument to microseconds.
unsigned
long
long
getPcapTimeMicro
(
const
struct
timeval
*
tp
)
...
...
@@ -84,6 +86,7 @@ void handleUDP_Version_1(struct pcap_pkthdr const *pcap_info, struct udphdr cons
{
ClientInfo
clientInfo
;
ClientMap
[
clientAddr
]
=
clientInfo
;
clientIter
=
ClientMap
.
find
(
clientAddr
);
}
...
...
@@ -272,10 +275,19 @@ void handleUDP_Version_2(struct pcap_pkthdr const *pcap_info, struct udphdr cons
{
ClientInfo
clientInfo
;
clientInfo
.
clientEpoch
=
getPcapTimeMicro
(
&
pcap_info
->
ts
);
ClientMap
[
clientAddr
]
=
clientInfo
;
clientIter
=
ClientMap
.
find
(
clientAddr
);
}
pcap_stats
(
pcapDescriptor
,
&
pcapStats
);
if
(
pcapStats
.
ps_drop
>
currentPcapLoss
)
{
currentPcapLoss
=
pcapStats
.
ps_drop
;
printf
(
"STAT::Number of packets lost in libpcap = %d
\n
"
,
currentPcapLoss
);
}
// Get a pointer to the start of the data portion of the packet.
u_char
*
dataPtr
=
udpPacketStart
+
8
;
...
...
@@ -312,11 +324,13 @@ 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
(
"%s:%d Received seqNum=%d,size=%d
\n
"
,
inet_ntoa
(
ipPacket
->
ip_src
),
sourcePort
,
packetSeqNum
,
recvPacketLen
);
packetLibpcapTimestamp
=
getPcapTimeMicro
(
&
pcap_info
->
ts
);
// printf("%d - %s:%d Received seqNum=%u,size=%u\n", (packetLibpcapTimestamp - clientIter->second.clientEpoch)/1000000, inet_ntoa(ipPacket->ip_src),sourcePort , packetSeqNum,recvPacketLen);
// printf("Received seqNum=%u,size=%u\n", packetSeqNum,recvPacketLen);
// printf("Packet loss = %d\n", clientIter->second.packetLoss);
if
(
packetSeqNum
==
clientIter
->
second
.
curSeqNum
)
{
printf
(
"This is a duplicate packet
\n\n
"
);
printf
(
"This
=%d
is a duplicate packet
\n\n
"
,
packetSeqNum
);
return
;
}
// Ignore loopback packets.
...
...
@@ -404,13 +418,16 @@ void handleUDP_Version_2(struct pcap_pkthdr const *pcap_info, struct udphdr cons
// The ACK packet must be the same size as the original UDP
// packet that was received - this is needed so that the
// one way delay can be calculated as RTT/2.
if
(
(
udpLen
)
>
ackLength
)
ackLength
=
udpLen
;
if
(
useMinAcksFlag
==
false
)
{
if
(
(
udpLen
)
>
ackLength
)
ackLength
=
udpLen
;
}
// 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
);
//
printf("#Redundant Acks=%d\n", numAcks);
// Copy the redundant ACKs.
for
(
int
i
=
0
;
i
<
numAcks
;
i
++
)
{
...
...
@@ -425,7 +442,7 @@ 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
);
//
printf("Redun Ack=%d,TimeDiff=%llu,byte=%d\n",clientIter->second.ackQueue[index].seqNo, timeDiff, redunAckStart + i*ackSize);
index
=
(
index
+
1
)
%
ackQueueSize
;
}
...
...
@@ -617,7 +634,7 @@ int main(int argc, char *argv[])
/* server infinite loop */
while
(
true
)
pcap_dispatch
(
pcapDescriptor
,
-
1
,
pcapCallback
,
NULL
);
pcap_dispatch
(
pcapDescriptor
,
1
,
pcapCallback
,
NULL
);
return
0
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment