Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot send tcp packet larger than 1500 #21

Closed
russianbullet opened this issue Apr 20, 2017 · 16 comments
Closed

Cannot send tcp packet larger than 1500 #21

russianbullet opened this issue Apr 20, 2017 · 16 comments

Comments

@russianbullet
Copy link

Hello

I'm trying to send 1600 bytes packet size , but no luck

I'll be delighted to hear from you soon

regards

@abdullah2993
Copy link

@russianbullet MTU?

@russianbullet
Copy link
Author

abdullah I've modified the mtu of the ethernet card in windows but no luck , anything to do in sharppcap

@chmorgan
Copy link
Collaborator

SharpPcap doesn't contain any limits to the packet size you can send. That of course doesn't mean that there aren't limits due to wincap or npcap.

Now that npcap is supported by the latest git master would you mind trying npcap (instead of winpcap) and the latest git master to see if it works? If it doesn't then at least we can reach out to the npcap developer to discuss, winpcap is a dead project so we have no path for support there.

@russianbullet
Copy link
Author

russianbullet commented Apr 21, 2017

Dear @chmorgan I've uninstalled winpcap and installed npcap , the result is the same , I get this exception when SendPacket

**> An unhandled exception of type 'SharpPcap.PcapException' occurred in SharpPcap.dll

Additional information: Can't send packet: send error: PacketSendPacket failed**

@chmorgan
Copy link
Collaborator

chmorgan commented Apr 21, 2017 via email

@russianbullet
Copy link
Author

Thank you Chris

@hsluoyz
Copy link

hsluoyz commented Apr 22, 2017

The issues page is at Nmap repo here: https://github.com/nmap/nmap/issues

BTW, can you provide an example to reproduce this issue? It only needs to contain the sending packet call with 1600 bytes. And I will test whether it works.

And please provide your DiagReport described in Npcap README. So I can see your adapter info.

@russianbullet
Copy link
Author

Hello @hsluoyz
It's a pleasure to be in contact with you, Thx for @chmorgan
Dear @hsluoyz I've made a Demo about this issue, it's written in C#, also I've attached the Report you asked for. DiagReport-20170422-121459.txt
Thank you in advance

using SharpPcap;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DemoSendPacket
{
public partial class frmDemo : Form
{



private SharpPcap.CaptureDeviceList devices;
public frmDemo()
{
InitializeComponent();
}

private static byte[] GetRandomPacket(int size)
{
byte[] packet = new byte[size];
Random rand = new Random();
rand.NextBytes(packet);
return packet;
}

private void frmDemo_Load(object sender, EventArgs e)
{



NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();

devices = CaptureDeviceList.Instance;

foreach (ICaptureDevice dev in devices)
{

NetworkInterface ni = nics.Where((nic) => dev.Name.EndsWith(nic.Id)).FirstOrDefault();

if (ni == null)
continue;

this.cboNics.Items.Add(ni.Name);
}
}

private void btnSend1_Click(object sender, EventArgs e)
{
byte[] packet1 = GetRandomPacket(1514);
ICaptureDevice device = CaptureDeviceList.New()[this.cboNics.SelectedIndex];

device.Open();

device.SendPacket(packet1);

device.Close();
}

private void btnSend2_Click(object sender, EventArgs e)
{
byte[] packet2 = GetRandomPacket(1600);
ICaptureDevice device = CaptureDeviceList.New()[this.cboNics.SelectedIndex];

device.Open();

device.SendPacket(packet2);

device.Close();
}
}
}


@hsluoyz
Copy link

hsluoyz commented Apr 22, 2017

Where is this.cboNics defined? Please upload your whole project as a zip. It's kind of hard for a non C# expert as me to tackle only a piece of code.

And BTW, I found you are running Win8. It's an outdated system and not supported by Microsoft any more. And I don't even have a Win8 VM to reproduce any bugs. (I only have Vista SP1, Win7 SP1, Win8.1, Win10). Please update to at least Win8.1 to avoid potential problems if possible.

@russianbullet
Copy link
Author

Hello @hsluoyz , I'm so sorry to be late , I couldn't upload the project here, so I've uploaded it to google drive , this is the link: https://drive.google.com/file/d/0B6TQYhFg8n0mdXhubm5ESDdyYkE/view

@hsluoyz
Copy link

hsluoyz commented Apr 25, 2017

Hi, I reproduced your issue. It seems that Windows hardcoded the maximum of MTU for Ethernet adapters to be 1500. In fact I never googled out an article that said MTU can be larger than 1500. It's a de-facto standard and it seems that Windows implements this way. In fact, you can get a larger MTU for other type adapters. For example, Npcap Loopback Adapter supports a MTU of 65536.

@russianbullet
Copy link
Author

Thank you @hsluoyz , It seems that am going to fragment the ip packet , thank you for your efforts guys , regards

@abdullah2993
Copy link

@hsluoyz @russianbullet i am quite sure you can change the MTU in windows. Using netsh tool...

@abdullah2993
Copy link

@russianbullet
Copy link
Author

@abdullah2993 I've already changed it , but no luck still the same error

@chmorgan
Copy link
Collaborator

chmorgan commented May 6, 2017

Closing this as it is a limitation of the OS and/or npcap. @hsluoyz thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants