problem with sending packets

Oct 10, 2011 at 6:39 PM

Hi,

My problem is that I want my packet to contain some special icmp message, like "Redirect", but I didn't find the way to do it.

I hoped to use icmpLayer.MessageType, but "MessageType" field is readonly.

Thank you very much!

Coordinator
Oct 10, 2011 at 6:47 PM

Hi Maxc13,


IcmpLayer is an abstract class so you need one of its descendants.

I guess that you want to send an echo request, so you'll need to use IcmpEchoRequest.

You can put a payload to this layer by adding a PayloadLayer after it with whatever data you want.

 

I hope this helps.

Boaz.

Jan 22, 2012 at 12:06 PM

hi, i tries this but here the payload goes into the icmp layer

how to add the payload to the tcp into the tcp layer

 Dim source As New MacAddress("1:1:1:1:1:1")

        ' set mac destination to 2:2:2:2:2:2
        Dim destination As New MacAddress("2:2:2:2:2:2")

        ' Create the packets layers

        ' Ethernet Layer
        Dim ethernetLayer As New EthernetLayer() With {.Source = source, .Destination = destination}


        ' IPv4 Layer
        ' The rest of the important parameters will be set for each packet
        Dim ipV4Layer As New IpV4Layer() With {.Source = New IpV4Address("1.2.3.4"), .Ttl = 128} '.tcp.payload = Encoding.ASCII.GetBytes("Catched")}

        Dim p As New PayloadLayer() With {.Data = New Datagram(Encoding.ASCII.GetBytes("Changed"))}


        ' ICMP Layer
        Dim icmpLayer As New IcmpEchoLayer()

        ' Create the builder that will build our packets
        Dim builder As New PacketBuilder(ethernetLayer, icmpLayer, ipV4Layer, p)
        ' Send 100 Pings to different destination with different parameters

        ' Set IPv4 parameters
        ipV4Layer.Destination = New IpV4Address("2.3.4." & 100)
        ipV4Layer.Identification = CUShort(100)

        ' Set ICMP parameters
        icmpLayer.SequenceNumber = CUShort(100)
        icmpLayer.Identifier = CUShort(100)

        ' Build the packet
        Dim packet2 As Packet = builder.Build(DateTime.Now)

        ' Send down the packet
        communicator.SendPacket(packet2)

Coordinator
Jan 22, 2012 at 7:40 PM

First of all, the order of the layers is wrong.

You wrote

New PacketBuilder(ethernetLayer, icmpLayer, ipV4Layer, p)
But ICMP should come after IPv4.

 

If you want a TCP with payload you need Ethernet, IPv4, TCP, Payload.

 

I hope this helps,

 

Boaz.

Jan 23, 2012 at 12:46 PM

thanks.....