Click here to Skip to main content
15,885,782 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am very new to programming so forgive me if my question may seem obvious. I am interested in learning more about networking, though I never got a chance to take a class in it. It was suggested to me that I will learn a great deal about packets and packet generation by writing my own program to generate simple packets using the OSI model, focusing on layers 2, 3 & 4, and worry about handling only the basic important protocols like Ethernet, IPv4, IPv6, TCP, and UDP.

I found this handy reference page so I understand a bit about the different layers and their purposes. I have been looking at a lot of source such as Ostinato, Jperf, JNetPCap, etc. These all seem quite a bit more complex than what I am trying to accomplish. I really want to simply create/generate the packets which I have never really seen before.

Can anyone explain to me which components of these source examples will be useful for me to look at as examples, and what sort of scope am I looking at with my own design and implementations. I was thinking I would probably write in Java because I am more familiar with it, have about half dozen classes to complete the work and just run it as a console program. Am I off the mark here?

Also, will I need to connect to any libraries out there just to do the generating of packets? I was a bit confused about all the dependencies in some of the commercial packet generators. I keep seeing some references to libpcap, or winpcap and I don't know if these are things I need to worry about?

Just looking for some direction to get me started. Thanks, I really appreciate it!

What I have tried:

I have been google searching for information/instructions on how to generate packets. Most information I've found is about the receiving end, or using a sniffer. Maybe much of what I'm looking at is relevant, but I just don't realize it.

I have been looking at these resources:

Reference guide: Lesson 1: Open Systems Interconnection (OSI) Reference Model[^]

Ostinato: http://ostinato.org[^]

JPerf: github.com/AgilData/jperf/tree/master/src/main/java/org/jperf[^]

JNetPCap: jnetpcap.com/examples/sendpacket[^]
Posted
Updated 25-Dec-16 0:57am

Java is not the best language choice for this type of application, you would be better studying C or C++. You also need a thorough understanding of the API available within the OS that you plan to work with.
 
Share this answer
 
While it is good to understand networking by generating your own packets, you don't need to write a program to do that. My advice is to generate packets using Ostinato - the process of generating packets as a user in Ostinato is low level enough for you to understanding the networking packets, layers, headers and fields.

It would also be worthwhile to look at packet captures in Wireshark at the same time.

Ideally you should have someone with networking knowledge to be able to answer questions that you will invariably have - a book is good, but not good enough to answer questions :-)

If you would still like to write your own program, use libpcap (or WinPCAP on Windows) - start with this Sending Packets Tutorial

Good luck!

Disclosure: I'm the developer of Ostinato
 
Share this answer
 
v2
Comments
Member 12920604 27-Dec-16 20:16pm    
most of what I see uses the GUI to do the actual packet generating.I'm curious to see what goes in to the mechanics of actually generating the packet. Like if I want to generate a packet for Ethernet-IPv4-UDP, what would I need to do to set the header and get it ready to send out?
Oh also the WinPCap link does not seem to work. I have downloaded JNetPCap because it sounds like it provides some needed functions, but am still unsure.
Srivats P 27-Dec-16 23:30pm    
I've fixed the broken URL. See the example on that page for the actual mechanics of generating the packet. Not very interesting IMHO :-)
Member 12920604 29-Dec-16 1:00am    
Beautiful, I think that is exactly what I was looking for, Thanks! Also Ostinato is fantastic, I will definitely recommend it to others

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900