Преглед на файлове

use microseconds

master
Henry Case преди 5 години
родител
ревизия
d93d0b49a5
променени са 2 файла, в които са добавени 17 реда и са изтрити 63 реда
  1. +0
    -49
      rawhammer/Cargo.lock
  2. +17
    -14
      rawhammer/src/main.rs

+ 0
- 49
rawhammer/Cargo.lock Целия файл

@@ -22,16 +22,6 @@ name = "bitflags"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "cc"
version = "1.0.38"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "cfg-if"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "clap"
version = "2.33.0"
@@ -46,39 +36,16 @@ dependencies = [
"vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "ctrlc"
version = "3.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "libc"
version = "0.2.60"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "nix"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
"void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "rawhammer"
version = "0.1.0"
dependencies = [
"clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ctrlc 3.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"thread-control 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
@@ -94,11 +61,6 @@ dependencies = [
"unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "thread-control"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "unicode-width"
version = "0.1.5"
@@ -109,11 +71,6 @@ name = "vec_map"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "void"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "winapi"
version = "0.3.7"
@@ -137,18 +94,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
"checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90"
"checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd"
"checksum cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)" = "ce400c638d48ee0e9ab75aef7997609ec57367ccfe1463f21bf53c3eca67bf46"
"checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33"
"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9"
"checksum ctrlc 3.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c7dfd2d8b4c82121dfdff120f818e09fc4380b0b7e17a742081a89b94853e87f"
"checksum libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "d44e80633f007889c7eff624b709ab43c92d708caad982295768a7b13ca3b5eb"
"checksum nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6c722bee1037d430d0f8e687bbdbf222f27cc6e4e68d5caf630857bb2b6dbdce"
"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
"checksum thread-control 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "22e002431352cce4e76fd6fe77d5bf1b75ff790ea790602f0579ce58641c2eea"
"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526"
"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770"
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

+ 17
- 14
rawhammer/src/main.rs Целия файл

@@ -187,17 +187,17 @@ static CH_NTRU: &'static [u8] = b"\
\x00\x2d\x00\x02\x01\x01\x00\x2b\x00\x09\x08\x03\x04\x03\x03\x03\
\x02\x03\x01";

fn sleep(millis: u64, cmt: &'static str) {
fn sleep(micros: u64, cmt: &'static str) {
println!("[START] {}", cmt);
sleep_no_comment(millis);
sleep_no_comment(micros);
println!("[DONE] {}", cmt);
}

fn sleep_no_comment(millis: u64) {
if millis > 0 {
let ten_millis = time::Duration::from_millis(millis);
let _now = time::Instant::now();
thread::sleep(ten_millis);
fn sleep_no_comment(micros: u64) {
println!("micros {}", micros);
if micros > 0 {
let dur_micros = time::Duration::from_micros(micros);
thread::sleep(dur_micros);
}
}

@@ -229,7 +229,7 @@ fn main() -> std::io::Result<()> {
.long("msg_per_sec")
.takes_value(true)
.required(false)
.help("Number of connections sent per second (default 100)"))
.help("Number of connections sent per second (default: no limit)"))
.arg(Arg::with_name("threads")
.short("s")
.long("sending_threads")
@@ -245,11 +245,15 @@ fn main() -> std::io::Result<()> {
let dur = Duration::new(
matches.value_of("connection_timeout").unwrap_or("1")
.parse().unwrap(), 0);
let msg_per_sec: usize = matches.value_of("frequency").unwrap_or("100").parse().unwrap();
let ch_case: usize = matches.value_of("case").unwrap().parse().unwrap();
let sending_threads: usize = matches.value_of("threads").unwrap_or("1").parse().unwrap();
let msg_per_sec: usize = matches
.value_of("frequency").unwrap_or("10000000000").parse().unwrap();
let ch_case: usize = matches
.value_of("case").unwrap().parse().unwrap();
let sending_threads: usize = matches
.value_of("threads").unwrap_or("1").parse().unwrap();

println!("Sending to {0}, with freq {1} per sec on {2} threads.", sock_addr, msg_per_sec, sending_threads);
println!("Sending to {0}, with freq {1} per sec on {2} threads.",
sock_addr, msg_per_sec, sending_threads);

// Start a thread which sends CH
let mut threads = Vec::new();
@@ -259,7 +263,6 @@ fn main() -> std::io::Result<()> {
// calculates number of sent client hellos
let mut ch_sent = 0;

// Sent until CTRL+C
loop {
// try connect
let sock = TcpStream::connect_timeout(&sock_addr, dur);
@@ -276,7 +279,7 @@ fn main() -> std::io::Result<()> {
_ => panic!("Unknown case"),
};
s.shutdown(Shutdown::Both).expect("shutdown call failed");
sleep_no_comment(1000/msg_per_sec as u64);
sleep_no_comment(1000000/msg_per_sec as u64);
ch_sent += 1;
if ch_sent % 100 == 0 {
println!("nb of queries sent: {}", ch_sent);


Зареждане…
Отказ
Запис