Friday, March 26, 2010

HTTP

About HTTP

Table of Contents

List of contents in this Blog











S.No Protocol Tools
1 HttpNemesis

Wednesday, February 24, 2010

IP Addressing

Address Classes

There are 5 different address classes. You can determine which class any IP address is in by examining the first 4 bits of the IP address.
  • Class A addresses begin with 0xxx, or 1 to 126 decimal.
  • Class B addresses begin with 10xx, or 128 to 191 decimal.
  • Class C addresses begin with 110x, or 192 to 223 decimal.
  • Class D addresses begin with 1110, or 224 to 239 decimal.
  • Class E addresses begin with 1111, or 240 to 254 decimal.
Addresses beginning with 01111111, or 127 decimal, are reserved for loopback and for internal testing on a local machine; [You can test this: you should always be able to ping 127.0.0.1, which points to yourself] Class D addresses are reserved for multicasting; Class E addresses are reserved for future use. They should not be used for host addresses.

Now we can see how the Class determines, by default, which part of the IP address belongs to the network (N, in blue) and which part belongs to the node (n, in red).

  • Class A -- NNNNNNNN.nnnnnnnn.nnnnnnnn.nnnnnnnn
  • Class B -- NNNNNNNN.NNNNNNNN.nnnnnnnn.nnnnnnnn
  • Class C -- NNNNNNNN.NNNNNNNN.NNNNNNNN.nnnnnnnn

Private Subnets

There are three IP network addresses reserved for private networks. The addresses are 10.0.0.0, Subnet Mask 255.0.0.0, 172.16.0.0, Subnet Mask 255.240.0.0, and 192.168.0.0, Subnet Mask 255.255.0.0. These addresses are also notated 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16. They can be used by anyone setting up internal IP networks, such as a lab or home LAN behind a NAT or proxy server or a router. It is always safe to use these because routers on the Internet by default will never forward packets coming from these addresses.

Subnet Masking

Node addresses of all "0"s and all "1"s are reserved for specifying the local network (when a host does not know its network address) and all hosts on the network (broadcast address), respectively.

To calculate the number of subnets or nodes, use the formula (2n-2) where n = number of bits in either field, and 2n represents 2 raised to the nth power.

Example:
11111111.11111111.11100000.00000000 255.255.224.000 Subnet Mask

In this example a 3 bit subnet mask was used. There are 6 (23-2) subnets available with this size mask (remember that subnets with all 0's and all 1's are not allowed). Each subnet has 8190 (213-2) nodes. Each subnet can have nodes assigned to any address between the Subnet address and the Broadcast address.

# bits Subnet Mask CIDR # Subnets # Hosts Nets * Hosts
2 255.192.0.0 /10 2 4194302 8388604
3 255.224.0.0 /11 6 2097150 12582900
4 255.240.0.0 /12 14 1048574 14680036
5 255.248.0.0 /13 30 524286 15728580
6 255.252.0.0 /14 62 262142 16252804
7 255.254.0.0 /15 126 131070 16514820
8 255.255.0.0 /16 254 65534 16645636
9 255.255.128.0 /17 510 32766 16710660
10 255.255.192.0 /18 1022 16382 16742404
11 255.255.224.0 /19 2046 8190 16756740
12 255.255.240.0 /20 4094 4094 16760836
13 255.255.248.0 /21 8190 2046 16756740
14 255.255.252.0 /22 16382 1022 16742404
15 255.255.254.0 /23 32766 510 16710660
16 255.255.255.0 /24 65534 254 16645636
17 255.255.255.128 /25 131070 126 16514820
18 255.255.255.192 /26 262142 62 16252804
19 255.255.255.224 /27 524286 30 15728580
20 255.255.255.240 /28 1048574 14 14680036
21 255.255.255.248 /29 2097150 6 12582900
22 255.255.255.252 /30 4194302 2 8388604





Thursday, November 5, 2009

SIP

Session Initiation Protocol

The Session Initiation Protocol (SIP) is a signaling protocol, widely used for controlling multimedia communication sessions such as voice and video calls over Internet Protocol (IP). Other feasible application examples include video conferencing, streaming multimedia distribution, instant messaging, presence information and online games. The protocol can be used for creating, modifying and terminating two-party (unicast) or multiparty (multicast) sessions consisting of one or several media streams. The modification can involve changing addresses or ports, inviting more participants, adding or deleting media streams, etc.

The SIP protocol is a TCP/IP-based Application Layer protocol. SIP is designed to be independent of the underlying transport layer; it can run on Transmission Control Protocol (TCP), User Datagram Protocol (UDP), or Stream Control Transmission Protocol (SCTP).[3] It is a text-based protocol, incorporating many elements of the Hypertext Transfer Protocol (HTTP) and the Simple Mail Transfer Protocol (SMTP),[4] allowing for direct inspection by administrators.

Protocol design

SIP employs design elements similar to HTTP-like request/response transaction model.[5] Each transaction consists of a client request that invokes a particular method or function on the server and at least one response.

SIP clients typically use TCP or UDP on port numbers 5060 and/or 5061 to connect to SIP servers and other SIP endpoints. Port 5060 is commonly used for non-encrypted signaling traffic whereas port 5061 is typically used for traffic encrypted with Transport Layer Security (TLS).

SIP is primarily used in setting up and tearing down voice or video calls. It has also found applications in messaging applications, such as instant messaging, and event subscription and notification.

SIP network elements


A SIP user agent (UA) is a logical network end-point used to create or receive SIP messages and thereby manage a SIP session. A SIP UA can perform the role of a User Agent Client (UAC), which sends SIP requests, and the User Agent Server (UAS), which receives the requests and returns a SIP response. These roles of UAC and UAS only last for the duration of a SIP transaction.

A SIP phone is a hardware-based or software-based SIP user agent, that provides call functions such as dial, answer, reject, hold/unhold, and call transfer. Examples include softphones such as Ekiga, KPhone, Twinkle, Windows Live Messenger, X-Lite, and hardware phones from vendors such as Avaya, Cisco, Leadtek, Polycom, Snom, and Nokia.

Each resource of a SIP network, such as a User Agent or a voicemail box, is identified by a Uniform Resource Identifier (URI), based on the general standard syntax also used in Web services and e-mail. A typical SIP URI is of the form: sip:username:password@host:port. The URI scheme used for SIP is sip:. If secure transmission is required, the scheme sips: is used and SIP messages must be transported over Transport Layer Security (TLS).

SIP Messages

SIP is a text-based protocol with syntax similar to that of HTTP. There are two different types of SIP messages: requests and responses. The first line of a request has a method, defining the nature of the request, and a Request-URI, indicating where the request should be sent.The first line of a response has a response code.

For SIP requests, RFC 3261 defines the following methods:

* REGISTER: Used by a UA to notify its current IP address and the URLs for which it would like to receive calls.
* INVITE: Used to establish a media session between user agents.
* ACK: Confirms reliable message exchanges.
* CANCEL: Terminates a pending request.
* BYE: Terminates a session between two users in a conference.
* OPTIONS: Requests information about the capabilities of a caller, without setting up a call.

The SIP response types defined in RFC 3261 fall in one of the following categories:

* Provisional (1xx): Request received and being processed.
* Success (2xx): The action was successfully received, understood, and accepted.
* Redirection (3xx): Further action needs to be taken (typically by sender) to complete the request.
* Client Error (4xx): The request contains bad syntax or cannot be fulfilled at the server.
* Server Error (5xx): The server failed to fulfill an apparently valid request.
* Global Failure (6xx): The request cannot be fulfilled at any server.

Source: http://en.wikipedia.org/wiki/Session_Initiation_Protocol

Sone more references:

SIP Concept based on some stories :)
http://www.sipcenter.com/sip.nsf/html/Personal+Selective+Presence
http://www.sipcenter.com/sip.nsf/html/SIP+Silent+Rejection+Service
http://www.sipcenter.com/sip.nsf/html/SIP+Call+Redirection

How to Start and Stop Services

Httpd Service:

service httpd stop
service httpd start

Example:
[root@lnx init.d]# service httpd stop
Stopping httpd: [ OK ]

[root@lnx init.d]# wget http://localhost/index1.html
--23:02:18-- http://localhost/index1.html
=> `index1.html.1'
Resolving localhost... 127.0.0.1
Connecting to localhost[127.0.0.1]:80... failed: Connection refused.

[root@lnx init.d]# service httpd start
Starting httpd: [ OK ]

[root@lnx init.d]# wget http://localhost/index1.html
--23:02:28-- http://localhost/index1.html
=> `index1.html.1'
Resolving localhost... 127.0.0.1
Connecting to localhost[127.0.0.1]:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 65 [text/html]

100%[=====================================================================>] 65 --.--K/s

23:02:28 (634.77 KB/s) - `index1.html.1' saved [65/65]

[root@lnx init.d]#

FTP Service:

Used Vsftpd server as FTP server here.
(To start any service using "service start", we should have the corresponding servie
in the /etc/init/d directory. Lets see how to add vsftpd to /etc/init.d later. For now we can
start / stop the vsftpd service using the process spawn / kill method)

To start the vsftpd service as a background process:
/usr/local/sbin/vsftpd &

To stop the vsftpd service, kill the process:
killall vsftpd

Example:

[root@lnx ~]# ftp localhost
Connected to lnx.cisco.com.
220 (vsFTPd 2.0.5)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (localhost:root): root
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd
257 "/root"
ftp> quit
221 Goodbye.
[root@lnx ~]#


DNS Service

Service "named" is meant for DNS.

[root@lnx ~]# service named restart
Stopping named: [ OK ]
Starting named: [ OK ]
[root@lnx ~]#

Instead of "restart", you can also "stop" and then "start".

Example:

[root@lnx ~]# dig @localhost www3.example.com

; <<>> DiG 9.2.4 <<>> @localhost www3.example.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 16182
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;www3.example.com. IN A

;; ANSWER SECTION:
www3.example.com. 1 IN A 3.1.1.2
www3.example.com. 1 IN A 3.1.1.3
www3.example.com. 1 IN A 3.1.1.4

;; AUTHORITY SECTION:
dnsins.com. 1 IN NS ns.dnsins.com.

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(localhost)
;; WHEN: Wed Nov 4 23:35:20 2009
;; MSG SIZE rcvd: 98

[root@lnx ~]#

SIP

Saturday, June 27, 2009

Some details for SSL

Some good websites :

http://tldp.org/HOWTO/SSL-Certificates-HOWTO/x64.html

http://www.dylanbeattie.net/docs/openssl_iis_ssl_howto.html

http://www.tc.umn.edu/~brams006/selfsign.html

DSA and RSA Cert Generation:
http://www.vscape.com/wiki/opensource/vssl/openssl_certs

http://security.ncsa.uiuc.edu/research/grid-howtos/usefulopenssl.php