Network Protocol Design
Network Protocol Design
EuroBSD 2007
EuroBSD 2007
Latency
- How long does does a packet take to transit the system?
Bandwidth
- How many packets can we send per second?
EuroBSD 2007
Code Inspection
- Finds faults by reading implementation
Fuzzing Tools
- Submit random junk in order to trigger a fault
EuroBSD 2007
TAHI
- Open source from the Wide Projecn - Used for IPv6 and IPsec testing
Netperf
- Used for performance testing
NetPIPE
- A better performance tester
6
EuroBSD 2007
7
BSD Can 2006 [email protected]
Terminology
Device Under Test (DUT)
- The system youre testing
Lab Network
- The connection to the real world - Used to get new images, code, les etc.
EuroBSD 2007
The Problem
Writing network protocol code is hard Testing network protocols is as hard as
writing the protocol in the rst place
- Only support a small number of packets - Not extensible - Written in write-once languages
EuroBSD 2007
EuroBSD 2007
10
The socket(2) API is designed with normal Writing packets directly to bpf(4) is an error
prone and lengthy process network stack
EuroBSD 2007
11
BSD Licensed
- http://pcs.sf.net
EuroBSD 2007
12
EuroBSD 2007
13
To this!
len = sizeof (struct ip) + tlen;
bzero(ipov->ih_x1, sizeof(ipov->ih_x1));
ipov->ih_len = (u_short)tlen;
ipov->ih_len = htons(ipov->ih_len);
th->th_sum = in_cksum(m, len);
(th->th_sum) { if
tcpstat.tcps_rcvbadsum++;
goto drop;
}
EuroBSD 2007
14
EuroBSD 2007
15
Advantages of PCS
Easy to specify new packet formats Natural way of setting and getting packet
elds
EuroBSD 2007
16
17
The syncache has a timer which controls The DUT must send 4 packets back to the
EuroBSD 2007
18
EuroBSD 2007
19
Setting up IP
ip = ipv4() ip.version = 4 ip.hlen = 5 ip.tos = 0 ip.id = 13000 ip.flags = 0 ip.offset = 0 ip.ttl = 64 ip.checksum = 0 ip.protocol = IPPROTO_TCP ip.src = self.src ip.dst = self.dst
EuroBSD 2007
20
Setting up TCP
tcppacket = tcp() tcppacket.sport = self.sport tcppacket.dport = self.dport tcppacket.sequence = 42 tcppacket.offset = 5; tcppacket.syn = 1 tcppacket.push = 0 tcppacket.window = 4096 tcppacket.checksum = 0
EuroBSD 2007
21
EuroBSD 2007
22
Transmission
instream = PcapConnector("cxgb4") instream.setfilter("ip"); output = PcapConnector("cxgb4") out = output.write(packet.bytes, len(packet.bytes))
EuroBSD 2007
23
24
Some Statistics
PCS Test is less than 60 lines of code This test was written by Kip Macy in about
15 minutes
A similar test in C was 600 lines Similar code in the kernel is hundreds of
lines and not easy to extract or re-use
EuroBSD 2007
25
EuroBSD 2007
26
EuroBSD 2007
27
Future Work
More packets
802.11 A more complete DNS Appletalk Better support of HTTP
More tests
- TCP Conformance Test Suite Project ([email protected]) - IPv6 and IPsec Conformance (TAHI replacment) - Fuzzers
A more comprehensive test framework Integration to the FreeBSD regression tests More tools based on PCS
- The Packet Debugger
EuroBSD 2007
28
Questions?
Main Pages
- http://pcs.sf.net - http://pktdbg.sf.net
Ports
- /usr/ports/net/py-pcs
Contribute!
- Patches, bugs, requests - https://sourceforge.net/projects/pcs/
EuroBSD 2007
29