Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Net::RawIP question

by mark200 (Novice)
on Aug 16, 2018 at 10:45 UTC ( [id://1220415]=perlquestion: print w/replies, xml ) Need Help??

mark200 has asked for the wisdom of the Perl Monks concerning the following question:

hi, Can you give me example how can i manipulate ethernet header using Net::RawIP module? thanks

Replies are listed 'Best First'.
Re: Net::RawIP question
by thanos1983 (Parson) on Aug 16, 2018 at 12:51 UTC

    Hello mark200,

    Welcome to the Monastery. From the module Net::RawIP documentation:

    Please look at the examples in the examples/ folder of the distribution.

    Follow the link examples

    Hope this helps, BR.

    Seeking for Perl wisdom...on the process of learning...not there...yet!
      Thanks, helped but the problem is that when i try send the ethernet packet using ethsend function it never sent. I followed same as in examples but not helped. If you can give example of simply creating ethernet packet then send it, this will be helpful.
Re: Net::RawIP question
by anonymized user 468275 (Curate) on Aug 16, 2018 at 12:45 UTC
    In the initialisation:
    Net::RawIP->new({ ARGPROTO => {PROTOKEY => PROTOVALUE,...} ip => {IPKEY => IPVALUE,...}, });
    the ip key should point to a hash of the header data. Probably NetPacket::IP will get you the data to assemble into the hash. I see the module promises to help you manipulate the header, but "manipulate" seems vague in the context of the module you refer to. Generally, NetPacket::TCP has what I would call a manipulation toolkit for your packets.

    One world, one people

      This:
      $n->send; $n->ethnew("eth0"); $n->ethset(source => 'my.target.lan', dest =>'my.target.lan'); $n->ethsend;
      the packet is first send then setting the ethernet header? how? can you explain me this?
        The documentation says:

        ethset

        is a method for set an ethernet parameters in the current object. The given parameters must look like parameters for the ethnew without a $device.

        So for your manipulation, it expects the new header to be given in the ethset call as ip => { header keys and values }

        update: you might also want to check whether your calls are returning a true value i.e.

        $n->methodname(parms) or die "Net::RawIP->methodname failed";

        One world, one people

      This:
      $n->send; $n->ethnew("eth0"); $n->ethset(source => 'my.target.lan', dest =>'my.target.lan'); $n->ethsend;
      the packet is first send then setting the ethernet header? how? can you explain me this?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1220415]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-25 08:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found