Exemplo n.º 1
0
int
main(int argc, char *argv[])
{
    web100_agent* agent;
    web100_connection* conn;
    web100_group* group;
    web100_var* var;
    char buf[256];
    int cid;
    char** arg;

    argv0 = argv[0];

    if (argc < 3) {
        usage();
        exit(EXIT_FAILURE);
    }

    cid = atoi(argv[1]);
    
    if ((agent = web100_attach(WEB100_AGENT_TYPE_LOCAL, NULL)) == NULL) {
        web100_perror("web100_attach");
        exit(EXIT_FAILURE);
    }
    
    if ((conn = web100_connection_lookup(agent, cid)) == NULL) {
        web100_perror("web100_connection_lookup");
        exit(EXIT_FAILURE);
    }
   
    for (arg=&argv[2]; *arg; arg++) {
        if ((web100_agent_find_var_and_group(agent, *arg, &group, &var)) != WEB100_ERR_SUCCESS) {
            web100_perror("web100_agent_find_var_and_group");
            exit(EXIT_FAILURE);
        }

        if ((web100_raw_read(var, conn, buf)) != WEB100_ERR_SUCCESS) {
            web100_perror("web100_raw_read");
            exit(EXIT_FAILURE);
        }
    
        printf("%-20s: %s\n", *arg, web100_value_to_text(web100_get_var_type(var), buf));
    }

    web100_detach(agent);

    return 0;
}
Exemplo n.º 2
0
/**
 * Set Cwnd limit
 * @param connarg tcp_stat_connection pointer
 * @param group_arg tcp_stat group pointer
 * @param agentarg tcp_stat agent pointer
 * */
void setCwndlimit(tcp_stat_connection connarg, tcp_stat_group* grouparg,
                  tcp_stat_agent* agentarg, Options* optionsarg) {
#if USE_WEB100
    web100_var *LimRwin, *yar;
#elif USE_WEB10G
    struct estats_val yar;
#endif

    u_int32_t limrwin_val;

    if (optionsarg->limit > 0) {
        log_print(1, "Setting Cwnd limit - ");

#if USE_WEB100
        if (connarg != NULL) {
            log_println(1,
                        "Got web100 connection pointer for recvsfd socket\n");
            char yuff[32];
            web100_agent_find_var_and_group(agentarg, "CurMSS", &grouparg,
                                            &yar);
            web100_raw_read(yar, connarg, yuff);
            log_println(1, "MSS = %s, multiplication factor = %d",
                        web100_value_to_text(web100_get_var_type(yar), yuff),
                        optionsarg->limit);
            limrwin_val = optionsarg->limit
                          * (atoi(
                                 web100_value_to_text(web100_get_var_type(yar),
                                         yuff)));
            web100_agent_find_var_and_group(agentarg, "LimRwin", &grouparg,
                                            &LimRwin);
            log_print(1, "now write %d to limit the Receive window",
                      limrwin_val);
            web100_raw_write(LimRwin, connarg, &limrwin_val);
#elif USE_WEB10G
        if (connarg != -1) {
            log_println(1,
                        "Got web10g connection for recvsfd socket\n");
            web10g_get_val(agentarg, connarg, "CurMSS", &yar);
            log_println(1, "MSS = %s, multiplication factor = %d",
                        yar.uv32, optionsarg->limit);
            limrwin_val = optionsarg->limit * yar.uv32;
            log_print(1, "now write %d to limit the Receive window", limrwin_val);
            estats_write_var("LimRwin", limrwin_val, connarg, agentarg);
#endif
            log_println(1, "  ---  Done");
        }
    }
}

/**
 * Check if receiver is clogged and use decision to temporarily
 * stop sending packets.
 * @param nextseqtosend integer indicating the Next Sequence Number To Be Sent
 * @param lastunackedseq integer indicating the oldest un-acked sequence number
 * @return integer indicating whether buffer is clogged
 * */
int is_buffer_clogged(int nextseqtosend, int lastunackedseq) {
    int recclog = 0;
    if ((RECLTH << 2) < (nextseqtosend - lastunackedseq - 1)) {
        recclog = 1;
    }
    return recclog;
}