a26b09e152a886feeac77e760638e0ee6761ba49
[p2p-kernel-protocol.git] / module / test.sh
1 #!/bin/bash
2
3 LISTENERS=2
4 START_PORT=60001
5
6 #use nc.traditional
7 echo 2 | update-alternatives --config nc &> /dev/null
8
9 #set -x
10
11 # listen for UDP packets on localhost, port 60001 (run in background)
12 for listener in $(seq $LISTENERS); do
13         netcat -l -u -p $START_PORT &
14         pids="$pids $!"
15         START_PORT=$(($START_PORT + 1))
16 done
17
18 # wait for netcat to start listening
19 sleep 1
20
21 # insert module, causing the message to be sent
22 insmod p2psp.ko
23
24 # remove module
25 rmmod p2psp
26
27 # kill netcat
28 for pid in $pids; do
29         kill $pid &> /dev/null
30 done