OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 25, 2024 1:42 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: test network send/receive with tap device ?
PostPosted: Tue Dec 20, 2016 7:38 pm 
Offline
Member
Member

Joined: Thu Apr 28, 2016 12:40 pm
Posts: 67
Hi, i m writing a rtl8139 card driver.

I am now able to send a raw packet, and capture the packet with qemu's "-net dump" command

Code:
    char * str = "aaaaaaaaaa";
    ethernet_send_packet(mac_addr, str, strlen(str), 0x0021);
qemu's dump:
0000000: d4c3 b2a1 0200 0400 0000 0000 0000 0000  ................
0000010: 0000 0100 0100 0000 66cb 5958 195c 0500  ........f.YX.\..
0000020: 1800 0000 1800 0000 1234 5678 1234 1234  .........4Vx.4.4
0000030: 5678 1234 2100 6161 6161 6161 6161 6161  Vx.4!.aaaaaaaaaa


However, the packet could not be captured by listening the tap device I created.

These are the steps I used to setup the tap device

1 add this to the /etc/network/interface
Code:
        auto br0
        iface br0 inet dhcp
        bridge_ports eth0
        bridge_stp off
        bridge_maxwait 0
        bridge_fd 0

2 sudo brctl addbr br0

3 sudo qemu-system-i386 -kernel os_kernel -net nic,model=rtl8139,macaddr=12:34:56:78:12:34 -net dump,file=traffic.pcap -netdev tap,id=br0 -device rtl8139,netdev=br0

So, when I send a packet from my os to itself(by mac address), tcpdump -i br0 did not capture anything.
Also, the rtl8139 interrupt did fire when the packet was sent, but it never fire again(it should, because the packet was sent to itself)

Did I do something wrong here?
Is the rtl8139 supposed to recognize the format of my ethernet packet and send it to the destination?


Top
 Profile  
 
 Post subject: Re: test network send/receive with tap device ?
PostPosted: Wed Dec 21, 2016 12:59 am 
Offline
Member
Member

Joined: Thu Apr 28, 2016 12:40 pm
Posts: 67
:) Never mind, i figure it out.

Code:
tcpdump -i br0 -A
06:53:16.740129 52:54:00:12:34:56 (oui Unknown) > 52:54:00:12:34:56 (oui Unknown), ethertype Unknown (0x2100), length 24:
   0x0000:  6161 6161 6161 6161 6161                 aaaaaaaaaa


For those having the same problem, see this post
http://f.osdev.org/viewtopic.php?f=1&t=30546&start=0


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: khudaydus and 236 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group