260 likes | 348 Views
Network Simulation and Testing. Polly Huang EE NTU http://cc.ee.ntu.edu.tw/~phuang phuang@cc.ee.ntu.edu.tw. Testing on Real Systems. dummynet. 4 Weeks. Week 1 Introduction, basic features Week 2 Setup and bandwidth management Week 3 Advanced features Week 4
E N D
Network Simulation and Testing Polly Huang EE NTU http://cc.ee.ntu.edu.tw/~phuang phuang@cc.ee.ntu.edu.tw
Testing on Real Systems dummynet
4 Weeks • Week 1 • Introduction, basic features • Week 2 • Setup and bandwidth management • Week 3 • Advanced features • Week 4 • Testing over a simple network
Today • Advanced features • Largely based on Luigi’s slides
Quick Review of Basic Features • Two major components • The pipe • The packet filter • Simple examples • Configuration • System setting
A Simple Example out IP layer 1 2 in Link layer ipfw add pipe 1 ip from any to any in ipfw add pipe 2 ip from any to any out
The Detailed System View Higher-level processes in-pipe ipfw else drop true true out-pipe ipfw else drop in-traffic out-traffic
Advanced Features • Multipath • For packet re-ordering emulation • Dynamic pipes • For automatic per-flow piping • Dynamic queues • For automatic per-flow queuing • Extensions • Bursty loss and delay jitter
Multipath • For emulation of packet re-ordering • The usage • Create multiple paths • Filter packets to these paths based on certain criteria • Currently, the criteria is probabilistic
Multipath Example ipfw pipe 1 config bw 2Mbits/s delay 80ms ipfw pipe 2 config bw 3Mbits/s delay 30ms ipfw pipe 3 config bw 1Mbits/s delay 100ms ipfw add prob 0.33 pipe 1 tcp from me to any ipfw add prob 0.5 pipe 2 tcp from me to any ipfw add prob 1 pipe 3 tcp from me to any
The Rules of Multipath Filtering • For each packet arriving at the dummynet • Match the 1st filter • For each packet arriving at the filter • Take a random number • Check if it falls within the filter probability • If yes, pass packets through the rule pipe • If not, pass packets to the next filter • Recursive use of the ‘packet arriving at the filter’ algorithm
Illustration of the Multi-Filtering Higher-level processes 0.67 Filter 1 0.33 Filter 2 0.5 0.5 Filter 2 0 1 else drop Pipe 1 Pipe 2 Pipe 3 out-traffic
Dynamic Pipes • For per-flow piping and monitoring • The usage • Adding a mask to the source or destination IP • Representing the level of flow classification
Dynamic Pipe Example ipfw pipe 1 config bw 2Mbits/s delay 80ms mask src-ip 0x000000ff
The Rules of Per-Flow Piping mask src-ip 0x000000ff • Packet src/dst addresses are ANDed with the mask • Src/dst addresses masking to the same number belong to the same flow • 256 flows in this example • The number is the flow ID • A pipe of the same configuration is created per flow
WFQ • Weighted Fair Queuing • For sharing of bandwidth • Statistical limitation • One pipe for all flows • A flow-based queue to determine which flow gets how much bandwidth share
WFQ Example ipfw pipe 10 config bw 2Mbits/s ipfw queue 1 config pipe 10 weight 50 ipfw queue 2 config pipe 10 weight 20 ipfw queue 3 config pipe 10 weight 1 ipfw add queue 1 tcp from me to any ssh ipfw add queue 1 udp from me to any 53 ipfw add queue 2 tcp from me to any 25 ipfw add queue 3 IP from me to any
Calculating the Share • Sum all the weights • The flow gets the fraction of bandwidth proportional to • The ratio of its weight to the sum
Statistical Sharing • Note the distinction of statistical bandwidth limitation to deterministic • One flow can get the whole bandwidth if no one else is in queue
Dynamic Queuing • The idea is similar to dynamic piping ipfw queue 1 config pipe 10 weight 50 mask src-ip 000000ff
Extension • What if we want to emulate • Bursty losses • Delay jitter
Using Existing Mechanism • Bursty losses • Add bursty traffic to compete with the traffic of observation • So that the bursty traffic cause bursty drops to the traffic of observation • Delay jitter • Add varying traffic to cause varying queue size • So that the delay variance is of the traffic of observation goes up
Adding to dummynet • Modify • ip_fw.c • ip_dymmynet.c • The BSD kernel is • Very modular • Extensively commented
Performance • Packet forwarding rate with pipe is a few % lower than without pipe • Packet copying is constant • Queue and pipe schedule is O(logN) • N: number of queues or pipes • Pipe/queue state fetching could be time consuming
Conclusion • Quite easy to use • If installing BSD isn’t a problem • If loading the dummynet kernel isn’t a problem • Quite a bit of applications with the simple functions • Need to be careful about how data flow • Complicated applications might be achievable with a bit of creativity • Usually the hardest part is knowing what to test
Next Week • Laptops • Running FreeBSD • With access to FreeBSD • FreeBSD • The kernel with proper options