Live demonstration of packets
Guys i hope you must be aware of a subject named "computer network" that you will or had learned during your course,here you must had learned about various packets such as ICMP,ARP,TCP,IP etc
But Have you ever see actual working of these packets , how these packets flow ?what if you see live in your pc the content of these packets?
I hope most of you will guys answer yes
Not a problem through ce labs,you will not only get deeper knowledge of these packets but also get a practical knowledge
All this need some time of yours and a little bit knowledge of programming in java.
So i will begin with TCP Packet
once you get an idea of basics about this then we will proceed with live demonstration of this packet
But Have you ever see actual working of these packets , how these packets flow ?what if you see live in your pc the content of these packets?
I hope most of you will guys answer yes
Not a problem through ce labs,you will not only get deeper knowledge of these packets but also get a practical knowledge
All this need some time of yours and a little bit knowledge of programming in java.
So i will begin with TCP Packet
once you get an idea of basics about this then we will proceed with live demonstration of this packet
Replies
-
VoltaireGo ahead. Sounds interesting
-
sushant005This semester i am having "Computer Network" so this might be very interesting to see the live flow of packets.Good work goyal..before showing the live demonstration please give some ideas about the various packets......
-
mayjuneYou can do this also with a simulator like packet tracer. But it'll be good, to see it through code. thanks a lot. waiting for it...
-
Manish GoyalHere is My first post
Note:-If anyone doesn't agree with me at any point he/she can correct me and Please no more thanks and praise in this thread as this can distract anyone
so Let us begin with one of the basic definiton of computer network
A computer network is just a interconnection of autonomous computers/devices or in simple definition a collection of devices connected by communication channels
It is used to facilitate communication and transfer of data from one location to another
For any kind of communication through computer network
WE require five elements
1:-Sender
2:-Receiver
3:-medium
4:- Protocol
5:-Message or data
Here our main concern is our precious data and protocol.
Now the data is transmitted in the form of packets,these packets may also be referred to as cell,segment,block
It has primarily two parts
1:-Header-It contains all the necessary information required to transfer data such as port no,address etc
2:- Data:-Next part is our data that we want to communicate
Now these packets can be of any type may be TCPPacket,IPPacket ,ICMP,ARP etc
So these are some basics of computer network,tomorrow we will start with TCPPackets
PS:-If i have missed anything then feel free to add and correct me -
Manish GoyalFor demonstration of packets ,
Please install following
1:-Jpcap ,I would recommend to use window platform for this
#-Link-Snipped-#
2:- winpcap from here
WinPcap - Home
WinPcap is the industry-standard tool for link-layer network access in Windows environments: it allows applications to capture and transmit network packets bypassing the protocol stack, and has additional useful features, including kernel-level packet filtering, a network statistics engine and support for remote packet capture.
3:-Java run time environment -
mayjuneDone Boss 😀
-
Manish Goyalcool
Just for testing whether everything is working fine or not
Try to execute this program ,it will display information related to network interface card available in your pc
import jpcap.*; class Network { public static void main(String args[]) { int i; try { NetworkInterface[] devices = JpcapCaptor.getDeviceList(); //for each network interface for (i = 0; i < devices.length; i++) { System.out.println(i+": "+devices[i].name + "(" + devices[i].description+")"+devices[i].loopback); } } catch(Exception e) { System.out.println(e.getMessage()); } } }
Note :-It is important to know from you Guys whether you want theory first or practical or simultaneously both
Everything should be in such a way that everyone would learn what we are learning here? -
sushant005I think simultaneously both theory and practical....it keeps update with theory and its practical as well....
-
mayjuneYup. First theory, and maybe some live example of us using it, for example ICMP packet is used whenever we ping or Traceroute etc and then the practical aspect of it.
-
vik001indWireshark is the best packet analysis tool, too commonly used in security field. linux & windows versions are available.
-
Manish GoyalSorry Guys for delay in reply
I was busy with some work
so let us try our first program that will show everything related to TCPPackets
First execute this program then analyze its output and try to co-relate the output with your knowledge
import jpcap.*; import jpcap.packet.*; import java.io.*; import jpcap.packet.TCPPacket.*; import java.io.*; class Network implements PacketReceiver { String sp=null; String dp=null; String window=null; String sequence=null; String acknowledge=null; FileWriter ff=null; String da=null; public void receivePacket(Packet pt) { try { if(pt instanceof TCPPacket) { TCPPacket tp=(TCPPacket)pt; ff=new FileWriter("da.txt",true); sp=new Integer(tp.src_port).toString(); dp=new Integer(tp.dst_port).toString(); window=new Integer(tp.window).toString(); sequence=new Long(tp.sequence).toString(); acknowledge=new Long(tp.ack_num).toString(); byte[]dat=tp.data; da=new String(dat); ff.write("\r\n Source port is :-"+sp); ff.write("\r\n Desination port is:-"+dp); ff.write("\r\n Sequence no is:-"+sequence); ff.write("\r\n Acknowledgement no is:-"+acknowledge); ff.write("\r\n Status of rsv1 flag is:-"+tp.rsv1); ff.write("\r\n Status of rsv2 flag is:-"+tp.rsv2); ff.write("\r\n Status of Syn flag is:-"+tp.syn); ff.write("\r\n Status of Urg flag is:-"+tp.urg); ff.write("\r\n Status of Fin flag is:-"+tp.fin); ff.write("\r\n Data :-"+da); ff.write("\r\n"); ff.write("\r\n"); ff.close(); } } catch(Exception e) { System.out.println(e.getMessage()); } } public static void main(String args[])throws IOException { int i; try { NetworkInterface[] devices = JpcapCaptor.getDeviceList(); //for each network interface for (i = 0; i < devices.length; i++) { //print out its name and description System.out.println(i+": "+devices[i].name + "(" + devices[i].description+")"+devices[i].loopback); //print out its datalink name and description System.out.println(" datalink: "+devices[i].datalink_name + "(" + devices[i].datalink_description+")"); //print out its MAC address System.out.print(" MAC address:"); for (byte b : devices[i].mac_address) System.out.print(Integer.toHexString(b&0xff) + ":"); System.out.println(); //print out its IP address, subnet mask and broadcast address for (NetworkInterfaceAddress a : devices[i].addresses) System.out.println(" address:"+a.address + " " + a.subnet + " "+ a.broadcast); } JpcapCaptor captor=JpcapCaptor.openDevice(devices[0], 65535, true, 20); captor.loopPacket(-1,new Network()); captor.close(); } catch(Exception e) { System.out.println(e.getMessage()); } } }
create a file named da.txt at the same location where program resides .then execute this program
Now open web browser and open any web page
after opening web page ,open "da.txt"
you will see the info about TCP packets that we have captured -
Morningdot HabluHello goyal,
Firstly thanks for sharing code with us.
I just try to compile your code it show error like this.
Network.java:1: package jpcap does not exist
import jpcap.*;
^
Network.java:2: package jpcap.packet does not exist
import jpcap.packet.*;
^
Network.java:5: package jpcap.packet.TCPPacket does not exist
import jpcap.packet.TCPPacket.*;
^
Network.java:7: cannot find symbol
symbol: class PacketReceiver
class Network implements PacketReceiver
^
Network.java:17: cannot find symbol
symbol : class Packet
location: class Network
public void receivePacket(Packet pt)
^
Network.java:21: cannot find symbol
symbol : class TCPPacket
location: class Network
if(pt instanceof TCPPacket)
^
Network.java:23: cannot find symbol
symbol : class TCPPacket
location: class Network
TCPPacket tp=(TCPPacket)pt;
^
Network.java:23: cannot find symbol
symbol : class TCPPacket
location: class Network
TCPPacket tp=(TCPPacket)pt;
^
Network.java:60: cannot find symbol
symbol : class NetworkInterface
location: class Network
NetworkInterface[] devices = JpcapCaptor.getDeviceList();
^
Network.java:60: cannot find symbol
symbol : variable JpcapCaptor
location: class Network
NetworkInterface[] devices = JpcapCaptor.getDeviceList();
^
Network.java:78: cannot find symbol
symbol : class NetworkInterfaceAddress
location: class Network
for (NetworkInterfaceAddress a : devices.addresses)
^
Network.java:81: cannot find symbol
symbol : class JpcapCaptor
location: class Network
JpcapCaptor captor=JpcapCaptor.openDevice(devices[0], 65535, true, 20);
^
Network.java:81: cannot find symbol
symbol : variable JpcapCaptor
location: class Network
JpcapCaptor captor=JpcapCaptor.openDevice(devices[0], 65535, true, 20);
^
13 errors
what i have to do to compile this code without any error.
I am using using ubuntu 10.04 LTS. -
Manish Goyalhave you installed Jpcap?
If yes then you have to set environment for this ,I hope you had set environment for java also while installing it in ubuntu
in same way you have set environment for this
2:-Here again Once program will compile ,I don't think you will be able to capture packets
since winpcap will not work in ubuntu which is must requirement for capturing packets
i think you have to install libpcap(Not sure about spellings) -
Manish GoyalSorry Guys for such a late response back on this thread
So have you tried this program ? If yes do you got any idea ? -
optimystixi agree with vik. the simplest way to check info about the packets you send and receive is to use Wireshark. It is a popular tool used to study the network by amateurs as well as professionals.
just download (around 17mb) and install the software, select the interface you want to capture which is usually your ethernet card, and select start. You can see live packets being captured and click on them to see a detailed list of information that they carry.
you will be surprised to know that these can often show you the login ids and passwords or any info that you type online. this tool is often used for sniffing purposes . -
Manish GoyalYeah i agree with you opti but i think there is more fun in creating our own tools .Even we can remove limitations of wireshark as it doesn't work for usb modems and atm network
You are reading an archived discussion.
Related Posts
Dear All,
A basic doubt which I came across is regarding the mail storage's of common mailboxes.
gmail or yahoomails are giving a greater scope of GB's of storage to...
hello guys..
i am btech fresher(2010 passout),computer science. i am from small place n there in no placement in our college this time.now i have option of walkins. so i...
Hello guy's,
Look at this coding in java.
This will run.
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Mouseapp extends Applet implements MouseListener,MouseMotionListener
{
int x,y;
String msg="";
public...
Hello friend's,
I think most of our CEan's are new in ubuntu like environment.
So a good way to resolved this problem is share your tips and tricks with us....
Hello friend's,
I am thinking about designing a website in java.
I just started to design home page for it.
Any one interested in doing this.