Monday, March 5, 2012

Digital Signature

What is digital Signature?
A digital signature scheme typically consists of three algorithms:
  • A key generation algorithm that selects a private key uniformly at random from a set of possible private keys. The algorithm outputs the private key and a corresponding public key.
  • A signing algorithm that, given a message and a private key, produces a signature.
  • A signature verifying algorithm that, given a message, public key and a signature, either accepts or rejects the message's claim to authenticity.

When is public / private key pair are used?
Answer  : used in two ways
1 Public key encryption :
message encrypted with a recipient's public key cannot be decrypted by anyone except a possessor of the matching private key. Used for Confidentiality
Asymmetric key algorithms : uses different(but Mathematically Related ) keys for Encryption and Decryption
Public encryption Key  and Private Decryption key
2  Digital Signature: message signed with a sender's private key can be verified by anyone who has access to the sender's public key. Used to check for Authenticity  of Message

What is EAP protocol Packet content?
What is PKI?

TCP IP

1Tell the scenarios in tcp connection establishmnet in which server doesnt reply.What all kind of errors can heppen

2 When is RESET used in TCP.
Ans:
1) When connection request (SYN )arrives and no process is listening on the destination port.
This is Hard Error ECONNRFUSED is returned to client as soon as RST is  reccieved
(In UDP  ICMP port unreachable  error will be sent to host)
2) In  TCP half-open connection (in a established connection if server reboots)If clients sedns data based on Preboot connection Server responds with RST
3) Receipt of any TCP segment from any device with which the device receiving the segment does not currently have a connection (other than a SYN requesting a new connection.)
4)  Receipt of a message with an invalid or incorrect Sequence Number or Acknowledgment Number field, indicating the message may belong to a prior connection or is spurious in some other way.

example: The client's host has crashed and rebooted. Here the server will receive a response
 to its keepalive probe, but the response will be a reset, causing the server to terminate the connection
sockets API provides this capability by using the "linger on close" socket option
This causes the abort to be sent when the connection is closed, instead of the normal FIN.
--RST segment elicits no response from the other end— it is not acknowledged at all.

Q) What is Linger on option in Socket?
Answer :The effect of an setsockopt(..., SO_LINGER,...) depends on what the values in the linger structure (the third parameter passed to setsockopt()) are:
Case 1:  linger->l_onoff is zero (linger->l_linger has no meaning):
            This is the default.
On close(), the underlying stack attempts to gracefully shutdown the connection after ensuring all unsent data is sent. In the case of connection-oriented protocols such as TCP, the stack also ensures that sent data is acknowledged by the peer.  The stack will perform the above-mentioned graceful shutdown in the background (after the call to close() returns), regardless of whether the socket is blocking or non-blocking.
Case 2: linger->l_onoff is non-zero and linger->l_linger is zero:
A close() returns immediately. The underlying stack discards any unsent data, and, in the case of connection-oriented protocols such as TCP, sends a RST (reset) to the peer (this is termed a hard or abortive close). All subsequent attempts by the peer's application to read()/recv() data will result in an ECONNRESET.
Case 3: linger->l_onoff is non-zero and linger->l_linger is non-zero:
A close() will either block (if a blocking socket) or fail with EWOULDBLOCK (if non-blocking) until a graceful shutdown completes or the time specified in linger->l_linger elapses (time-out). Upon time-out the stack behaves as in case 2 above.

Friday, February 17, 2012

Mutex

If a thread takes Mutex and dies.What happens to that mutex can take other take it ?

Threads

How to create Thread safe Function?
What is thread specific Data?
how to kill all threads spawned in Process.

Friday, February 10, 2012

64 bit processor what is the size of ptr and size of int

size of ptr is 64 bits. As Address bus is of 64 bit  2power64 size of memory can be accessed directly..
while in 32 bit 2 power 32 i.e 4 GB memory can be addressed RAM physical memory ant go beyond more than 4 GB
Size of int depends on the implementation generally its 32 bit as in
OS ------------------Data Model-----shor-t------int-------long----longlong-----ptr

Window--------------LLP64----------16---------32------32-------64----------64
Linux-----------------LP4-------------16---------32------64-------64----------64
SPARC--------------ILP64-----------16---------64------64-------64----------64
--------------------------------------------------------------------------------------------

What should be taken care while porting from 32  to 64 Arch?
If client is in 32 and server is in 64 bit what care should be taken?

--padding , ediannesss,pointers ?

What is Time_wait when does Socket goes in that its uses ?

Active Close / Passive Close ??

Linger option for sockets??

Wednesday, September 14, 2011

Packet flow in Network

DATA FLOW
A typical data flow which we deal with on daily bases in our homes and offices is like this:
Host A -> Switch -> Router R -> Switch -> Host B
  1. The 1.x host A wants to send to 2.x host B.
  2. Host A realises B is on a different network judging from the subnet mask and ip addresses and knows it need help from a router.
  3. Host A does an ARP operation to find out the MAC address of its default gateway, which is a router R.
  4. Host A sends to router R with source MAC = A‘s MAC and destination MAC = R‘s MAC. The switches in between them pass the frames intact.
  5. Router R sends to host B through the switch in between, rewriting the source MAC to R‘s MAC and the destination MAC to B‘s MAC (before this it should have an ARP entry of host B; otherwise it would do an ARP operation to find out B‘s MAC).

packet creation layer  from url type to page opening ? how pkt flows ? if there are 2 router in subnet ?
when is dns query fired ???