mptcp
mptcp copied to clipboard
no such file or directory when using setsockopt(fd, SOL_TCP, MPTCP_SCHEDULER, scheduler, sizeof(scheduler))
I have installed mptcpv0.95 on both client(Ubuntu) and server(Ubuntu) successfully.But when I used the APIs mentioned in http://multipath-tcp.org/pmwiki.php/Users/ConfigureMPTCP,many errors occured. Problem 1: char *scheduler = "redundant"; setsockopt(fd, SOL_TCP, MPTCP_SCHEDULER, scheduler, sizeof(scheduler)); It turned back the erro "no such file or directory".
Problem2: getsockopt(..., ..., MPTCP_INFO, &minfo, sizeof(minfo)); It turned back the erro "bad address".
Can you please help me solve these problems or perhaps tell me why such errors occurred?
Hi
It seems the wiki is down for the moment but are you sure it is what is written in the example?
char *scheduler = "redundant";
setsockopt(fd, SOL_TCP, MPTCP_SCHEDULER, scheduler, sizeof(scheduler));
Here sizeof(scheduler)
will return 8, the size of a pointer on x86_64. While what you should write is the size of the array.
In other words, either you declare an array:
char scheduler[] = "redundant";
Or you give the correct number of chars:
setsockopt(fd, SOL_TCP, MPTCP_SCHEDULER, scheduler, strlen(scheduler) + 1);
For the second problem, we would need the entire code but I am sure this MPTCP_INFO
code is well tested.
Thank you for your help and my first problem has been solved(just like what you told me). For the second problem. The entire code is here:
struct mptcp_info minfo;
struct mptcp_meta_info meta_info;
struct tcp_info initial;
struct tcp_info others[3];
struct mptcp_sub_info others_info[3];
minfo.tcp_info_len = sizeof(struct tcp_info);
minfo.sub_len = sizeof(others);
minfo.meta_len = sizeof(struct mptcp_meta_info);
minfo.meta_info = &meta_info;
minfo.initial = &initial;
minfo.subflows = &others;
minfo.sub_info_len = sizeof(struct mptcp_sub_info);
minfo.total_sub_info_len = sizeof(others_info);
minfo.subflow_info = &others_info;
int sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if(sockfd==-1)
printf("\nsocket error");
struct sockaddr_in serv_addr;
memset(&serv_addr, 0, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = inet_addr("223.2.25.170");
serv_addr.sin_port = htons(8080);
char pathmanager[] = "fullmesh";
int a =setsockopt(sockfd, SOL_TCP, MPTCP_PATH_MANAGER, pathmanager, sizeof(pathmanager));
printf("\nfullmesh a=%d",a);
char scheduler[] = "redundant";
setsockopt(sockfd, SOL_TCP, MPTCP_SCHEDULER, scheduler, sizeof(scheduler));
connect(sockfd, (struct sockaddr*)&serv_addr, sizeof(serv_addr));
int enable=1;
setsockopt(sockfd, SOL_TCP, MPTCP_ENABLED, &enable, sizeof(enable));
m = getsockopt(sockfd, IPPROTO_TCP, MPTCP_INFO, &minfo, sizeof(minfo));
if(m==-1)
{
printf("\ncannot getsockopt(MPTCP_INFO)");
printf("\nerrno = %s\n",strerror(errno));
}
Just to be sure, can you try:
m = getsockopt(sockfd, IPPROTO_TCP, MPTCP_INFO, &minfo, sizeof(minfo)*1000)
and also print:
printf("size: %zu, %zu\n", sizeof(minfo), sizeof(struct mptcp_info))
The size of minfo is 56 and the size of mptcp_info is also 56. The error also occurred.
Not sure why you still have the issue with * 1000
.
@cpaasch : any idea? :)
I will give it a shot later this week on v0.95.