Friday, November 26, 2010

Visual Studio Command Prompt


C# codes can be compiled using "Visual Studio Command Prompt". Most of the people facing difficulties when it comes to find this command prompt. It resides in "C:\Windows\System32" as cmd.exe. For windows7 users it is possible to search for it through the start menu typing "visual studio command prompt".

Assume test.cs,

How to compile

csc test.cs

How to execute

test.exe

Tuesday, November 23, 2010

IP Header


• Version (Specifies the format of the IP packet header): 4 bits.

• IHL, Internet Header Length (Specifies the length of the IP packet header in 32 bit words. The minimum value for a valid header is 5): 4 bits.

• Differentiated Services (This field is defined in RFC 2474 and obsoletes the TOS field): 8 bits.

• Total length (Contains the length of the datagram). 16 bits.

• Identification (Used to identify the fragments of one datagram from those of another. The originating protocol module of an internet datagram sets the identification field to a value that must be unique for that source-destination pair and protocol for the time the datagram will be active in the internet system. The originating protocol module of a complete datagram clears the MF bit to zero and the Fragment Offset field to zero): 16 bits.

• Flags: 3 bits.

• Fragment Offset (Used to direct the reassembly of a fragmented datagram): 13 bits.

• TTL, Time to Live (A timer field used to track the lifetime of the datagram. When the TTL field is decremented down to zero, the datagram is discarded): 8 bits.

• Protocol (This field specifies the next encapsulated protocol): 8 bits.

• Header checksum (A 16 bit one's complement checksum of the IP header and IP options): 16 bits.

• Source IP address (IP address of the sender): 32 bits.

• Destination IP address (IP address of the intended receiver): 32 bits.

ARP

ARP (address resolution protocol) is used to translate protocol addresses to hardware interface addresses(mac).

ARP Header





• Hardware type: 16 bits.

• Protocol type: 16 bits.

• Hardware address length (Length of the hardware address in bytes.): 8 bits.

• Protocol address length (Length of the protocol address in bytes.): 8 bits.

• Opcode: 16 bits.

• Source hardware address: Variable length.

• Source protocol (mac) address: Variable length.

• Destination hardware (mac) address.: Variable length.

• Destination protocol address: Variable length.

Monday, November 22, 2010

Wireshark video tutorials

Wireshark is a free and open source software which is used for packet capturing and network analyzing... Download wireshark: http://www.wireshark.org/

Here are some good video tutorials to get a basic understand of wireshark software...

Introduction to Wireshark (Part 1 of 3)



Cookies and Grabbing Passwords with Wireshark (Part 2 of 3)



Data Mining using Wireshark (Part 3 of 3)

Thursday, November 18, 2010

Bit further into lex

Consider the lex program given below (line.l) which adds line numbers in front of each line in a given text file and displays the output on standard output.

The use of lex variables and lex functions

yytext : The text of the matched pattern is stored in this variable. yytext is a char pointer.

yyin : Of the type FILE*. This points to the current file being parsed by the lexer.

yylex() : The function that starts the analysis. It is automatically generated by Lex.

What if there is no matching pattern to be found?
Any string matches and default action happens which means all the inputs are going to be printed in a way one at a time.

%{

int lineno=1;

%}

%%

.*\n { printf("%5d %s",lineno++,yytext); }

%%

main(int argc, char*argv[])
{

FILE *yyin;
yyin=fopen(argv[1],"r");
yylex();
return 0;

}



Compilation process

lex line.l
cc lex.yy.c -0 line -lfl

Executing

For this program it requires a a file as a command line argument. So a file should be provided in this stage.

./line filename

If it is needed to print the output in a file, just redirect the output to a text file like following.

./line > filename

Thursday, November 11, 2010

How to add external jar files in eclipse

1. Inside the "package explorer", Right click on the project which needs to add the external jar file and click on "properties".


2. In "java build path", inside "Libraries" tab choose the external jar file by clicking on "Add external JARs" button and click "OK".


Wednesday, November 3, 2010

Configuring Git on Windows

Create an account in codaset.com


Create a project in there

Download and install following three programs in the given order




After finishing installations, Open git bash program and type the following command there (skip pass phrasing by entering). This process will generate a key.

ssh-keygen -C “username@email.com” -t rsa

(give an email address instead of “username@email.com”)



The key will be stored in a .ssh folder somewhere, usually in your user folder c:\\Documents and Settings\\Username\\.ssh on XP or c:\\Users\\Username\\.ssh on Windows7

Upload the key to codaset using the following way.
Myaccount > SSH keys then click on "upload new"



Open Git Extensions program

Click "clone repository"


Goto codaset account again and click on the project created, copy text under SSH tab

Now gain go to the clone window, paste it to the text area "repository to clone",give a desired destination and click ok

Goto the given destination folder and the project will be seen in there

Do the wanted changes to the project , go to the Git extensions again and open the repository been working on, under the command menu click on commit, stage the wanted files and click on "commit and push" to update in codaset so changes will be visible to everyone.