proxygen
Main.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree. An additional grant
7  * of patent rights can be found in the PATENTS file in the same directory.
8  *
9  */
10 #include <folly/init/Init.h>
12 
16 
17 DEFINE_string(input, "", "File containing requests");
18 DEFINE_string(scheme,
19  "qpack",
20  "Scheme: <qpack|qmin|hpack>");
21 
22 DEFINE_int32(rtt, 100, "Simulated RTT");
23 DEFINE_double(lossp, 0.0, "Loss Probability");
24 DEFINE_double(delayp, 0.05, "Delay Probability");
25 DEFINE_int32(delay, 100, "Max extra delay");
26 DEFINE_int32(ooo_thresh, 0, "First seqn to allow ooo");
27 DEFINE_int32(table_size, 4096, "HPACK dynamic table size");
28 DEFINE_int64(seed, 0, "RNG seed");
29 DEFINE_bool(blend, true, "Blend all facebook.com and fbcdn.net domains");
30 DEFINE_int32(max_blocking, 100,
31  "Maximum number of vulnerable/blocking header blocks");
32 DEFINE_bool(same_packet_compression,
33  true,
34  "Allow QPACK to compress across "
35  "headers the same packet");
36 
37 using namespace proxygen::compress;
38 
39 int main(int argc, char* argv[]) {
40  folly::init(&argc, &argv, true);
41  if (FLAGS_same_packet_compression) {
42  LOG(WARNING) << "Same packet compression no longer supported";
43  }
44 
45  if (FLAGS_input.empty()) {
46  LOG(ERROR) << "Must supply a filename";
47  return 1;
48  }
49 
51  if (FLAGS_scheme == "qpack") {
52  LOG(INFO) << "Using QPACK";
54  } else if (FLAGS_scheme == "qmin") {
55  LOG(INFO) << "Using QMIN";
56  t = SchemeType::QMIN;
57  } else if (FLAGS_scheme == "hpack") {
58  LOG(INFO) << "Using HPACK with table size=" << FLAGS_table_size;
60  } else {
61  LOG(ERROR) << "Unsupported scheme";
62  return 1;
63  }
64 
65  if (FLAGS_seed == 0) {
66  FLAGS_seed = folly::Random::rand64();
67  std::cout << "Seed: " << FLAGS_seed << std::endl;
68  }
69  SimParams p{t,
70  FLAGS_seed,
71  std::chrono::milliseconds(FLAGS_rtt),
72  FLAGS_lossp,
73  FLAGS_delayp,
74  std::chrono::milliseconds(FLAGS_delay),
75  uint16_t(FLAGS_ooo_thresh),
76  FLAGS_blend,
77  FLAGS_same_packet_compression,
78  uint32_t(FLAGS_table_size),
79  uint32_t(FLAGS_max_blocking)};
80  CompressionSimulator sim(p);
81  if (sim.readInputFromFileAndSchedule(FLAGS_input)) {
82  sim.run();
83  }
84 
85  return 0;
86 }
bool readInputFromFileAndSchedule(const std::string &filename)
static const int seed
DEFINE_string(input,"","File containing requests")
DEFINE_bool(blend, true,"Blend all facebook.com and fbcdn.net domains")
DEFINE_double(lossp, 0.0,"Loss Probability")
DEFINE_int32(rtt, 100,"Simulated RTT")
int main(int argc, char **argv)
Definition: Main.cpp:27
void init(int *argc, char ***argv, bool removeFlags)
Definition: Init.cpp:34
char ** argv
DEFINE_int64(seed, 0,"RNG seed")
static uint64_t rand64()
Definition: Random.h:263