Unable to Send packets using PCap.net

Jan 30, 2012 at 10:22 AM

Hello Guys,

 

I'm trying to send packets to my dedicated server on port 80. On my side (where I'm building and sending the packet) Wireshark logs the packet as being sent.

However, when I log all incoming packets on my dedicated server no packet is received at all. (I've even looked through without using any filters)
I've verified my interface is correct as well.
Does anyone know why I am unable to accomplish this? Here's what I have:

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using PcapDotNet.Packets.Icmp;
using PcapDotNet.Packets;
using PcapDotNet.Packets.IpV4;
using PcapDotNet.Packets.Ethernet;
using PcapDotNet.Core;
using PcapDotNet.Packets.Transport;



namespace pcap
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            uint i = 0;
            while (true)
            {
                i++;
                EthernetLayer ethernet;
                IpV4Layer ip4;
                TcpLayer tcp;
                MacAddress srcMac, dstMac;
                srcMac = new MacAddress("1:1:1:1:1:1");
                dstMac = new MacAddress("2:2:2:2:2:2");
                ethernet = new EthernetLayer();
                ethernet.Source = srcMac;
                ethernet.Destination = dstMac;
                ethernet.EtherType = EthernetType.IpV4;
                IpV4Address srcIP = new IpV4Address("xx.xx.xx.xx");
                IpV4Address dstIP = new IpV4Address("xx.xx.xx.xx");
                ip4 = new IpV4Layer();
                ip4.Source = srcIP;
                ip4.Destination = dstIP;
                ip4.Protocol = IpV4Protocol.Tcp;
                ip4.Ttl = 128;
                ip4.Fragmentation = new IpV4Fragmentation(IpV4FragmentationOptions.DoNotFragment, 0);
                tcp = new TcpLayer();
                tcp.SourcePort = (ushort)80;
                tcp.DestinationPort = 80;
                tcp.Window = (ushort)i;
                tcp.SequenceNumber = (uint)i;
                tcp.AcknowledgmentNumber = (uint)i;
                tcp.ControlBits = TcpControlBits.Acknowledgment | TcpControlBits.Fin;
                PacketBuilder pb = new PacketBuilder(ethernet, ip4, tcp);
                SendPackets sp = new SendPackets(pb);
                sp.WriteToWire();
                Thread.Sleep(100);
            }
        }
    }
    class SendPackets
    {
        private PacketBuilder pktBuilder;
        public SendPackets(PacketBuilder builder)
        {
            pktBuilder = builder;
        }
        public void WriteToWire()
        {
            using (PacketCommunicator communicator = LivePacketDevice.AllLocalMachine[1].Open(100, PacketDeviceOpenAttributes.Promiscuous, 1000))
            {
                Packet packet = pktBuilder.Build(DateTime.Now);
                communicator.SendPacket(packet);
            }
        }
    }
}


Thanks for taking your time into reading this topic.