c - RAW-Sockets should ignore MTU -
i have small problem raw-socket. have capture packets in network modify them. have add special data, timestamps. works fine, have problem witht mtu (linux).
if of application of upper layers generates packets close mtu, can not add data. decide downsize mtu of systems. got smaller packets , possible ad data. when try sendout packets raw-socket, not working.
i found (by google, in older stackoverflow threads , in linux manpages) option ip_mtu_discover help. when use setsockopt, nothing changes.
if ((s = socket(af_packet, sock_raw, eth_p_all)) < 0) { printf("error: not open socket\n"); return -1; } char socket_mtu = ip_pmtudisc_dont; setsockopt(s,ipproto_ip,ip_mtu_discover,socket_mtu, 1);
maybe important. downsizing of mtu done, because when add own data, resulting packet not greater 1500 + eth-header. problem is, make raw-sockets ignore local mtu of linux-system.
- is ip_mtu_discover right way ignore value set in mtu?
- is ip_mtu_discover realy usable raw-socket?
- are there other ways decrement segement size of protocols on layer 3 , higher?
i read, sendto() returns emsgsize (=90) when size big. have done following test.
int k = sendto(s, frame.buffer, frame_len, 0, (struct sockaddr*)&saddrll, sizeof(saddrll)); printf("k:%i\n", k);
after calling sendto() "k" contains "-1". if depends on packet size, shouldn't "90"??
when set size of packet send smaller mtu, works fine.... little bit strange.
any nice :-)
kind regards, andreas
ok. found solution change mtu c program.
buffer.ifr_mtu = 1500; if(!ioctl(s, siocsifmtu, &buffer)) { printf("mtu changed\n"); }
for first moment works. it's workarround, it's not realy clean. problem coul be, if application sending packet in moment resize mtu, packet big. better ideas?
kind regards, andreas
Comments
Post a Comment