tapデバイス間の生データ転送
うまくいった。一昨日のtapブリッジプログラムを起動した状態でtap0から送信したデータをtap1でダンプすることが出来た。
- 送信側
$~/devel/tun# ./send fd= 3 ifindex = 5 send 128 bytes
- 受信側(sendより先に起動しておく)
$~/devel/tun# ./recv fd= 3 ifindex = 6 Now receiving.. ret= 128 Received 128 bytes 0000 : 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f : ................ 0010 : 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f : ................ 0020 : 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f : ................ 0030 : 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f : 0123456789...... 0040 : 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f : .ABCDEFGHIJKLMNO 0050 : 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f : PQRSTUVWXYZ..... 0060 : 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f : .abcdefghijklmno 0070 : 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f : pqrstuvwxyz.....
参考にしたURLは以下。非常に役に立った。
I've succeeded in transmitting raw data from tap0 to tap1. I've learned from the above links about how to change network interface in sending or receiving data. In sending, sendto() is needed and in receiving,we need to call bind() to indicate an interface. And I've leaned how to erase data which exists before starting program in the receive buffer. They're convenient informations for me.