LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 06-17-2010, 06:45 AM   #1
muruga86
LQ Newbie
 
Registered: Nov 2006
Posts: 1

Rep: Reputation: 0
Raw socket - max frame length supported by sendto call for tag frames


Hi,

Can some one clarify me regarding maximum frame length supported by raw socket sendto call with 3 vlan tags.

I use a PF raw socket to send out triple tag packet from application module to kernel module. But excluding triple tag length, only frame length of 1504 bytes were transmitted successfully by the socket. As per my understanding, socket tx sendto call should support max of 1518 for untag frames and 1526 for tagged frames.

Please correct me if iam wrong. Would there be any way i can increase the tx frame size of tagged frames to 1526 in socket sendto call.

Thanks in advance
Murugan


Code snippet:

const int ETH_PROT_RAW_SOCK_FILTER = 0x8100
const int maxFrameSize = 1526;
const int maxUntagSize = 1518;
const char InterfaceName[] = "eth2.4090";

unsigned char SockRxBuffer[maxFrameSize];
unsigned char SockTxBuff[maxFrameSize];

//create socket interface
RawSockID = socket(PF_PACKET, SOCK_RAW, htons(ETH_PROT_RAW_SOCK_FILTER));

//Get the interface number for a given interface name
if( ioctl(RawSockID, SIOCGIFINDEX, &InterfaceRequest) == -1)

//Now use the Interface ID to bind the raw socket to a specific device
memset(&RawSockAddrInfo, 0, sizeof(struct sockaddr_ll));
RawSockAddrInfo.sll_family = AF_PACKET;
RawSockAddrInfo.sll_ifindex = InterfaceRequest.ifr_ifindex;
RawSockAddrInfo.sll_protocol = htons(ETH_PROT_RAW_SOCK_FILTER);
if (bind(RawSockID, (struct sockaddr *) &RawSockAddrInfo, sizeof(struct sockaddr_ll)) < 0)

//Set the socket to non-blocking
if(fcntl(RawSockID, F_SETFL,O_NONBLOCK) == -1)

//Finally init the last variable to be used by the sendto()/recvfrom() socket APIs
RawSockAddrInfoLength = sizeof(struct sockaddr_ll);

//rcv single tag frames
if((NumRxBytes = recvfrom(RawSockID,
SockRxBuffer,
maxFrameSize, 0,
(struct sockaddr *) &RawSockAddrInfo,
(socklen_t *)&RawSockAddrInfoLength) )== -1 )


//Tx the packet - with tripple tag - add 4090/tag1/tag2, max frame size supported 1516(with all 3 tags)
if(sendto(RawSockID,
SockTxBuff,
NumTxBytes, 0,
(struct sockaddr *) &RawSockAddrInfo,
RawSockAddrInfoLength) == -1)

---------------------------------------------------------------------------------------

Last edited by muruga86; 06-17-2010 at 07:28 AM. Reason: update
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
RAW receive Socket also delivers sent frames baddad Programming 22 11-27-2013 12:44 PM
id3 tag 'comment' max length cast in stone? larryfroot Linux - Desktop 2 07-03-2008 09:58 AM
Raw socket creation error (IPPROTO_IP not supported) linfreak Programming 1 06-17-2004 12:37 PM
Raw socket creation error (IPPROTO_IP not supported) linfreak Linux - Networking 1 06-17-2004 10:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration