1. 程式人生 > >Warning: Unable to send packet: Error with PF_PACKET send() [11]: Message too long (errno = 90)

Warning: Unable to send packet: Error with PF_PACKET send() [11]: Message too long (errno = 90)

今天在使用tcpreplay重放流量時,發現有的資料包沒有傳送成功:

Warning: Unable to send packet: Error with PF_PACKET send() [215]: Message too long (errno = 90)
Warning: Unable to send packet: Error with PF_PACKET send() [216]: Message too long (errno = 90)
Warning: Unable to send packet: Error with PF_PACKET send() [218]: Message too long (errno = 90)
Warning: Unable to send packet: Error with PF_PACKET send() [219]: Message too long (errno = 90)
Warning: Unable to send packet: Error with PF_PACKET send() [234]: Message too long (errno = 90)
Actual: 459 packets (386911 bytes) sent in 0.03 seconds.                Rated: 12897033.0 bps, 98.40 Mbps, 15300.00 pps
Statistics for network device: eth0
        Attempted packets:         235
        Successful packets:        217
        Failed packets:            18
Retried packets (ENOBUFS): 0 Retried packets (EAGAIN): 0 Statistics for network device: eth0 Attempted packets: 224 Successful packets: 224 Failed packets: 0 Retried packets (ENOBUFS): 0 Retried packets (EAGAIN): 0
從錯誤提示看出,應該是資料包太大了。我查看了一下發送的資料包:
10:20:39.019199 IP xyw-Eliot.local.http > xyw-Eliot.local.53720: Flags [.], seq 323602:326522, ack 1978, win 31, length 2920
10:20:39.019298 IP xyw-Eliot.local.53720 > xyw-Eliot.local.http: Flags [.], ack 326522, win 543, length 0
10:20:39.047511 IP xyw-Eliot.local.http > xyw-Eliot.local.53720: Flags [.], seq 326522:329442, ack 1978, win 31, length 2920
10:20:39.047559 IP xyw-Eliot.local.53720 > xyw-Eliot.local.http: Flags [.], ack 329442, win 543, length 0
10:20:39.047665 IP xyw-Eliot.local.http > xyw-Eliot.local.53720: Flags [.], seq 329442:330902, ack 1978, win 31, length 1460
10:20:39.075783 IP xyw-Eliot.local.http > xyw-Eliot.local.53720: Flags [.], seq 330902:333822, ack 1978, win 31, length 2920
10:20:39.075824 IP xyw-Eliot.local.53720 > xyw-Eliot.local.http: Flags [.], ack 333822, win 543, length 0
10:20:39.104001 IP xyw-Eliot.local.http > xyw-Eliot.local.53720: Flags [.], seq 333822:336742, ack 1978, win 31, length 2920
10:20:39.104049 IP xyw-Eliot.local.53720 > xyw-Eliot.local.http: Flags [.], ack 336742, win 543, length 0
10:20:39.104322 IP xyw-Eliot.local.http > xyw-Eliot.local.53720: Flags [.], seq 336742:338202, ack 1978, win 31, length 1460
10:20:39.132219 IP xyw-Eliot.local.http > xyw-Eliot.local.53720: Flags [.], seq 338202:339662, ack 1978, win 31, length 1460
發現數據包長度已經超過1500(MTU預設為1500),所以問題的解決方法是修改系統的MTU值。

先說一下我的系統環境:ubuntu 12.04

linux系統修改MTU的方法比較簡單,一個命令即可:

sudo ifconfig eth0 mtu 3000
這是將網絡卡eth0的MTU值設定為3000,這樣再重新放包,發現數據包被全部發送:
sending out eth0 eth0
processing file: tcp_rewrite.pcap
Actual: 459 packets (386911 bytes) sent in 0.04 seconds.                Rated: 9672775.0 bps, 73.80 Mbps, 11475.00 pps
Statistics for network device: eth0
        Attempted packets:         235
        Successful packets:        235
        Failed packets:            0
        Retried packets (ENOBUFS): 0
        Retried packets (EAGAIN):  0
Statistics for network device: eth0
        Attempted packets:         224
        Successful packets:        224
        Failed packets:            0
        Retried packets (ENOBUFS): 0
        Retried packets (EAGAIN):  0
本文為Eliot原創,轉載請註明出處:http://blog.csdn.net/xyw_blog/article/details/10741919