# Create custom network packet

**URL:** <https://www.ruby-forum.com/t/create-custom-network-packet/117124>\
**Category:** Ruby\
**Created:** [October 13, 2007, 9:46am UTC](https://www.ruby-forum.com/t/create-custom-network-packet/117124 "2007-10-13T09:46:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![flnative](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/5daacb/32.png) [@flnative](https://www.ruby-forum.com/u/flnative)\
**Post date:** [October 13, 2007, 9:46am UTC](https://www.ruby-forum.com/t/create-custom-network-packet/117124/1 "2007-10-13T09:46:57Z")

</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…

---

<div class="post-metadata">

**Author:** ![flnative](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/5daacb/32.png) [@flnative](https://www.ruby-forum.com/u/flnative)\
**Post date:** [October 15, 2007, 8:33am UTC](https://www.ruby-forum.com/t/create-custom-network-packet/117124/2 "2007-10-15T08:33:45Z")

</div>

Ari B. 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…

---

<div class="post-metadata">

**Author:** ![flnative](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/5daacb/32.png) [@flnative](https://www.ruby-forum.com/u/flnative)\
**Post date:** [October 25, 2007, 3:24pm UTC](https://www.ruby-forum.com/t/create-custom-network-packet/117124/3 "2007-10-25T15:24:47Z")

</div>

K. R. wrote:

> Ari B. 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…

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…

---

<div class="post-metadata">

**Author:** ![flnative](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/5daacb/32.png) [@flnative](https://www.ruby-forum.com/u/flnative)\
**Post date:** [October 13, 2007, 5:15pm UTC](https://www.ruby-forum.com/t/create-custom-network-packet/117124/4 "2007-10-13T17:15:17Z")

</div>

On Oct 13, 2007, at 3:46 AM, M. R. wrote:

> (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…

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.
