Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 27 Feb 2010 15:31:45 +0900
From:      Hideki Yamamoto <hyama99@gmail.com>
To:        freebsd-net@freebsd.org
Subject:   Re: IPv6 multicast packet size
Message-ID:  <90dbee151002262231v5d80a5cbua62786b5847c147b@mail.gmail.com>
In-Reply-To: <90dbee151002211402o52ed7cf6q352bd1ef339379bf@mail.gmail.com>
References:  <90dbee151002211402o52ed7cf6q352bd1ef339379bf@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,

I have found the answer to my question.
The following lines resolved my problem.

	sock_optval=3D0;
	error =3D setsockopt(send_s, IPPROTO_IPV6, IPV6_USE_MIN_MTU,
                         &sock_optval, sizeof(sock_optval));

2010/2/22 Hideki Yamamoto <hyama99@gmail.com>:
> Hi,
>
> I have encountered IPv6 multicast problem.
> I cannot send UDP packet longer than Shortest MTU.
> It seems the bug of IPv6 multicast kernel.
> I used the same application from FreeBSD 4.11. On that old version,
> any problems happens. =A0When I would like to change the platform of
> this application from 4.11 to 7.2 or later, I encountered this
> problem.
> Does anyone have any information about this problem?
>
> The followings are OS information I have tested, the result of
> Tshark command, and source code of test program.
>
> Best regards,
>
> Hideki Yamamoto
>
> -------------------------------------------------------------------------=
-
> OS information
> -------------------------------------------------------------------------=
-
> # sysctl -a |grep v6
> net.inet.tcp.v6mssdflt: 1024
> net.inet6.ip6.v6only: 1
> # sysctl -a |grep mtu
> net.inet.tcp.path_mtu_discovery: 1
> net.inet.sctp.pmtu_raise_time: 600
> net.inet6.ip6.mcast_pmtu: 0
> # uname -a
> FreeBSD tulip 9.0-CURRENT FreeBSD 9.0-CURRENT #16: Fri Jan 15 05:25:24
> JST 2010 =A0 =A0 root@tulip:/usr/obj/usr/src/sys/tulip8 =A0i386
> tulip#
>
> -------------------------------------------------------------------------=
-
> Tshark output that shows the packets are devided into two packtet when
> delivering 1400 byte lenghth packets.
> -------------------------------------------------------------------------=
-
> # ./udp -s 1400 -o &
> # tshark -VV -i fxp1 host ff3e::9800:600 |grep -v aaaaaaaaa
> Capturing on fxp1
> Frame 1 (1294 bytes on wire, 1294 bytes captured)
> =A0 Arrival Time: Feb 21, 2010 17:35:08.560297000
> =A0 [Time delta from previous captured frame: 0.000000000 seconds]
> =A0 [Time delta from previous displayed frame: 0.000000000 seconds]
> =A0 [Time since reference or first frame: 0.000000000 seconds]
> =A0 Frame Number: 1
> =A0 Frame Length: 1294 bytes
> =A0 Capture Length: 1294 bytes
> =A0 [Frame is marked: False]
> =A0 [Protocols in frame: eth:ipv6:data]
> Ethernet II, Src: Intel_89:d6:d9 (00:d0:b7:89:d6:d9), Dst:
> IPv6mcast_98:00:06:00 (33:33:98:00:06:00)
> =A0 Destination: IPv6mcast_98:00:06:00 (33:33:98:00:06:00)
> =A0 =A0 =A0 Address: IPv6mcast_98:00:06:00 (33:33:98:00:06:00)
> =A0 =A0 =A0 .... ...1 .... .... .... .... =3D IG bit: Group address
> (multicast/broadcast)
> =A0 =A0 =A0 .... ..1. .... .... .... .... =3D LG bit: Locally administere=
d
> address (this is NOT the factory default)
> =A0 Source: Intel_89:d6:d9 (00:d0:b7:89:d6:d9)
> =A0 =A0 =A0 Address: Intel_89:d6:d9 (00:d0:b7:89:d6:d9)
> =A0 =A0 =A0 .... ...0 .... .... .... .... =3D IG bit: Individual address =
(unicast)
> =A0 =A0 =A0 .... ..0. .... .... .... .... =3D LG bit: Globally unique add=
ress
> (factory default)
> =A0 Type: IPv6 (0x86dd)
> Internet Protocol Version 6
> =A0 0110 .... =3D Version: 6
> =A0 =A0 =A0 [0110 .... =3D This field makes the filter "ip.version =3D=3D=
 6" possible: 6]
> =A0 .... 0000 0000 .... .... .... .... .... =3D Traffic class: 0x00000000
> =A0 .... .... .... 0000 0000 0000 0000 0000 =3D Flowlabel: 0x00000000
> =A0 Payload length: 1240
> =A0 Next header: IPv6 fragment (0x2c)
> =A0 Hop limit: 1
> =A0 Source: 2001:2a0:806:206:2d0:b7ff:fe89:d6d9
> (2001:2a0:806:206:2d0:b7ff:fe89:d6d9)
> =A0 Destination: ff3e::9800:600 (ff3e::9800:600)
> =A0 Fragmentation Header
> =A0 =A0 =A0 Next header: UDP (0x11)
> =A0 =A0 =A0 0000 0000 0000 0... =3D Offset: 0 (0x0000)
> =A0 =A0 =A0 .... .... .... ...1 =3D More Fragment: Yes
> =A0 =A0 =A0 Identification: 0xc31d92fa
> Data (1232 bytes)
>
> 0000 =A05d 61 46 50 05 80 b0 d6 61 61 61 61 61 61 61 61 =A0 ]aFP....aaaaa=
aaa
> =A0 Data: 5D6146500580B0D661616161616161616161616161616161...
> =A0 [Length: 1232]
>
> Frame 2 (238 bytes on wire, 238 bytes captured)
> =A0 Arrival Time: Feb 21, 2010 17:35:08.560324000
> =A0 [Time delta from previous captured frame: 0.000027000 seconds]
> =A0 [Time delta from previous displayed frame: 0.000027000 seconds]
> =A0 [Time since reference or first frame: 0.000027000 seconds]
> =A0 Frame Number: 2
> =A0 Frame Length: 238 bytes
> =A0 Capture Length: 238 bytes
> =A0 [Frame is marked: False]
> =A0 [Protocols in frame: eth:ipv6:udp:data]
> Ethernet II, Src: Intel_89:d6:d9 (00:d0:b7:89:d6:d9), Dst:
> IPv6mcast_98:00:06:00 (33:33:98:00:06:00)
> =A0 Destination: IPv6mcast_98:00:06:00 (33:33:98:00:06:00)
> =A0 =A0 =A0 Address: IPv6mcast_98:00:06:00 (33:33:98:00:06:00)
> =A0 =A0 =A0 .... ...1 .... .... .... .... =3D IG bit: Group address
> (multicast/broadcast)
> =A0 =A0 =A0 .... ..1. .... .... .... .... =3D LG bit: Locally administere=
d
> address (this is NOT the factory default)
> =A0 Source: Intel_89:d6:d9 (00:d0:b7:89:d6:d9)
> =A0 =A0 =A0 Address: Intel_89:d6:d9 (00:d0:b7:89:d6:d9)
> =A0 =A0 =A0 .... ...0 .... .... .... .... =3D IG bit: Individual address =
(unicast)
> =A0 =A0 =A0 .... ..0. .... .... .... .... =3D LG bit: Globally unique add=
ress
> (factory default)
> =A0 Type: IPv6 (0x86dd)
>
> ------
> /**********************************************************************
> udp.c (modified for MC Send Support)
> ***********************************************************************/
> #include <sys/param.h>
> #include <sys/types.h>
> #include <sys/socket.h>
> #include <sys/ioctl.h>
> #include <net/if.h>
> #include <netinet/in.h>
> #include <netdb.h>
> #include <stdlib.h>
> #include <stdio.h>
> #include <string.h>
> #include <fcntl.h>
> #include <unistd.h>
> #include <err.h>
> #include <errno.h>
> #include <ifaddrs.h>
>
> =A0// Modify send_addr to Multicast Address
> char *send_addr=3D"ff3e::9800:600";
> char *send_port=3D"18000";
>
> char *recv_addr=3D"2001:99::1";
> char *recv_port=3D"16000";
> int send_s;
> int only_out=3D0;
> int only_in=3D0;
> int out_packet_size;
> struct addrinfo *send_res;
>
> // Add for MC support
> char *out_if=3D"fxp1";
>
> main(ac,av)
> int ac;
> char **av;
> {
> =A0 int c;
>
> =A0 while ((c =3D getopt(ac, av, "s:oi")) !=3D -1) {
> =A0 =A0 =A0 switch (c) {
> =A0 =A0 =A0 case 'o':
> =A0 =A0 =A0 =A0 =A0 only_out++;
> =A0 =A0 =A0 =A0 =A0 break;
> =A0 =A0 =A0 case 'i':
> =A0 =A0 =A0 =A0 =A0 only_in++;
> =A0 =A0 =A0 =A0 =A0 break;
> =A0 =A0 =A0 case 's':
> =A0 =A0 =A0 =A0 =A0 out_packet_size =3D atoi(optarg);
> =A0 =A0 =A0 =A0 =A0 break;
> =A0 =A0 =A0 default:
> =A0 =A0 =A0 =A0 =A0 Usage();
> =A0 =A0 =A0 =A0 =A0 exit (1);
> =A0 =A0 =A0 }
> =A0 }
> =A0 if( only_in && only_out ){
> =A0 =A0 =A0 Usage();
> =A0 =A0 =A0 exit (1);
> =A0 }
>
> =A0 if( only_in =3D=3D 0 ){
> =A0 =A0 =A0 create_send_socket();
> =A0 =A0 =A0 send_v6_udp();
> =A0 =A0 =A0 exit;
> =A0 }
> =A0 recv_v6_udp();
> }
> Usage()
> {
> =A0 printf("Usage: udpgw [-o][-i][-s output_packet_size]\n");
>
> }
> create_send_socket()
> {
> =A0 struct addrinfo hints;
> =A0 int error;
> =A0 struct sockaddr_in6 *sin6;// Add for MC Support
> =A0 int ifindex;// Add for MC Support
>
>
> =A0 memset(&hints, 0, sizeof(hints));
> =A0 hints.ai_family =3D PF_UNSPEC;
> =A0 hints.ai_socktype =3D SOCK_DGRAM;
> =A0 error =3D getaddrinfo(send_addr, send_port, &hints, &send_res);
> =A0 if (error !=3D 0) errx(1, "%s", gai_strerror(error));
> =A0 send_res->ai_family =3D AF_INET6;
> =A0 send_s =3D socket(send_res->ai_family, send_res->ai_socktype,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 send_res->ai_protocol);
> =A0 if (send_s < 0) err(1, "socket");
>
> // Add for MC support
> =A0 sin6 =3D (struct sockaddr_in6 *)send_res->ai_addr;
> =A0 if(IN6_IS_ADDR_MULTICAST(&(sin6->sin6_addr))) {
> =A0 =A0 =A0 if ( (ifindex =3D if_nametoindex(out_if)) =3D=3D 0 ){
> =A0 =A0 =A0 =A0 =A0 err(1, "socket-MC");
> =A0 =A0 =A0 }
> =A0 =A0 =A0 error =3D setsockopt(send_s, IPPROTO_IPV6, IPV6_MULTICAST_IF,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0&ifindex, sizeof(ifind=
ex));
> =A0 =A0 =A0 if (error < 0){
> =A0 =A0 =A0 =A0 =A0 err(1, "socket-MC");
> =A0 =A0 =A0 }
> =A0 }
>
> }
> send_v6_udp()
> {
> =A0 int len,cc,i;
> =A0 char buf[2000];
>
> =A0 for( i=3D0; i<2000 ; i++ ){
> =A0 =A0 =A0 buf[i]=3D'a';
> =A0 }
> =A0 if( =A01501 > out_packet_size ){
> =A0 =A0 =A0 cc =3D out_packet_size ;
> =A0 }else{
> =A0 =A0 =A0 cc =3D 1500;
> =A0 }
> =A0 printf("Let's send %d length packet to %s\n",cc,send_addr);
> =A0 while(1){
> =A0 =A0 =A0 len =3D sendto(send_s, buf, cc, 0, send_res->ai_addr,
> send_res->ai_addrlen);
> =A0 =A0 =A0 sleep(1);
> =A0 }
> }
>
> recv_v6_udp()
> {
> =A0 int recv_s;
> =A0 struct addrinfo hints, *res;
> =A0 int error;
> =A0 int len,cc,ccout;
> =A0 char buf[2000];
> =A0 FILE *outfp=3Dstdout;
> =A0 int fromlen;
> =A0 struct sockaddr_in6 from6;
>
> =A0 memset(&hints, 0, sizeof(hints));
> =A0 hints.ai_family =3D PF_UNSPEC;
> =A0 hints.ai_socktype =3D SOCK_DGRAM;
> =A0 error =3D getaddrinfo(recv_addr, recv_port, &hints, &res);
> =A0 if (error !=3D 0) errx(1, "%s", gai_strerror(error));
> =A0 res->ai_family =3D AF_INET6;
> =A0 recv_s =3D socket(res->ai_family, res->ai_socktype, res->ai_protocol)=
;
> =A0 if (recv_s < 0) err(1, "socket");
>
> =A0 while(1){
> =A0 =A0 =A0 cc =3D recvfrom(recv_s, (void *)buf, sizeof(buf), 0,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (struct sockaddr *)&from6, &froml=
en);
> =A0 =A0 =A0 if (cc < 0) {
> =A0 =A0 =A0 =A0 =A0 warn("recvfrom");
> =A0 =A0 =A0 =A0 =A0 continue;
> =A0 =A0 =A0 }
> =A0 =A0 =A0 if ( only_in =3D=3D 0 ){
> =A0 =A0 =A0 =A0 =A0 len =3D sendto(send_s, buf, cc, 0, send_res->ai_addr,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0send_res->ai_addrlen);
> =A0 =A0 =A0 } else {
> =A0 =A0 =A0 =A0 =A0 if ((ccout =3D fwrite(buf, cc, 1, outfp)) < 1)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 close(recv_s);
> =A0 =A0 =A0 }
>
> =A0 }
> }
> -------------
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?90dbee151002262231v5d80a5cbua62786b5847c147b>