This project is read-only.

Is This Correct?? (on pcap.net example)

May 21, 2010 at 9:16 AM
Edited May 21, 2010 at 9:37 AM
on SendingASinglePacketWithSendPacket example: // Supposing to be on ethernet, set mac destination to 1:1:1:1:1:1 MacAddress source = new MacAddress("1:1:1:1:1:1"); // set mac source to 2:2:2:2:2:2 MacAddress destination = new MacAddress("2:2:2:2:2:2"); on the comment you swap between source and destination ????? PacketBuilder builder = new PacketBuilder(ethernetLayer, ipV4Layer, icmpLayer); for (int i = 0; i != 100; ++i) { // Set IPv4 parameters ipV4Layer.Destination = new IpV4Address("2.3.4." + i); ipV4Layer.Identification = (ushort)i; // Set ICMP parameters icmpLayer.SequenceNumber = (ushort)i; icmpLayer.Identifier = (ushort)i; // Build the packet Packet packet = builder.Build(DateTime.Now); // Send down the packet communicator.SendPacket(packet); } the parameters values of the layers on the for loop doesn't added to the builder so doesn't added to the packets that sendeded ?? I now confused about these two questions ?? THANKS
May 21, 2010 at 9:27 AM

First, for readability - here is your question:

 

on SendingASinglePacketWithSendPacket example:

// Supposing to be on ethernet, set mac destination to 1:1:1:1:1:1
MacAddress source = new MacAddress("1:1:1:1:1:1");
// set mac source to 2:2:2:2:2:2
MacAddress destination = new MacAddress("2:2:2:2:2:2");

on the comment you swap between source and destination ?????

PacketBuilder builder = new PacketBuilder(ethernetLayer, ipV4Layer, icmpLayer);
for (int i = 0; i != 100; ++i)
{
  // Set IPv4 parameters
  ipV4Layer.Destination = new IpV4Address("2.3.4." + i);
  ipV4Layer.Identification = (ushort)i;

  // Set ICMP parameters
  icmpLayer.SequenceNumber = (ushort)i;
  icmpLayer.Identifier = (ushort)i;

  // Build the packet
  Packet packet = builder.Build(DateTime.Now);

  // Send down the packet
  communicator.SendPacket(packet);
} 
the parameters values of the layers on the for loop doesn't added to the builder so doesn't added to the packets that sendeded ?? I now confused about these two questions ?? THANKS

May 21, 2010 at 9:31 AM

The answers:

  1. You are right, the comments were wrong and should be swapped. I will swap them.
  2. The packets do get the values of the layers. The PacketBuilder keeps references to the layers so you can change the layer parameters and every time you call PacketBuilder.Build() you get a packet with the updated layer parameters.

 

May 21, 2010 at 9:40 AM
sorry for Horrible post, and thanks brickner for your replay