setting IP flags

Feb 18, 2011 at 6:34 PM

Hi everyone

i wanna set the IP Flags , i know its done like :

 

IpV4FragmentationOptions.MoreFragments;

 

but how do i use it ?? i mean where do i use it ?? for instance with the TCP Control Bits i Can use :

 

new TcpLayer
                    {
                        ControlBits=TcpControlBits.Acknowledgment,
                    }

 

 please note that im using the following form :

 

using (PacketCommunicator pCommunicator = selectedDevice.Open(
                65536,
                PacketDeviceOpenAttributes.Promiscuous, 
                1000))
            {
                // Create the packet layers
                Packet packet = PacketBuilder.Build(DateTime.Now,
                    new EthernetLayer
                    {
                        Source = source,
                        Destination = destination,
                    },
                    new IpV4Layer
                    {
                        /* IP Initialization */
                    },
                    new TcpLayer
                    {
                        /* TCP Initialization */
                    });

                pCommunicator.SendPacket(packet);

which accepts only specified initialization members

Thanks in advance :)

 

Coordinator
Feb 19, 2011 at 8:02 AM

Hi shamilqais,

 

The IpV4FragmentationOptions field is part of the IpV4Fragmentation class.

Use the Fragmentation field in IpV4Layer to set IpV4Fragmentation and use the Options field in IpV4Fragmentation to set the options.

 

Boaz.

Feb 19, 2011 at 12:27 PM
Edited Feb 20, 2011 at 5:18 PM

im using :

IpV4Fragmentation x=new IpV4Fragmentation();
        x.Options = new IpV4FragmentationOption

but the compiler gives a (read only) error on (x.Options)

 

i used :

IpV4Fragmentation x=new IpV4Fragmentation(IpV4FragmentationOption.MoreFragment , 0);

and it worked , but i wanna ask is this field Immutable ?? because the only way i found was this (using the constructer) .

Coordinator
Feb 19, 2011 at 12:29 PM

You're right, IpV4Fragmentation is immutable so you can only assign it on construction.

You can still do it dynamically, but only using the constructor.