# Create custom network packet

**URL:** <https://rubytalk.org/t/create-custom-network-packet/41354>\
**Category:** ruby-talk\
**Created:** [13 October 2007 07:46 UTC](https://rubytalk.org/t/create-custom-network-packet/41354 "2007-10-13T07:46:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![M\_R](https://avatars.discourse-cdn.com/v4/letter/m/bcef8e/32.png) [@M\_R](https://rubytalk.org/u/M_R)\
**Post date:** [13 October 2007 07:46 UTC](https://rubytalk.org/t/create-custom-network-packet/41354/1 "2007-10-13T07:46:59Z")

</div>

hi @all

I would like to create a custom network packet with:  
layer 2: ethernet  
layer 3: ip

At first, I want to create a ip packet and set some header fields (for  
example the TOS-byte) by myself. After that, I take the created  
ip-packet and nest it into a new ethernet packet, which I create too.  
Also, I would like to change the header fields in the ethernet packet  
(e.g. cos-field). Over a raw socket, I'll send the packet to a other  
station in the network.

Has anyone a solution or any experience? thanks for help...

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Ari\_Brown](https://avatars.discourse-cdn.com/v4/letter/a/48db29/32.png) [@Ari\_Brown](https://rubytalk.org/u/Ari_Brown)\
**Post date:** [13 October 2007 15:14 UTC](https://rubytalk.org/t/create-custom-network-packet/41354/2 "2007-10-13T15:14:34Z")

</div>

check out rubyforger. NOTICE THE EXTRA R

It's a GREAT library for \*nix, and is nicely extracted.

[http://rubyforger.rubyforge.org/](http://rubyforger.rubyforge.org/)

Ari  
--------------------------------------------|  
If you're not living on the edge,  
then you're just wasting space.

> **···**
>
> On Oct 13, 2007, at 3:46 AM, M. R. wrote:
> 
> > hi @all
> > 
> > I would like to create a custom network packet with:  
> > layer 2: ethernet  
> > layer 3: ip
> > 
> > At first, I want to create a ip packet and set some header fields (for  
> > example the TOS-byte) by myself. After that, I take the created  
> > ip-packet and nest it into a new ethernet packet, which I create too.  
> > Also, I would like to change the header fields in the ethernet packet  
> > (e.g. cos-field). Over a raw socket, I'll send the packet to a other  
> > station in the network.
> > 
> > Has anyone a solution or any experience? thanks for help...

---

<div class="post-metadata">

**Author:** ![M\_R](https://avatars.discourse-cdn.com/v4/letter/m/bcef8e/32.png) [@M\_R](https://rubytalk.org/u/M_R)\
**Post date:** [15 October 2007 06:33 UTC](https://rubytalk.org/t/create-custom-network-packet/41354/3 "2007-10-15T06:33:45Z")

</div>

Ari Brown wrote:

> **···**
>
> > On Oct 13, 2007, at 3:46 AM, M. R. wrote:  
> > [http://rubyforger.rubyforge.org/](http://rubyforger.rubyforge.org/)
> 
> Hi Ari  
> Do you known, how can I install the libnet4r?  
> thanks...  
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![K\_R](https://avatars.discourse-cdn.com/v4/letter/k/dbc845/32.png) [@K\_R](https://rubytalk.org/u/K_R)\
**Post date:** [25 October 2007 13:24 UTC](https://rubytalk.org/t/create-custom-network-packet/41354/4 "2007-10-25T13:24:46Z")

</div>

K. R. wrote:

> Ari Brown wrote:
> 
> > [http://rubyforger.rubyforge.org/](http://rubyforger.rubyforge.org/)
> 
> Hi Ari  
> Do you known, how can I install the libnet4r?  
> thanks...

Yes, you can use make to compile and install this library...  
When the installation is completed, you can compile and install the  
rnet.c File. This file creates the libnet4r.so. The library libnet4r.so  
is a pseudo-bridge, that translate the ruby-used methods to contact the  
functions of the C-Library. So you can use the features of libnet in  
ruby...

> **···**
>
> > > On Oct 13, 2007, at 3:46 AM, M. R. wrote:
> 
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
