Results 1 to 6 of 6
Hi,
I wrote an application that receives packets on one interface and sends them to another interface after it added a vlan header. Both the sending and the receiving is ...
- 08-19-2010 #1Just Joined!
- Join Date
- May 2010
- Posts
- 9
Sending frames of size 1518 using raw sockets
Hi,
I wrote an application that receives packets on one interface and sends them to another interface after it added a vlan header. Both the sending and the receiving is done using raw sockets.
Everything seems to work fine until I get TCP packets that are of size 1514 (MTU). Once I add a vlan header to the packet, its size becomes 1518 and when I try to send it I get the returned value -1 and errno=90 (message too long).
I tried to change the MTU of the NIC to a value that is bigger than 1500 but that fails.
If I create a bridge using brctl and vconfig between the NICs I can see that my NIC does sends packets of size 1518.
What do I need to in order to make my NIC to send packets of size 1518?
Thanks in advance,
Mickey
- 08-20-2010 #2Just Joined!
- Join Date
- Jul 2010
- Posts
- 53
you opened the socket raw (SOCK_RAW)? you receive on a TCP stream (SOCK_STREAM)? then are sending out again on TCP? or UDP?
then are getting EMSGSIZE from sendmsg() ?
when i'd needed to do something similar - was using udp - and istr that had to rewrite settings to one of the file in /proc/sys/net - will poke around and see if i still have that somewhere...
- 08-20-2010 #3Just Joined!
- Join Date
- Jul 2010
- Posts
- 53
should be one of the conf. settings you can find with this:
Code:sysctl -a | grep -i mtu
- 08-20-2010 #4Just Joined!
- Join Date
- Jul 2010
- Posts
- 53
i suppose you know 1518 is actually not available in the standard ethernet packet... so presumably you have gigE and jumbo packets available to where you are sending this repeater?
- 08-20-2010 #5Just Joined!
- Join Date
- May 2010
- Posts
- 9
Thx for answering.
The socket I opened is SOCK_RAW. I receive on a raw socket and send on another one.
Both NICs are 100 Mb ethernet interfaces. I didn't change any configuration regarding the interfaces. I also wasn't sure if my NIC supports frames of size 1518, but when I setup a bridge and config a vlan (using brctl and vconfig) between them I see that my NIC is able to send such frames of size 1518. For some reason when my application does it, it fails.
I will try what you said regarding one of the conf. settings.
- 08-29-2010 #6Just Joined!
- Join Date
- May 2010
- Posts
- 9
Hi,
If it helps, this is the creation code of my socket:
Code:int CreateRawSocket (void) { int iSockHandle = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); if (iSockHandle == -1) { return -1; } struct sockaddr_ll sll; struct ifreq ifr; bzero(&sll, sizeof(sll)); bzero(&ifr, sizeof(ifr)); /* First Get the Interface Index */ strncpy((char *)ifr.ifr_name, "eth2", IFNAMSIZ); if ((ioctl (iSockHandle, SIOCGIFINDEX, &ifr)) == -1) { return -1; } // add the promiscuous mode struct packet_mreq mr; memset (&mr, 0, sizeof(mr)); mr.mr_ifindex = ifr.ifr_ifindex; mr.mr_type = PACKET_MR_PROMISC; if (setsockopt (iSockHandle, SOL_PACKET, PACKET_ADD_MEMBERSHIP, (char *)&mr, sizeof(mr)) < 0) { perror("Failed to add the promiscuous mode"); return (-1); } /* Bind our raw socket to this interface */ sll.sll_family = AF_PACKET; sll.sll_ifindex = ifr.ifr_ifindex; sll.sll_protocol = htons (ETH_P_ALL); if ((bind (iSockHandle, (struct sockaddr *)&sll, sizeof(sll)))== -1) { return -1; } return iSockHandle; }


Reply With Quote