Re: Problem with packt transmission

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Try this small program to send a packet out and see if you are able to.
Change target_eth0, local_eth0 and "eth0" to your environment.

#define __KERNEL__ 1
#define MODULE   1

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/skbuff.h>
#include <linux/netdevice.h>

static unsigned char target_eth0[] = {0x00, 0xb0, 0xd0, 0x6f, 0xcd, 0x1b};

static unsigned char local_eth0[] = {0x00, 0xb0, 0xd0, 0x6f, 0xcd, 0x1b};

int init_module(void)
{
     unsigned char packet[98] = {0};
     int i;

     for(i = 0; i < 10; i++) {
          struct sk_buff *skb = alloc_skb(sizeof(packet), GFP_ATOMIC);
          if(!skb) {
               printk("<1> skb allocation failed\n");
           break;
         }

          memcpy(packet, target_eth0, 6);
          memcpy(packet+6, local_eth0, 6);
          packet[12] = 0x86;
          packet[13] = 0xdd;
          memcpy(skb_put(skb, sizeof(packet)), packet, sizeof(packet));

          skb->dev = (struct net_device*)dev_get_by_name("eth0");
          if(!skb->dev) {
               printk("<1>device not found\n");
               kfree_skb(skb);
               break;
          }
          printk("<1>sending packet out\n");
          dev_queue_xmit(skb);
     }

 return 0;
}

or if you can modify the driver interrupt handler, then you can ensure if
you packet is sent correctly on wire and a packet has been received from
wire. Generally interrupt handler is registered like this
request_irq(dev->irq, rtl8139_interrupt, 0, dev->name, dev);

Try to give some printk in rtl8139_interrupt (or whichever interrupt handler
you have), while you receive an interrupt for successfully transmitting
packet (similarly for receiving packet). These different interrupts are
demultiplexed from network card register when network card generates
interrupt.

Regards
Mohanlal

----- Original Message -----
From: "vijaykumar v" <vij@it.iitb.ac.in>
To: "mohanlal jangir" <mohanlal@samsung.com>; <kernelnewbies@nl.linux.org>
Sent: Thursday, May 06, 2004 2:41 PM
Subject: Re: Problem with packt transmission


> mohanlal jangir wrote:
>
> >Hi Vijay,
> >
> >Did you check if the packet is not being sent on wire or it is not being
> >received on other end?
> >
> How do I check this ???.
> I tried putting broadcast mac address on the out going frame, even then,
> no machine on the network recieves it.
> (again, the ping request is received  by all machines, but the reply by
> none.)
>
> > If you see a ping reply on some packet capturing
> >utility on sender side, it does not ensure that packet has been sent out.
> >You mentioned in your old mail that you have implemented virtual
interface
> >which uses Ethernet card to send/receive packets. In that case, you can
use
> >Ethernet card interrupt mechanism to know if a packet has been
transmitted
> >on wire and also to ensure that a packet has been received from wire.
> >
> How to do this?. Do I write another module to register for this
> interrupt number and log all events ?. Or is there is an easier way?.
>
> >Before this just make sure packet length is not less than 60 bytes :-)
> >
> The packet is a standard ping reply - the skb->data is 98 bytes long.
> So, this is not the problem.
>
> >
> >Regards
> >Mohanlal
> >
> >----- Original Message -----
> >From: "vijaykumar v" <vij@it.iitb.ac.in>
> >To: "Kishore A K" <kishoreak@myw.ltindia.com>;
<kernelnewbies@nl.linux.org>
> >Sent: Wednesday, May 05, 2004 2:11 AM
> >Subject: Re: Problem with packt transmission
> >
> >
> >
> >
> >>Hi,
> >>           The problem is not with firewall/gateway, as these machines
> >>are on the same subnet and even on these machines, the firewalls are
> >>disabled.
> >>
> >>Pinging normal interfaces will not work as this interface changes the
> >>type of the packet in the ethernet headers (so, the other interface cant
> >>identify this packet).
> >>
> >>i make a  *dev_queue_xmit(skb);*  call on the physical interface.
> >>Ethereal too shows that the packet is going to the eht0 interface.
> >>
> >>If firewall is set, will the packet be seen in the ethereal output?.
> >>
> >>And the bigger question is "when the ping-request/syn goes through the
> >>interface and gets received at the other end, why does the
> >>ping-reply/syn-ack not go through the interface?"
> >>
> >>-Vij
> >>
> >>Kishore A K wrote:
> >>
> >>
> >>
> >>>Hi Vijay,
> >>>
> >>>* check your gateway settings
> >>>
> >>>* check your firewall configration
> >>>
> >>>* try pinging normal interfaces
> >>>
> >>>or mail in some more details about this virtual interface
> >>>& all other network settings.
> >>>
> >>>-Kishore
> >>>
> >>>
> >>>
> >>--
> >>*****************************************************************
> >>         V.Vijayakumar   http://www.it.iitb.ac.in/~vij/
> >>
> >>   "Anything less than a conscious commitment to the important
> >>        is an unconscious commitment to the unimportant."
> >>*****************************************************************
> >>
> >>
> >>
> >>--
> >>Kernelnewbies: Help each other learn about the Linux kernel.
> >>Archive:       http://mail.nl.linux.org/kernelnewbies/
> >>FAQ:           http://kernelnewbies.org/faq/
> >>
> >>
> >>
> >>
>
> --
> *****************************************************************
>          V.Vijayakumar   http://www.it.iitb.ac.in/~vij/
>
>    "Anything less than a conscious commitment to the important
>         is an unconscious commitment to the unimportant."
> *****************************************************************
>
>
>


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux