lsquic icon indicating copy to clipboard operation
lsquic copied to clipboard

how does connection migration work?

Open wxie7 opened this issue 2 years ago • 0 comments

hello, I'm trying to test connection migration based on echo_client. My idea is this: when the standard input of the client receives a specific string("chgxxx"), close the previous fd, and then create and bind new fd on the new port. Using Wireshark, I observed that the server did send the path challenge frame, but the client did not respond to the frame correctly. Is there a problem with my switching code,

        if (0 == strncmp("chg", st_h->buf, 3))
        {
            // get last fd
            struct cv_client_ctx *client_ctx = st_h->client_ctx;
            struct cv_prog *prog = client_ctx->prog;
            struct cv_service_port *sport = prog->cur_port;

            // close last fd
            close(sport->fd);
            event_del(sport->ev);
            //
            // create new fd
            struct sockaddr_in next_addr = create_addr(ports_pool[1]);
            sport->fd = socket(AF_INET, SOCK_DGRAM, 0);
            sport->sin_local = next_addr;

            if (0 != bind(sport->fd, (struct sockaddr *)&next_addr,
                                            sizeof(next_addr)))
            {
                perror("bind again error");
                exit(EXIT_FAILURE);
            }
            make_fd_nonblock(sport->fd);
            sport->ev = event_new(prog->eb, sport->fd,
                    EV_READ|EV_PERSIST, read_handler, sport);
            // activate new fd
            event_add(sport->ev, NULL);

        }

The above is the code related to switching. This link contains all the codehttps://wtools.io/paste-code/bCbd

wxie7 avatar May 23 '22 13:05 wxie7