I have only one doubt about your way of searching for reference , I
got below code in 5-10 min of search. You could have mentioned what
site you have already checked so far.


Anyway, back to your concern .......

1) CAPTURE: You need to capture a packet first to analyze. Use simple
raw socket.

2) ANALYZE: In raw socket mode you will get raw IP data [*TADA* with
an IP header!].
Decode using "standard" IP header paradigm.

If you *REALLY* need copy paste then try this : (in c#)



public enum Protocol {
                Ggp = 3,
                Icmp = 1,
                Idp = 22,
                Igmp = 2,
                IP = 4,
                ND = 77,
                Pup = 12,
                Tcp = 6,
                Udp = 17,
                Other = -1
        }
public enum Precedence {
                Routine = 0,
                Priority = 1,
                Immediate = 2,
                Flash = 3,
                FlashOverride = 4,
                CRITICECP = 5,
                InternetworkControl = 6,
                NetworkControl = 7
        }

public enum Delay {
                NormalDelay = 0,
                LowDelay = 1
        }
public enum Throughput {
                NormalThroughput = 0,
                HighThroughput = 1
        }

        public enum Reliability {
                NormalReliability = 0,
                HighReliability = 1
        }

      private byte[] m_Raw;
                private DateTime m_Time;
                private int m_Version;
                private int m_HeaderLength;
                private Precedence m_Precedence;
                private Delay m_Delay;
                private Throughput m_Throughput;
                private Reliability m_Reliability;
                private int m_TotalLength;
                private int m_Identification;
                private int m_TimeToLive;
                private Protocol m_Protocol;
                private byte[] m_Checksum;
                private IPAddress m_SourceAddress;
                private IPAddress m_DestinationAddress;
                private int m_SourcePort;
                private int m_DestinationPort;

Decode (byte[] raw)
{
if (raw == null)
        throw new ArgumentNullException();
                        if (raw.Length < 20)
                                throw new ArgumentException(); // invalid IP 
packet

                        m_Time = time;
                        m_Version = (raw[0] & 0xF0) >> 4;
                        m_HeaderLength = (raw[0] & 0x0F) * 4 /* sizeof(int) */;
                        if ((raw[0] & 0x0F) < 5)
                                throw new ArgumentException(); // invalid 
header of packet
                        m_Precedence = (Precedence)((raw[1] & 0xE0) >> 5);
                        m_Delay = (Delay)((raw[1] & 0x10) >> 4);
                        m_Throughput = (Throughput)((raw[1] & 0x8) >> 3);
                        m_Reliability = (Reliability)((raw[1] & 0x4) >> 2);
                        m_TotalLength = raw[2] * 256 + raw[3];
                        if (m_TotalLength != raw.Length)
                                throw new ArgumentException(); // invalid size 
of packet
                        m_Identification = raw[4] * 256 + raw[5];
                        m_TimeToLive = raw[8];
                        if (Enum.IsDefined(typeof(Protocol), (int)raw[9]))
                                m_Protocol = (Protocol)raw[9];
                        else
                                m_Protocol = Protocol.Other;
                        m_Checksum = new byte[2];
                        m_Checksum[0] = raw[11];
                        m_Checksum[1] = raw[10];
                        m_SourceAddress = new 
IPAddress(BitConverter.ToUInt32(raw, 12));
                        m_DestinationAddress = new 
IPAddress(BitConverter.ToUInt32(raw,
16));
                        if (m_Protocol == Protocol.Tcp || m_Protocol == 
Protocol.Udp) {
                                m_SourcePort = raw[m_HeaderLength] * 256 + 
raw[m_HeaderLength +
1];
                                m_DestinationPort = raw[m_HeaderLength + 2] * 
256 +
raw[m_HeaderLength + 3];
                        } else {
                                m_SourcePort = -1;
                                m_DestinationPort = -1;
                        }
}









* I also copy-pasted the above code* (i.e. not my invention)

On Feb 23, 6:32 pm, Sravan <[email protected]> wrote:
> i just wanted to repeat that "THIS IS NOT A COMEDY SHOW OR WE ARE NOT
> HAVING FUN HERE"
>
> @FUN MAKING PEOPLE
>
> if u dont know the answer just shut up and do your work dont make
> unnecessary comments
>
> @greg hile
>
> those links which u gave me i referred long back
>
> i am attaching a file just go through that.
>
> my project is "network data protocol analyzer"
>
> need to analyze the data what protocol the data is using and source
> and destion addresses
>
> i am struck on how to analyze the network data and display in the gui
> of my tool.
>
> i am coding this in c# so i can have practice in coding.
>
> because i am serious and i am intrested to complete the work and just
> 1 month is there to complete...
> --
> Sravan Lakkaraju M.Tech CS
>
>  Project.doc
> 518KViewDownload

Reply via email to