Is there anybody that have jpcap ( rawsocket ) examples Thanks

I'am an Italian programmers, sorry i speak a little English.
I downloaded from http://www.goto.info.waseda.ac.jp/~fujii/jpcap/index.html , jpcap pakage.
By it i can read and send packet/rawsocket.
When i capturing packet it's all ok.
When i want send packet i have an exception: java.io.IOException: sendto error
probably i have not setting any field.
Is there anybody that can help-me.
Is there anybody that have some examples that explain how to send packet ( ICMP,TCP,UDP )
In the pakage documentation i dont find nothing.
In the pakage documentation there is only a tcpdump examples.
Thanks you ulisse640
p.s. Below there is the code that give the error.
package progetto10;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import jpcap.*;
public class Frame1 extends JFrame {
JPanel contentPane;
JButton jButton1 = new JButton();
String device = "\\Device\\Packet_{6B0E8DE3-8F46-41E3-B3BD-673C59BB0028}";
BorderLayout borderLayout1 = new BorderLayout();
/**Construct the frame*/
public Frame1() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try
jbInit();
catch(Exception e)
e.printStackTrace();
/**Component initialization*/
private void jbInit() throws Exception {
//setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(borderLayout1);
this.setSize(new Dimension(400, 300));
this.setTitle("Frame Title");
jButton1.setText("Bottone");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton1_actionPerformed(e);
contentPane.add(jButton1, BorderLayout.CENTER);
/**Overridden so we can exit when window is closed*/
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
void jButton1_actionPerformed(ActionEvent e) {
try
Jpcap jpcap = null;
IPAddress.setAddressConvert(true);
String[] devices = Jpcap.getDeviceList();
for( int i=0; i<devices.length; i++ )
System.out.println( devices[i] );
jpcap = new Jpcap(device,1500,true ,200);
UDPPacket pack = createUDP(); //TCPPacket pack = createTCP();
System.out.println("");
System.out.println("openRawSocket");
jpcap.openRawSocket();
jpcap.sendPacket( pack );
jpcap.close();
catch(Exception ex)
ex.printStackTrace();
public EthernetPacket createEthernetPacket() throws Exception {
EthernetPacket ep = new EthernetPacket();
ep.frametype = 2048;
String strdst = new String("00:50:ba:49:6c:9b");
ep.dst_mac = strdst.getBytes();
String strsrc = new String("00:00:e2:44:b8:dd");
ep.src_mac = strsrc.getBytes();
return ep;
public UDPPacket createUDP() throws Exception {
UDPPacket up = new UDPPacket( 80,333 );
//up.setIPv4Parameter(0,false,false,false,false,false,false,0,1,255,17,new IPAddress("100.100.100.1"),new IPAddress("100.100.100.2"));
up.src_ip = new IPAddress("100.100.100.1");
up.dst_ip = new IPAddress("100.100.100.2");
up.dont_frag = true;
up.protocol = 17;
up.ident = 1;
up.offset = 0;
up.version = 4;
up.data = "".getBytes();
up.hop_limit = 128;
up.length = 48;
displayUDP( up );
return up;
public TCPPacket createTCP() throws Exception {
TCPPacket tp = new TCPPacket(80,333,5215133,0,false,false,false,false,true,false,8192,0);
//tp.setIPv4Parameter(0,false,false,false,false,false,false,0,1,255, 6,new IPAddress("100.100.100.1"),new IPAddress("100.100.100.2"));
tp.src_ip = new IPAddress("100.100.100.1");
tp.dst_ip = new IPAddress("100.100.100.2");
tp.dont_frag = true;
tp.protocol = 6;
tp.ident = 1;
tp.offset = 0;
tp.version = 4;
tp.data = "".getBytes();
tp.hop_limit = 128;
tp.length = 48;
displayTCP( tp );
return tp;
public void displayUDP(UDPPacket packet) {
System.out.println( "UDP Packet");
System.out.println("-----------------");
System.out.println("caplen:" +packet.caplen        );
System.out.println("sec:" +packet.sec           );
System.out.println("usec:" +packet.usec          );
System.out.println("datalink:" +packet.datalink      );
System.out.println("data:" +packet.data.length   );
System.out.println("-----------------");
System.out.println("priority:" +packet.priority      );
System.out.println("d_flag:" +packet.d_flag        );
System.out.println("t_flag:" +packet.t_flag        );
System.out.println("r_flag:" +packet.r_flag        );
System.out.println("rsv_frag:" +packet.rsv_frag      );
System.out.println("dont_frag:"+packet.dont_frag );
System.out.println("more_frag:"+packet.more_frag );
System.out.println("offset:" +packet.offset        );
System.out.println("ident:" +packet.ident         );
System.out.println("ttl: ** not found **" );
System.out.println("protocol:" +packet.protocol      );
System.out.println("src_ip:" +packet.src_ip        );
System.out.println("dst_ip:" +packet.dst_ip        );
System.out.println("length:" +packet.length        );
System.out.println("version:" +packet.version       );
System.out.println("hop_limit:"+packet.hop_limit );
System.out.println("-----------------");
System.out.println("src_port:" +packet.src_port      );
System.out.println("dst_port:" +packet.dst_port      );
public void displayTCP(TCPPacket packet) {
System.out.println( "TCP Packet");
System.out.println("-----------------");
System.out.println("caplen:" +packet.caplen        );
System.out.println("sec:" +packet.sec           );
System.out.println("usec:" +packet.usec          );
System.out.println("datalink:" +packet.datalink      );
System.out.println("data:" +packet.data.length   );
System.out.println("-----------------");
System.out.println("priority:" +packet.priority      );
System.out.println("d_flag:" +packet.d_flag        );
System.out.println("t_flag:" +packet.t_flag        );
System.out.println("r_flag:" +packet.r_flag        );
System.out.println("rsv_frag:" +packet.rsv_frag      );
System.out.println("dont_frag:"+packet.dont_frag );
System.out.println("more_frag:"+packet.more_frag );
System.out.println("offset:" +packet.offset        );
System.out.println("ident:" +packet.ident         );
System.out.println("ttl: ** not found **" );
System.out.println("protocol:" +packet.protocol      );
System.out.println("src_ip:" +packet.src_ip        );
System.out.println("dst_ip:" +packet.dst_ip        );
System.out.println("length:" +packet.length        );
System.out.println("version:" +packet.version       );
System.out.println("hop_limit:"+packet.hop_limit );
System.out.println("-----------------");
System.out.println("src_port:" +packet.src_port      );
System.out.println("dst_port:" +packet.dst_port      );
System.out.println("sequence:" +packet.sequence      );
System.out.println("ack_num:" +packet.ack_num       );
System.out.println("urg:" +packet.urg           );
System.out.println("ack:" +packet.ack           );
System.out.println("psh:" +packet.psh           );
System.out.println("rst:" +packet.rst           );
System.out.println("syn:" +packet.syn           );
System.out.println("fin:" +packet.fin           );
System.out.println("window:" +packet.window        );
System.out.println("urgent:" +packet.urgent_pointer);
}

I have done quite a bit of work with the jpcap software. The tcp dump functionality works fine but as you stated there are problems with the send. I hope you are fimilar with C programming because there are bugs in the native implementation that you will unfortunutely need to work out.
I have the source code that I worked on at work or I would send it to you now. If you would like a copy of my updated version of the C code then send me an email. It's not perfect but its a start. BTW -- what operating system are you attempting to run this on? I only have patched the code for windows.
[email protected]

Similar Messages

  • I accidentally put a passcode lock on my iPhone and I forgot what I set for it, is there a way to take it off without accessing the phone? I have restored my phone but it doesn't work, is there anybody that could help me please?

    I accidentally put a passcode lock on my iPhone and I forgot what I set for it, is there a way to take it off without accessing the phone? I have restored my phone but it doesn't work, is there anybody that could help me please?

    You can't "accidentally" put a passcode on any iPhone...its a multi-step process. Further, restoring an iPhone will remove the passcode, as the passcode is not included in an iPhone backup.
    Are you sure you're talking about the phone passcode & not something else...like the "Restrictions" passcode?

  • Problem during installation of iTunes 10.7 on Win7 x64. Is there anybody that can help me?

    Hello everyone!
    I've a problem during installation of Itunes 10.7 on Window 7 x64. I had installed v11 but i don't like it, so i've uninstalled correctly this version and i have downloaded v10.7
    The message, translated in english, is:
    UNKNOWN \ Components \ ... \ 2B0163E6D0340BE2758E9BEDD8.
    Make sure you have sufficient access to that key, or contact your support staff.
    I don't know how to do...I don't want to format my pc
    I have already tried to erase all the "apple" folders on directory C:\, but nothing to do...
    Is there anybody that can help a poor italian boy, please?
    Thanks a lot,
    Teo

    Thx Polydorus!
    this evening i'll try and i'll tell you if it works!
    Teo

  • Is there anybody that upgraded an "older" MacBook to Mavericks

    Hello
    I have a MacBook (MacBook 2,1 Mid 2007) with an Intel Core 2 Duo, 2.16 GHz processor. It's executing 10.6.8 (Snow Leopard) and it runs very well. Is there anybody with a similar setup that upgraded to Mavericks ?
    If so, any problems ? Did it slow down your coputer ?
    Thank's for your input.

    To install Mavericks, you need one of these Macs:
    iMac (Mid-2007 or later)
    MacBook (13-inch Aluminum, Late 2008), (13-inch, Early 2009 or later)
    MacBook Pro (13-inch, Mid-2009 or later),
    MacBook Pro (15-inch or 17-inch, Mid/Late 2007 or later)
    MacBook Air (Late 2008 or later)
    Mac mini (Early 2009 or later)
    Mac Pro (Early 2008 or later)
    Xserve (Early 2009)
    Your Mac also needs:
    OS X Mountain Lion, Lion, or Snow Leopard v10.6.8 already installed
    2 GB or more of memory
    8 GB or more of available space

  • I have a mac book pro i7 2.00Ghz and 4Gb RAM. I want to run at the same time Omnisphere,Trilian and BFD 2. Will it work fine? Anybody that has some experience? Thanks

    I have a mac book pro i7 2.00Ghz and 4Gb RAM. I want to run at the same time Omnisphere,Trilian and BFD 2. Will it work fine? Anybody that has some experience? Thanks

    Well this is not a problem I have already bought one, my great worry is the processor and the memory..

  • I am having trouble in downloading apps as when I try, a message appears " not enough local storage is available manage this in settings". I have tried by deleting old apps but the message still appears.  What am I doing wrong and is there anybody that  c

    I am having trouble downloading apps onto my iPad2.  When I try a message appears " not enough local storage this can be managed in settings.". I ave tried by deleting unused apps, but the same message appears.  How can I resolve this ?  Help needed pleas.

    Try rebooting the iPad as well. You might be getting an inaccurate reading and rebooting might clear that up.
    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.

  • My camera is not working I can not take photos, use the recorder or even I can not use the facetime's video mode. Is there anybody that can have the same problem and knows the solution?

    Please answer as soon as possible.

    Have you tried a rest or hard reset?
    Hold your power button and your home button for about 15 seconds until you see the apple logo.
    Ignore the power slider when you see it.

  • Ever since the last update I can't seem to open up the list of ''Recently Closed Windows'', is there anybody that can help me with that?

    Yesterday my Firefox browser was updated without me even noticing it. I closed the only 2 windows that were open, both having a bunch of tabs, because I turned off my PC. Today I opened up Firefox, clicked ''Restore previous session'' which opened up one of these 2 windows. But when I wanted to access the list of ''Recently Closed Windows'' it didn't open. It only shows a small square as if it's there, but it doesn't show anything. I can open up ''Recently Closed Tabs'' but that doesn't help me. I now only have 1 window, but the other one had some important tabs opened in it as well, so I could really use some help.
    Thanks in advance.

    Sorry to hear about this problem and for the delay in getting back to you.
    Firefox stores your open windows and tabs in a file named sessionstore.js in your currently active settings folder. Could you check that folder and back up all of the sessionstore files as the first step.
    Open your current Firefox settings (AKA Firefox profile) folder using
    Help > Troubleshooting Information > "Show Folder" button
    If you find a file named sessionstore but not sessionstore.js, Windows may be hiding file extensions from you. To work with files as accurately as possible, I suggest unhiding them. This Microsoft support article has the steps: [http://support.microsoft.com/kb/865219].
    ''(In Windows 8.1, you should be able to access the Folder Options dialog by tapping the Alt key to show the menu bar, then using the Tools menu. Click to the View menu and scan down for the hidden files/folders option.)''
    Assuming you still have a sessionstore.js or sessionstore.bak file that would have your pre-update session, check out these threads for different ways to rescue the lost URLs from the sessionstore.js or sessionstore.bak file:
    * Using Firefox's Browser Console (formerly known as Error Console): https://support.mozilla.org/questions/969046#answer-471950
    * Using Firefox developer tool "Scratchpad": http://forums.mozillazine.org/viewtopic.php?f=38&t=622036&start=60&p=12098147#p12098147
    * Using a third party website: https://firefox-session-restore.herokuapp.com/

  • Re: Is there anybody that i can complain to about ...

    2 weeks and 12 line checks later the fault is still not resolved because I will not accept the charges.
    I believe we have a contract that I pay a premium price for and which BT is not supplying, ie a working network connection.
    Their own tracker shows the fault lies with the BT retail servers, I cannot take time off without 6-8 weeks notice just on the off chance that the engineer might turn up and might need to access my house. The local line was replaced last year and the internal wiring checked at the same time, there have been no changes since.
    Until BT can assure me that there is no possibility of the fault being in their network, where upon I will arrange my own engineer at much less cost and greater convenience, we are at an impasse, as the so called help desk say they cannot escalate the calls.

    Hi Paxman20,
    Welcome to the forum and thanks for posting. In most cases an engineer will need to get access to test and demonstrate to the customer that the issue is sorted. I'll be happy to take a look at this case for you if you wish. Drop me an email with your details. You'll get the 'contact us' link in my profile.
    Cheers
    David
    BTCare Community Mod
    If we have asked you to email us with your details, please make sure you are logged in to the forum, otherwise you will not be able to see our ‘Contact Us’ link within our profiles.
    We are sorry but we are unable to deal with service/account queries via the private message(PM) function so please don't PM your account info, we need to deal with this via our email account :-)

  • Hey there is there anyone that have problems whit Copy/paste, after downloading the new version off Facebook

    i can copy/paste on facebook after the opgarding ios5 on my phone..
    can anybody help me whit that ?

    Sorry to be so late in replying to you but thanks for answering my question but Where do I go for the I-POD TOUCH FORUM? totally new to this game.

  • Is there anybody that i can complain to about BT?

    Despite extensive correspondence with BT Digital Care Complaints and Resolutions, BT continue to bill me for broadband despite me having no Broadband Service from them due to delays in their services! Does anyone know how i can take this complaint higher as at the moment BT are basically doing what they want despite my objections.
    I thought about complaing to Ofcom but they dont accept complaints.
    Solved!
    Go to Solution.

    Hi Chester97,
    Thanks for posting and I'm sorry to read about the problems with your service.  If you are not happy with the way resolutions are dealing with the complaint you can always ask the person you are dealing with to escalate it to the next level alternatively we can take a look at this for you if you send over your details.  I've made the contact the mods link visible and you can find that by clicking on my username.
    Thanks
    Neil 
    BTCare Community Mod
    If we have asked you to email us with your details, please make sure you are logged in to the forum, otherwise you will not be able to see our ‘Contact Us’ link within our profiles.
    We are sorry but we are unable to deal with service/account queries via the private message(PM) function so please don't PM your account info, we need to deal with this via our email account :-)
    If someone answers your question correctly please let other members know by clicking on ’Mark as Accepted Solution’.

  • Hello, I need to know how to restore my Bookmarks that have disappeared .. Thank you

    Hello, I have noticed that my Firefox has been crashing quite often over the last 2 weeks. Now as of this morning my several Book Marks that I use daily have disappeared ... Please help me to restore this .
    Awaiting a response
    Thank you

    First, you need to update to a more Recent version of Firefox. Download Firefox 15.0.1 from [http://www.getfirefox.com www.getfirefox.com].
    Then, after that, read [[Recover lost or missing Bookmarks]]

  • Is there a way to just show the lines that have keys on?

    Hi,
    Is there a way to just show the lines of the pararameters that have keys on?
    Thanks.

    Select all of the layers in the timeline, and hit the "u" key.

  • Counting Numnber of Cells in a Table that Have the Same Value

    Is there a way/formula to do this, other than they way I'm doing it now, which is by using COUNTIF? In a table with 1000 rows for instance, let's say the values in the A column are what I'm keying off. I would like a count of all the cells in the A column that have the word "example" as their value. Right now for each unique value in a cell in the A column I am manually creating a COUNTIF(A1:A1000,"<value i'm matching against>) but if there are many unique values in the A column, it's quite laborious. Ideally I'd like to just have a table generated that gives me the top 5 or top 10 most occurring cell values in the A column in the table. What's the best way to do this?

    So for instance, for a column like this:
    1
    1
    1
    2
    2
    4
    5
    I want a way to get back the number of times 1 appears in the list (3), the number of times 2 appears in the list (2), 4 (1), 5 (1), and so on. If I do a COUNTIF and there are thousands of rows, I have to manually put the matching string in each one.

  • Enumerate the users that have access to a particular directory

    Hi, my name is Jennifer and I have been searching for an answer to my problem through several blogs. The problem is that I have a Directory of which I want to not only retrieve the users\groups that have access to it but also enumerate through the groups
    to list actual users. The groups part is the main issue here. If I use get-acl, I can return any number of particular Active Directory groups that have access, however, I need to list the users inside this group and get-acl will not output an object I can
    work with. I thought I could do something like this (which I may have seen on this forum before):
    get-acl "C:\NestedGroupTest" | %{$_.access} \ ft -property identityreference
    This will return the groups\users that have access. Example:
    Domain\OU
    NT Authority\system
    Builtin\users
    ETC...
    I have tried exporting this output to a file and then trying to use get-adgroupmember (which obviously will not work on the non-AD groups) but the objects are of the wrong type so basically nothing in the Active Directory module will work...
    This seems like such a simple issue but it is causing me grief to no end...please help

    I can't guarantee that this will work in all cases, but it seems to work on my test domain. Warning: it's very slow and inefficient. It requires
    this module (get the 3.0 test version), but you can modify the foreach block's code somewhat to get it to work with Get-Acl. 
    Get-Item C:\NestedGroupTest | Get-AccessControlEntry | ForEach-Object { $PropertyNames = $null }{
    if (-not $PropertyNames) {
    # We need to copy the property. This will get a list
    # of the properties on each ACE when it encounters
    # the first ACE (since the rest of this is so ineffecient,
    # we can feel good that we saved some work by doing this)
    $PropertyNames = $_ | Get-Member -MemberType Properties | select -exp Name
    # Create a new hashtable that will be used to create a PSObject
    $NewObjectProps = @{}
    foreach ($CurrentProperty in $PropertyNames) {
    $NewObjectProps.$CurrentProperty = $_.$CurrentProperty
    # Check to see if this SID belongs to an AD group
    Write-Verbose ("Current principal: {0}" -f $_.Principal)
    try {
    $Group = Get-ADGroup -Filter { SID -eq $_.SecurityIdentifier } -ErrorAction Stop
    catch {
    # Write a warning or something?
    if ($Group) {
    Write-Verbose " -> Group, so looking up members"
    $Users = $Group | Get-ADGroupMember -Recursive | select @{N="Principal"; E={$_.SID.Translate([System.Security.Principal.NTAccount])}}, @{N="SecurityIdentifier"; E={$_.SID}}
    else {
    Write-Verbose " -> Not an AD group"
    $Users = $_ | select Principal, SecurityIdentifier
    # Go through each user/non-translated group, modify two
    # hashtable properties, and create the new PSObject
    $Users | ForEach-Object {
    $NewObjectProps.SecurityIdentifier = $_.SecurityIdentifier
    $NewObjectProps.Principal = $_.Principal
    $NewObject = New-Object PSObject -Property $NewObjectProps
    # This will make the new object show the module's custom formatting:
    $NewObject.pstypenames.Insert(0, "PowerShellAccessControl.Types.AdaptedAce")
    $NewObject
    That should resemble the output that Get-AccessControlEntry would give you, but AD groups have been translated to users. If you pipe that to Export-CSV, you'd have plenty of information for each ACE, including the path, principal, security identifier, access
    mask, etc. You could also pipe that to Select-Object and just ask for certain properties (try it with these properties: Path, Principal, AccessMask, AccessMaskDisplay, AppliesTo).
    You can also use the Get-AccessControlEntry function's parameters to do some filtering on the ACEs that are returned (maybe you only want ACEs with FullControl, or ACEs that were not inherited...)
    Give it a shot and let me know if it works for you. If you need more explanation of what's going on in the foreach-object process block, let me know and I'll try to help. It can be modified to work with version 2.1 of my module, and with Get-Acl.

Maybe you are looking for