include quic_types
action random_stream_pos(min:stream_pos,max:stream_pos) returns (res:stream_pos)
action greater_stream_pos(min:stream_pos) returns (res:stream_pos)
action lower_stream_pos(max:stream_pos) returns (res:stream_pos)
implementation {
implement random_stream_pos(min:stream_pos,max:stream_pos) {
<<<
srand((unsigned) time(0)); //fixed or random seed ?
res = 0;
res = ::rand()% (max-min+1) + min;
std::cerr << "between random: " << res << "\n";
>>>
}
implement greater_stream_pos(min:stream_pos) {
<<<
srand((unsigned) time(0)); //fixed or random seed ?
res = 0;
res = ::rand()%32767 + (min+1);
std::cerr << "greater random: " << res << "\n";
>>>
}
implement lower_stream_pos(max:stream_pos) {
<<<
res = 0;
srand((unsigned) time(0)); //fixed or random seed ?
res = ::rand()%(max-1) + 0;
std::cerr << "lower random: " << res << "\n";
>>>
}
}
action random_stream_id(min:stream_id,max:stream_id) returns (res:stream_id)
action greater_stream_id(min:stream_id) returns (res:stream_id)
action lower_stream_id(max:stream_id) returns (res:stream_id)
implementation {
implement random_stream_id(min:stream_id,max:stream_id) {
<<<
srand((unsigned) time(0)); //fixed or random seed ?
res = 0;
res = ::rand()% (max-min+1) + min;
std::cerr << "between random: " << res << "\n";
>>>
}
implement greater_stream_id(min:stream_id) {
<<<
srand((unsigned) time(0)); //fixed or random seed ?
res = 0;
res = ::rand()%32767 + (min+1);
std::cerr << "greater random: " << res << "\n";
>>>
}
implement lower_stream_id(max:stream_id) {
<<<
res = 0;
srand((unsigned) time(0)); //fixed or random seed ?
res = ::rand()%(max-1) + 0;
std::cerr << "lower random: " << res << "\n";
>>>
}
}
action random_stream_data(min:stream_pos,max:stream_pos,len:stream_pos) returns (res:stream_data)
implementation {
implement random_stream_data(min:stream_pos,max:stream_pos,len:stream_pos) {
<<<
// 128 + 40 (38..) bit = 2^168 value = 21 bytes
srand((unsigned) time(0)); //fixed or random seed ?
res.resize(len);
for (unsigned i = 0; i < len; i++) {
res[len-i-1] = 0xff & ::rand()%(max-min+1) + min;
}
std::cerr << "between random: " << res << "\n";
>>>
}
}
action random_microsecs(min:milliseconds,max:milliseconds) returns (res:milliseconds)
action greater_microsecs(min:milliseconds) returns (res:milliseconds)
action lower_microsecs(max:milliseconds) returns (res:milliseconds)
implementation {
implement random_microsecs(min:milliseconds,max:milliseconds) {
<<<
srand((unsigned) time(0)); //fixed or random seed ?
res = 0;
res = ::rand()%(max-min+1) + min*1000;
std::cerr << "between random: " << res << "\n";
>>>
}
implement greater_microsecs(min:milliseconds) {
<<<
srand((unsigned) time(0)); //fixed or random seed ?
res = 0;
res = ::rand()%32767 + (min+1);
std::cerr << "greater random: " << res << "\n";
>>>
}
implement lower_microsecs(max:milliseconds) {
<<<
srand((unsigned) time(0)); //fixed or random seed ?
res = 0;
res = ::rand()%(max-1) + 0;
std::cerr << "lower random: " << res << "\n";
>>>
}
}