IPv6 support

Oct 1, 2014 at 3:08 PM
Edited Oct 1, 2014 at 7:43 PM
I saw that the new version support IPv6 and i saw under Sending Packets example hot to create IPV6 packet but my aim is to take PCAP file and convert all the packet into IPV6 packets so i am using this:
        private Packet ConvertToIPv6(Packet packet)
        {
            EthernetLayer ethernet = (EthernetLayer)packet.Ethernet.ExtractLayer();
            DateTime packetTimestamp = packet.Timestamp;

            EthernetLayer ethernetLayer =
            new EthernetLayer
            {
                Source = ethernet.Source,
                Destination = ethernet.Destination,
                EtherType = EthernetType.None,
            };

            if (packet.Ethernet.IpV4.Protocol == IpV4Protocol.Tcp)
            {
                ILayer payload = packet.Ethernet.IpV4.Tcp.Payload.ExtractLayer();
                TcpLayer tcpLayer =
                    new TcpLayer
                    {
                        SourcePort = packet.Ethernet.IpV4.Tcp.SourcePort,
                        DestinationPort = packet.Ethernet.IpV4.Tcp.DestinationPort,
                        Checksum = null, // Will be filled automatically.
                        SequenceNumber = packet.Ethernet.IpV4.Tcp.SequenceNumber,
                        AcknowledgmentNumber = packet.Ethernet.IpV4.Tcp.AcknowledgmentNumber,
                        ControlBits = TcpControlBits.Acknowledgment,
                        Window = packet.Ethernet.IpV4.Tcp.Window,
                        UrgentPointer = packet.Ethernet.IpV4.Tcp.UrgentPointer,
                        Options = TcpOptions.None,
                    };

                IpV6Layer ipV6Layer =
                    new IpV6Layer
                    {
                        Source = new IpV6Address("0123:4567:89AB:CDEF:0123:4567:89AB:CDEF"),
                        CurrentDestination = new IpV6Address("FEDC:BA98:7654:3210:FEDC:BA98:0000:0000"),
                        FlowLabel = 123,
                        HopLimit = 100,
                        NextHeader = IpV4Protocol.Tcp,
                    };

                return PacketBuilder.Build(packetTimestamp, ethernet, ipV6Layer, tcpLayer, payload);
            }
            else if (packet.Ethernet.IpV4.Protocol == IpV4Protocol.Udp)
            {
                ILayer payload = packet.Ethernet.IpV4.Udp.Payload.ExtractLayer();
                UdpLayer udpLayer =
                    new UdpLayer
                    {
                        SourcePort = packet.Ethernet.IpV4.Udp.SourcePort,
                        DestinationPort = packet.Ethernet.IpV4.Udp.DestinationPort,
                        Checksum = null, // Will be filled automatically.
                        CalculateChecksumValue = true,
                    };

                IpV6Layer ipV6Layer =
                    new IpV6Layer
                    {
                        Source = new IpV6Address("0123:4567:89AB:CDEF:0123:4567:89AB:CDEF"),
                        CurrentDestination = new IpV6Address("FEDC:BA98:7654:3210:FEDC:BA98:0000:0000"),
                        FlowLabel = 123,
                        HopLimit = 100,
                        NextHeader = IpV4Protocol.Udp,
                    };

                return PacketBuilder.Build(packetTimestamp, ethernet, ipV6Layer, udpLayer, payload);
            }
            else
            {
                return null;
            }
        }
This code works fine with TCP packets but with UDP packet it seems that the checksum is illeagal.
please see this 2 examples, before and after: https://www.sendspace.com/file/5vkj77
Coordinator
Oct 3, 2014 at 6:25 AM
Indeed, automatically calculate UDP checksum in UDP over IPv6 is not yet supported.
I hope to release a new version soon with supporting this.
Oct 3, 2014 at 4:00 PM
Can i do a temporary fix to solve it ?
Coordinator
Oct 4, 2014 at 5:30 AM
Yes, you can avoid calculating UDP checksum, and put 0 there.
Or you can calculate it yourself.
Oct 4, 2014 at 7:33 AM
Edited Oct 4, 2014 at 7:37 AM
Checksum = 0 for UDP is still Spawned same results.
How can i calculate UDP checksum ?
how hard is it ?
Coordinator
Oct 4, 2014 at 8:11 AM
Oct 4, 2014 at 10:50 AM
I'm sorry but I did not really understand how the calculation goes and how to do it.
can you help me with this ?
Coordinator
Oct 4, 2014 at 6:57 PM
Note that version 1.0.1 that has been released today includes support for calculating the UDP checksum over IPv6.
Oct 4, 2014 at 8:11 PM
Great, thanks a lot !