Introduction
The ErrorGeneratingFilter is an IoFilter
with to introduce random error in your data streams. The filter can insert/delete/modify bytes from the data stream with a specified probability.
The Code
To use an ErrorGeneratingFilter:
- Instantiate Error Generating Filter
- Set probability for modifying data stream (insert/delete/modify)
- Enable manipulation for read/write data
- Add to the filter chain
Instantiating the filter
Set Probability for modifying Data Stream
For activate the change of some bytes in your IoBuffer
, for a probability of 200 out of 1000 IoBuffer processed :
or activate the insertion of some bytes in your IoBuffer
, for a probability of 200 out of 1000 :
And for the removing of some bytes :
Enable manipulation of read/write data
You can activate the error generation for write or read with the following methods :
Now add it to filter chain, it'll generate the error at the given probability.