How to test Berkley socket (BSD) API? - api

I'd like to test the correctness and the completeness of an implementation of the BSP API.
The test set has to be cross-compiled for an ARM sam7x.

I don't know if this would be of any interest to you, but here are two links to presentations from NYC BSD Conference 2008: Detecting TCP regressions with tcpdiff (FreeBSD) and An introduction to the Automated Testing Framework (ATF) for NetBSD. Both were pretty good.

There is a public domain Benchmarking tool for TCP and UDP performance measurement.
It has a some amount of control available. You might be able to use it for testing.
Remember, this is not testing the API, but the implementation performance, you will need more than this.
The PCATTCP tool includes several options that are controlled by parameters passed on the command line when the program is started. To see the available options, run the PCATTCP application with the "-h" option. Here is what you would see:
pcattcp -h
PCAUSA Test TCP Utility V2.01.01.08
Usage: pcattcp -t [-options] host [ < in ]
pcattcp -r [-options > out]
Common options:
-l ## length of bufs read from or written to network (default 8192)
-u use UDP instead of TCP
-p ## port number to send to or listen at (default 5001)
-s toggle sinkmode (enabled by default)
sinkmode enabled:
-t: source (transmit) fabricated pattern
-r: sink (discard) all received data
sinkmode disabled:
-t: reads data to be transmitted from stdin
-r: writes received data to stdout
-A align the start of buffers to this modulus (default 16384)
-O start buffers at this offset from the modulus (default 0)
-v verbose: print more statistics
-d set SO_DEBUG socket option
-b ## set socket buffer size (if supported)
-f X format for rate: k,K = kilo{bit,byte}; m,M = mega; g,G = giga
-c -t: send continuously
-r: accept multiple connections sequentially
-R concurrent TCP/UDP multithreaded receiver
.
Options specific to -t:
-n ## number of source bufs written to network (default 2048)
-D don't buffer TCP writes (sets TCP_NODELAY socket option)
-w ## milliseconds of delay before each write (default 0)
-L ## desired transmit data rate in bytes/second
Options specific to -r:
-B for -s, only output full blocks as specified by -l (for TAR)
-T "touch": access each byte as it's read

Related

sending packets from iperf packet generator in continuous mode

Can we send packets from iperf generator in a continuous mode? Currently, I am sending packets in a burst mode by using command
iperf -c 10.0.0.2 -u -b 1m -t 1
where u is UDP packets 1m is bandwidth (1 Mbps) and t is a time which is 1 second.
but I want to send in continuous mode.
Time can be a floating-point value, and one special floating-point value is infinity:
iperf3 -c 10.0.0.2 -tinf
iperf -c 10.0.0.2 -tinf
For iperf 2.0.13 use iperf -c -b 1pps
CLIENT SPECIFIC OPTIONS
-b, --bandwidth n[kmgKMG] | npps
set target bandwidth to n bits/sec (default 1 Mbit/sec) or n packets per sec. This may be used with TCP or UDP. For variable loads use format mean,standard deviation
Bob
for iperf v3.0.11 : you can play with -w "windows size" value

ssh v2 maximum compression (xzip/7zip)

I am on a slow dial-up connection, but I have root access to a fast server.
Currently I use ssh v2 to connect to the server with Compression enabled in ~/.ssh/config. However this only uses gzip level 6 (as mentioned here https://serverfault.com/questions/388658/ssh-compression/.
However, it is possible to use better algorithms (like xzip with -e9 or 7zip with -mx=9 ) using pipes as mentioned here [https://serverfault.com/a/586739/506887]. The example in that answer:
ssh ${SSH_USER}#${SSH_HOST} "
echo 'string to be compressed' | gzip -9
" | zcat | echo -
compresses a single string using xzip and pipes on the remote server.
1) I would like to do this (compress with xzip) for all traffic.How can that be done.
2) To save data, when I run firefox on my client, I use a socks v5 proxy with ssh to take advantage of compression
ssh -D 8123 -C -v -N root#myserver
and I point firefox to socks://localhost:8123. Again this using gzip level 6. Can this example be similarly modified to use xzip or 7zip.
I am aware that the bandwidth advantage of using xzip vs gzip may not be significant for a single connection. But I am hoping the bandwith savings will accumulate to a significant amount over a period of time.
Thanks

egrep file of txt varibles is removing varibles with spaces

i have a script I use that reads ipaddress or ranges lines in from a txt file and insert them into my iptables. allows me to maintain one list for many servers. Recently I have been playing with string searches and user-agents stopping bad actors that use scripts that identify themselves using weird names in the useragent that i discover using tcpdump
I am trying to read a file and read each line in and
I am reading a file full of variables using egrep for example
JuNXhgCR
sipcli/v1.8
sipcli
friendly-scanner
pplsip
Asterisk PBX
Asterisk PBX 1.6.5
erdfcvqwaszx121
sipvicious
eyeBeam
VaxIPUserAgent
VaxSIPUserAgent/3.1
siparmyknife
VoIP SIP v11.0.0
FreePBX 1.8
Test Agent
but when i
egrep -v "^#|^$" x | while IFS= read -r uas
do
iptables -A INPUT -p udp -m udp --dport 5060 -m string --string $uas --algo bm --to 65535 -j DROP
done <"${_input}"
I just get ... but anything with a space is not passed ?? where is... VoIP SIP v11.0.0 , FreePBX 1.8 , Test Agent ??
JuNXhgCR
sipcli/v1.8
sipcli
friendly-scanner
pplsip
erdfcvqwaszx121
sipvicious
eyeBeam
VaxIPUserAgent
VaxSIPUserAgent/3.1
siparmyknife
Is there a better way to read and do this?

iperf connects but does not report output

I am using iperf to test network bandwidth between two Ubuntu 16.04.2 hosts (10.0.0.1 and 10.0.0.51). I ran "iperf -s" on 10.0.0.51 and then ran "iperf -c 10.0.0.51 -T 10" on 10.0.0.1. I do see the connection establishment (i.e. local 10.0.0.51 port 5001 connected with 10.0.0.1 port 37680) on both the sides but I do not get the results. It just hangs. Any help is highly appreciated. Thanks
with iperf3, you can see the output in json format:
The command:
iperf3 -c <server-ip> -w 4000 -t 10 -i 2 -f MBytes -V -J --logfile test.log
Note: In this case make sure you can run iperf client and server same version i.e version 3 in both cases
Check for firewalls or packet filters, e.g. for linux use iptables -L to list them and iptables -F to delete them all. Also, what version of iperf? You might want to display interval reports (-i 1) and see what they are reporting.

How to make Apache copy certain requests to another webserver?

I have a busy web server running apache. Now I am interested in certain request like:
http://myserver1/path1/somepage1.html?xxxxxx
http://myserver1/path2/somepage2.html?xxxxxx
What I want to do is to duplicate request like this and forward them to another webserver like:
http://myserver2/request_statistic/
But the original request must be served on myserver1 as they are now. myserver2 is only for research purpose, so I want the duplicated request headers and bodys are just as the original ones.
Can this be done? How?
Thank you.
Where would the response go?
You might try looking at mod_security, which has a number of useful features that would be of use... is your goal security/forensics, or performance analysis?
For performance analysis, I've found it more useful in the past to create a more comprehensive logging format that captures things like response-code, response Location header (for tracking redirects), selected request headers, timing information, etc.
If https is not in use, then you might be better served by something driven by packet-capture. I know that Oracle Real User Information (?) (RUI) works using that principle. For more casual diagnostic sessions, I've often gotten away with the following tcpdump:
tcpdump -s0 -A -p -nn tcp and port 80
That's enough to get the full requests (and responses), it is a little messy, but the data is all there. You can clean it up a bit with a script, such as the following (tcpdump-http-headers-only) -- its not perfect (particularly on a busy server where things get harder to track).
#!/bin/bash
#
# Pass in the output of 'tcpdump -s0 -A ...' to this and it will
# output only the HTTP request headers and response headers.
#
# Cameron Kerr <cameron.kerr.nz#gmail.com>
# 2013-02-14
#
grep --line-buffered -o \
-e $'GET .*\r' \
-e $'POST .*\r' \
-e $'^[A-Z][A-Za-z0-9_-]*: .*\r' \
-e $'HTTP/1.1 .*\r' \
-e $'^\r$' \
| sed --unbuffered -e 's,\r$,,'
Alternatively, you might like to capture them (perhaps in conjunction with the -W, -C or -G options) for later analysis. This can, depending on the cipher used, also work with https connections if the key is provided (useful for Wireshark)