Date: Wed, 18 Jul 2012 15:14:28 +0530 From: Deepak Kumar <dk311990@gmail.com> To: freebsd-net@freebsd.org Subject: determine the nic pairs Message-ID: <CAELRkmeex3b_dn5B-mi%2BDY4Ax8RhYXFgPYOG8JUxJ2jW7m8=9A@mail.gmail.com> In-Reply-To: <CAELRkmc_h57zqHoUUkptzugLAM7t6gvmbWRJDrTFXMbjBzYaKg@mail.gmail.com> References: <CAELRkmc_h57zqHoUUkptzugLAM7t6gvmbWRJDrTFXMbjBzYaKg@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi Enthusiast, I have a server which has around 20 nic interfaces. Some are connected port to port via cross cable and some are connected via a switch and few are not connected. (Let consider all are connected port to port) I want to find out the way so that I can determine the pairs efficiently. I assigned ip starting from 172.x.x.30 with netmask 255.255.255.0 I created as many sockets as there are interfaces with socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP) then I bind the all but one interfaces to the ip I gave using bind(sockfd, (struct sockaddr *)&in, sizeof(in)); where in is something like bzero(&in, sizeof(in)); in.sin_family = AF_INET; in.sin_port = htons(2074); in.sin_addr.s_addr = inet_addr("172.x.x.30+interfaceno"); and one left socket I did socket creation and using setsockopt I did int option = 1; setsockopt(sockfd[counter], SOL_SOCKET, SO_BROADCAST, &option, sizeof(option)); and do sendto(sockfd, arr, sizeof(arr), 0, (struct sockaddr *)&in, len); where in is bzero(&in, sizeof(in)); in.sin_family = AF_INET; in.sin_port = htons(2074); in.sin_addr.s_addr = inet_addr(172.x.x.255); Now I want to send the packet from one interface and who ever receive should be its partner. But when I do recvfrom for one socket it blocks and I am not able to implement timeout for it. select is not working as it need file discripter and socket call is returning struct socket. So how should I implement timeout in recvfrom or use there exist some equivalent of select for struct socket or any other way to implement this. PS: Ping is working fine in determining the pair but taking to much time.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAELRkmeex3b_dn5B-mi%2BDY4Ax8RhYXFgPYOG8JUxJ2jW7m8=9A>