Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 03 Feb 2008 23:01:25 +0100
From:      Kris Kennaway <kris@FreeBSD.org>
To:        Kris Kennaway <kris@FreeBSD.org>
Cc:        freebsd-hackers@freebsd.org, Ivan Voras <ivoras@freebsd.org>, Stefan Lambrev <stefan.lambrev@moneybookers.com>
Subject:   Re: gettimeofday() in hping
Message-ID:  <47A639B5.2020909@FreeBSD.org>
In-Reply-To: <47A62F1D.8070507@FreeBSD.org>
References:  <4795CC13.7080601@moneybookers.com>	<4795FE54.9090606@moneybookers.com>	<86lk6i0vzk.fsf@ds4.des.no>	<479605E2.6070709@moneybookers.com>	<fn5c7u$i7e$2@ger.gmane.org>	<47964356.6030602@moneybookers.com>	<479647FB.3070909@FreeBSD.org>	<47970EE2.5000400@moneybookers.com>	<fn7evj$smv$1@ger.gmane.org>	<479754E6.1060101@moneybookers.com>	<9bbcef730801230802n5c52832bk60c6afc47be578f4@mail.gmail.com> <47976AD4.3020203@moneybookers.com> <47A62EE8.2000700@FreeBSD.org> <47A62F1D.8070507@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------050704020506030104040903
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Kris Kennaway wrote:

>> Fixing all of the above I can send at about 13MB/sec (timecounter is 
>> not relevant any more).  The CPU is spending about 75% of the time in 
>> the kernel, so
>              that is the next place to look. [hit send too soon]

Actually 15MB/sec once I disable all kernel debugging.  This is 
identical to Linux 2.6.24 on the same hardware.  The patch I use to fix 
hping brain-damage is attached.

Kris




--------------050704020506030104040903
Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0";
	name="braindeath.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="braindeath.diff"

diff -ru work/hping3-20051105/opensockraw.c work~/hping3-20051105/opensockraw.c
--- opensockraw.c.orig	2003-09-01 00:22:06.000000000 +0000
+++ opensockraw.c	2008-02-03 19:45:28.000000000 +0000
@@ -17,7 +17,7 @@
 
 int open_sockraw()
 {
-	int s;
+	int s, t, val;
 
 	s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
 	if (s == -1) {
@@ -25,5 +25,12 @@
 		return -1;
 	}
 
+	val = 262144;
+	t = setsockopt(s, SOL_SOCKET, SO_SNDBUF, &val, sizeof(val));
+	if (t == -1) {
+		perror("[open_sockraw] setsockopt()");
+		return -1;
+	}
+
 	return s;
 }
diff -ru work/hping3-20051105/sendip.c work~/hping3-20051105/sendip.c
--- sendip.c.orig	2004-04-09 23:38:56.000000000 +0000
+++ sendip.c	2008-02-03 19:50:35.000000000 +0000
@@ -110,7 +110,7 @@
 	result = sendto(sockraw, packet, packetsize, 0,
 		(struct sockaddr*)&remote, sizeof(remote));
 	
-	if (result == -1 && errno != EINTR && !opt_rand_dest && !opt_rand_source) {
+	if (result == -1 && errno != ENOBUFS && errno != EINTR && !opt_rand_dest && !opt_rand_source) {
 		perror("[send_ip] sendto");
 		if (close(sockraw) == -1)
 			perror("[ipsender] close(sockraw)");
diff -ru work/hping3-20051105/sendtcp.c work~/hping3-20051105/sendtcp.c
--- sendtcp.c.orig	2003-09-01 00:22:06.000000000 +0000
+++ sendtcp.c	2008-02-03 20:30:51.000000000 +0000
@@ -85,8 +85,10 @@
 		      packet_size);
 #endif
 
+#if 0
 	/* adds this pkt in delaytable */
 	delaytable_add(sequence, src_port, time(NULL), get_usec(), S_SENT);
+#endif
 
 	/* send packet */
 	send_ip_handler(packet+PSEUDOHDR_SIZE, packet_size);
--- send.c.orig	2003-08-31 17:23:53.000000000 +0000
+++ send.c	2008-02-03 21:58:59.000000000 +0000
@@ -63,6 +63,8 @@
 	}
 }
 
+static int sigalarm_handler = 0;
+
 /* The signal handler for SIGALRM will send the packets */
 void send_packet (int signal_id)
 {
@@ -79,12 +81,15 @@
 	else			send_tcp();
 
 	sent_pkt++;
-	Signal(SIGALRM, send_packet);
+	if (!opt_flood && !sigalarm_handler) {
+		Signal(SIGALRM, send_packet);
+		sigalarm_handler = 1;
+	}
 
 	if (count != -1 && count == sent_pkt) { /* count reached? */
 		Signal(SIGALRM, print_statistics);
 		alarm(COUNTREACHED_TIMEOUT);
-	} else if (!opt_listenmode) {
+	} else if (!opt_listenmode && !opt_flood) {
 		if (opt_waitinusec == FALSE)
 			alarm(sending_wait);
 		else

--------------050704020506030104040903--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?47A639B5.2020909>