Tuesday, April 8, 2014

Program C# : Divide Packet Data from Protocol TCP

First Step , open C# , (u can use Sharp Develop or Visual Studio /VB or ETC)

Next , make Project ,

Next , Lets Try analisyz our operational plan ,how the program logic on mind ?

Now , We have this code packet data :

*&(ikh)(abcde304900015halo apa kabar?okeh5986edcbaio test*0iou

want to translated into like this :
. What we have to do is ?

Lets we design for :
Button
TextBox

Label
Grupbox


After finish design , ill tell u the logic how it works .
So , there's many character on that packet , but there's gate between of it , 
there's it 
"abcda" 
on input gate , n 
"ebcda" 
on output gate . that data , is between that gate.

On two next character thats will be Source Port so we used 
x = teks.IndexOf("abcde");
y = teks.IndexOf("edcba");
string sourceport = teks.Substring(x+5,2);
x1 = x + 5 ;

Next Destination addres
string destinationaddress = teks.Substring(x1+2,2);
x2 = x1 + 2;

Next HLEN
string HLEN = teks.Substring(x2+2,5);
x3 = x2 + 2;
x4 = x3 + 5;
y2 = y - 4;

Next CRC 
string CRC = teks.Substring(y2,4);
xy = y2 - x4;

Next DATA
string DATA = teks.Substring(x4,xy);
textBox1.Text = Convert.ToString(sourceport);
textBox2.Text = Convert.ToString(destinationaddress);
textBox3.Text = Convert.ToString(HLEN);
textBox4.Text = Convert.ToString(CRC);
textBox5.Text = Convert.ToString(DATA);

As we can se , these above i use variable x + something , its mean the index ., 
at where the index what will found 

So here the coding



So lets compile it