FastTcpAgent::FastTcpAgent() : TcpAgent(), avgRTT_(0), baseRTT_(0), avg_cwnd_last_RTT_(1), alpha_(0), beta_(0), fastrecov_(FALSE), pipe_(-1), next_pkt_(0), firstpartial_(0), last_natural_ack_number_(-1), on_first_rtt_(true), gamma_(0.5) { sendtime_ = NULL; transmits_ = NULL; cwnd_array_ = NULL; bind_bool("partial_ack_", &partial_ack_); /* Use the Reassembly Queue based scoreboard as * ScoreBoard is O(cwnd) which is bad for HSTCP * scb_ = new ScoreBoard(new ScoreBoardNode[SBSIZE],SBSIZE); */ scb_ = new ScoreBoardRQ(); #ifdef TCP_DELAY_BIND_ALL #else /* ! TCP_DELAY_BIND_ALL */ /*bind tunable parameters*/ bind("fast_update_cwnd_interval_", &cwnd_update_period_); bind("avg_cwnd_last_RTT_", &avg_cwnd_last_RTT_); bind("avgRTT_", &avgRTT_); bind("baseRTT_", &baseRTT_); bind("alpha_", &alpha_); bind("beta_", &beta_); bind("high_accuracy_cwnd_", &high_accuracy_cwnd_); bind("mi_threshold_", &mi_threshold_); // bind("pipe_", &pipe_); //weixl // bind("sack_num_", &sack_num_); //weixl // bind("sack_len_", &sack_len_); //weixl // bind("alpha_tuning_", &alpha_tuning_); bind("gamma_", &gamma_); #endif /* TCP_DELAY_BIND_ALL */ #ifdef FASTTCPAGENT_DEBUG static unsigned int s_agent_ID = 0; char strTmp[30]; sprintf(strTmp, "agent%d_%s.txt", s_agent_ID, "record0"); fasttcpagent_recordfps[0] = fopen(strTmp, "w+"); sprintf(strTmp, "agent%d_%s.txt", s_agent_ID, "record1"); fasttcpagent_recordfps[1] = fopen(strTmp, "w+"); s_agent_ID++; #endif }
DeviceOptions::DeviceOptions(shared_ptr<pv::device::DevInst> dev_inst, const sr_channel_group *group) : _dev_inst(dev_inst), _group(group) { assert(dev_inst); GVariant *gvar_opts; gsize num_opts; if (!(gvar_opts = dev_inst->list_config(group, SR_CONF_DEVICE_OPTIONS))) /* Driver supports no device instance options. */ return; const int *const options = (const int32_t *)g_variant_get_fixed_array( gvar_opts, &num_opts, sizeof(int32_t)); for (unsigned int i = 0; i < num_opts; i++) { const struct sr_config_info *const info = sr_config_info_get(options[i]); if (!info) continue; const int key = info->key; GVariant *const gvar_list = dev_inst->list_config(group, key); const QString name = QString::fromUtf8(info->name); const Property::Getter get = [&, key]() { return _dev_inst->get_config(_group, key); }; const Property::Setter set = [&, key](GVariant *value) { _dev_inst->set_config(_group, key, value); }; switch(key) { case SR_CONF_SAMPLERATE: // Sample rate values are not bound because they are shown // in the SamplingBar break; case SR_CONF_CAPTURE_RATIO: bind_int(name, "%", pair<int64_t, int64_t>(0, 100), get, set); break; case SR_CONF_PATTERN_MODE: case SR_CONF_BUFFERSIZE: case SR_CONF_TRIGGER_SOURCE: case SR_CONF_TRIGGER_SLOPE: case SR_CONF_FILTER: case SR_CONF_COUPLING: case SR_CONF_CLOCK_EDGE: bind_enum(name, key, gvar_list, get, set); break; case SR_CONF_EXTERNAL_CLOCK: case SR_CONF_RLE: bind_bool(name, get, set); break; case SR_CONF_TIMEBASE: bind_enum(name, key, gvar_list, get, set, print_timebase); break; case SR_CONF_VDIV: bind_enum(name, key, gvar_list, get, set, print_vdiv); break; case SR_CONF_VOLTAGE_THRESHOLD: bind_enum(name, key, gvar_list, get, set, print_voltage_threshold); break; } if (gvar_list) g_variant_unref(gvar_list); } g_variant_unref(gvar_opts); }
DeviceOptions::DeviceOptions(struct sr_dev_inst *sdi) : _sdi(sdi) { GVariant *gvar_opts, *gvar_list; gsize num_opts; if ((sr_config_list(sdi->driver, SR_CONF_DEVICE_CONFIGS, &gvar_opts, sdi) != SR_OK)) /* Driver supports no device instance options. */ return; const int *const options = (const int32_t *)g_variant_get_fixed_array( gvar_opts, &num_opts, sizeof(int32_t)); for (unsigned int i = 0; i < num_opts; i++) { const struct sr_config_info *const info = sr_config_info_get(options[i]); if (!info) continue; const int key = info->key; if(sr_config_list(_sdi->driver, key, &gvar_list, _sdi) != SR_OK) gvar_list = NULL; const QString name(info->name); switch(key) { case SR_CONF_SAMPLERATE: bind_samplerate(name, gvar_list); break; case SR_CONF_CAPTURE_RATIO: bind_int(name, key, "%", pair<int64_t, int64_t>(0, 100)); break; case SR_CONF_DEVICE_MODE: case SR_CONF_PATTERN_MODE: case SR_CONF_BUFFERSIZE: case SR_CONF_TRIGGER_SOURCE: case SR_CONF_FILTER: case SR_CONF_COUPLING: bind_enum(name, key, gvar_list); break; case SR_CONF_RLE: bind_bool(name, key); break; case SR_CONF_CLOCK_TYPE: bind_bool(name, key); break; case SR_CONF_TIMEBASE: bind_enum(name, key, gvar_list, print_timebase); break; case SR_CONF_VDIV: bind_enum(name, key, gvar_list, print_vdiv); break; } if (gvar_list) g_variant_unref(gvar_list); } g_variant_unref(gvar_opts); }
DeviceOptions::DeviceOptions(struct sr_dev_inst *sdi) : _sdi(sdi) { GVariant *gvar_opts, *gvar_list; gsize num_opts; if ((sr_config_list(sdi->driver, sdi, NULL, SR_CONF_DEVICE_CONFIGS, &gvar_opts) != SR_OK)) /* Driver supports no device instance options. */ return; const int *const options = (const int32_t *)g_variant_get_fixed_array( gvar_opts, &num_opts, sizeof(int32_t)); for (unsigned int i = 0; i < num_opts; i++) { const struct sr_config_info *const info = sr_config_info_get(options[i]); if (!info) continue; const int key = info->key; if(sr_config_list(_sdi->driver, _sdi, NULL, key, &gvar_list) != SR_OK) gvar_list = NULL; const QString name(info->label); switch(key) { case SR_CONF_SAMPLERATE: bind_samplerate(name, gvar_list); break; case SR_CONF_CAPTURE_RATIO: bind_int(name, key, "%", pair<int64_t, int64_t>(0, 100)); break; case SR_CONF_PATTERN_MODE: case SR_CONF_BUFFERSIZE: case SR_CONF_TRIGGER_SOURCE: case SR_CONF_FILTER: case SR_CONF_COUPLING: case SR_CONF_EN_CH: case SR_CONF_OPERATION_MODE: case SR_CONF_THRESHOLD: case SR_CONF_ZERO: case SR_CONF_STREAM: case SR_CONF_TEST: case SR_CONF_STATUS: case SR_CONF_FACTOR: bind_enum(name, key, gvar_list); break; case SR_CONF_VTH: bind_double(name, key, "V", pair<double, double>(0.0, 5.0), 1, 0.1); break; case SR_CONF_RLE: bind_bool(name, key); break; case SR_CONF_CLOCK_TYPE: case SR_CONF_CLOCK_EDGE: case SR_CONF_INSTANT: case SR_CONF_DATALOCK: bind_bool(name, key); break; case SR_CONF_TIMEBASE: bind_enum(name, key, gvar_list, print_timebase); break; case SR_CONF_VDIV: bind_enum(name, key, gvar_list, print_vdiv); break; default: gvar_list = NULL; } if (gvar_list) g_variant_unref(gvar_list); } g_variant_unref(gvar_opts); }