LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 07-21-2014, 10:03 PM   #1
zerop
Member
 
Registered: Jul 2014
Posts: 65

Rep: Reputation: Disabled
Question how to set mmap for better performance of raw socket


req.tp_block_size=96;
req.tp_frame_size=96;
req.tp_block_nr=2;
req.tp_frame_nr=2;
if ( (setsockopt(fd,
SOL_PACKET,
PACKET_RX_RING,
(char *)&req,
sizeof(req))) != 0 ) {
perror("setsockopt()");
close(fd);
return 1;
};
/* mmap() the sucker */
map=mmap(NULL,
req.tp_block_size * req.tp_block_nr,
PROT_READ|PROT_WRITE|PROT_EXEC, MAP_SHARED, fd, 0);


1. if minimum size of frame is 64, is the final 4 octet. crc. set by operating system?
if i set size of frame as 60 without crc place, can it be successfully transfer among cisco router and switch?

2. can above minimum setting work for setting allocation of the circular buffer (ring )option: PACKET_TX_RING

Example
tp_block_size= 4096 // Minimal size of contiguous block
tp_frame_size= 2048 // Size of frame
tp_block_nr= 4// Number of blocks
tp_frame_nr= 8// Total number of frames, redundant

4096/2048 = 2, 2*4 = 8

what is the size of tpacket_hdr? is it 32 bytes
size of tpacket_hdr + frame with size 64

what is minimum tp_frame_size? is it = 32+64 = 96

tp_block_size= 96
tp_frame_size= 96
tp_block_nr = 2
tp_frame_nr = 2

96/96 = 1, 1*2 = 2

if number of block is less, can it have better performance? or more blocks is better?

if every frame is just 64, and send immediately when have msg
ret = sendto(sock, buffer, pkt_index->pktlen, MSG_DONTWAIT,
(struct sockaddr *)(void *) to, sizeof(struct sockaddr_in));

3. (bonus not needed to answer) how to see the difference between applied above and not applied?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
force kernel 2.6.33.3 to send the packet with MF flag set on through raw socket samiran.linux Linux - Networking 3 08-02-2013 02:08 PM
mmap performance on SMP rick_rold Programming 3 03-08-2011 11:57 AM
[c] Raw socket, set source ip to 0.0.0.0.0 darell Programming 5 03-19-2009 07:35 PM
AF_LOCAL domain socket versus AF_INET socket performance zzaappp Linux - General 0 06-19-2008 07:50 AM
can I use mmap with raw sockets? kanth Programming 2 02-28-2004 12:42 PM

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

All times are GMT -5. The time now is 11:05 AM.

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