ErrorGeneratingFilter Tutorial

Introduction

The ErrorGeneratingFilter is an very simple IoFilter with the goal to introduce random error in your data streams.

The code

It's quite simple to use :

ErrorGeneratingFilter egf = new ErrorGeneratingFilter();

For activate the change of some bytes in your IoBuffer, for a probability of 200 out of 1000 IoBuffer processed :

egf.setChangeByteProbability(200);

or activate the insertion of some bytes in your IoBuffer, for a probability of 200 out of 1000 :

egf.setInsertByteProbability(200);

And for the removing of some bytes :

egf.setRemoveByteProbability(200);

You can activate the error generation for write or read with the following methods :

egf.setManipulateReads(true);
egf.setManipulateWrites(true);

Now add it to any session filter chain, it'll generate the error at the given probability.

Added by Julien Vermillard, last edited by Trustin Lee on Jan 18, 2008