Tuesday, August 13, 2013

How to create your own ssl certificate

Developers have to use Digital Certificates very often. We can use self signed certificates to our development process rather than buying certificates from certificate authorities.

There are few simple steps to create our own certificates using visual studio.

Step 1

Open visual studio command prompt as administrator. You can get cmd as administrator by right click on short cut exists in visual studio tools and select run as administrator. (Not native windows command prompt)

Step 2:

Change the directory to where you want to create certificates. And type following command.



  • -sv yourprivatekeyfile.pvk is the name of the file containing the private key.
  • -n "cert name" is the name that will appear on the certificate (and in the certificate store).
  • yourcertfile.cer is the name of the certificate file.
  • -b mm/dd/yyyy is the date when the certificate becomes valid.
  • -e mm/dd/yyyy is the date when the certificate expires.
  • -r indicates that this will be a self-signed certificate.


Step 3:

Then you'll be prompted to enter the password for private key.


Step 4:

After you enter password you'll be prompted to enter password for sign certificate.


Step 5: 

This is the final step. Enter following command in cmd


Then it'll be prompted to enter private key password. Enter password and that's it.


  • -pvk yourprivatekeyfile.pvk is the private key file that you created
  • -spc yourcertfile.cer is the certificate file you created
  • -pfx yourpfxfile.pfx is the name of the .pfx file that will be created
You can see your certificates in hard disk






Sunday, May 5, 2013

Use Xgraph with NS2

XGRAPH is a general purpose x-y data plotter with interactive buttons for panning, zooming, printing, and selecting display options. It will plot data from any number of files on the same graph and can handle unlimited data-set sizes and any number of data files.

How to Install:
This example goes with two previous posts:
1. NS2 UDP Example
2. NS2 TCP Example

You will need both source code to plot ns2 simulations in this example.

Additionally we have to use these perl scripts to extract data from output trace generated from NS2.

I have written a shell script to do our job quickly.

Sample out put:
 



NS2 UDP Example

Previously I wrote a blog post about TCP example using NS2. In this post I am posting source code for UDP Example with NS2.

Source code:
Please follow the instruction mentioned in previous post to get output.

Sample screen of output:


Related posts:
http://beyondtechs.blogspot.com/2013/05/ns2-tcp-example.html

NS2 TCP Example

NS2 is a free but a powerful simulator. It is capable to simulate most of complex scenarios in wired and wireless networks.

How to install:
Get your teminal and type this
Then you'll need NAM

Source code:
How to run:
You may need to create outtcp.nam file in source code directory.

Sample screen of out put.



Related post:

http://beyondtechs.blogspot.com/2013/05/ns2-udp-example.html

Wednesday, March 6, 2013

Convert object into DataTable C#

Recently I got a requirement in a project to convert own type of object to DataTable. Here I am sharing my code with you.

Steps

1. Create datatable and give a name
2. Create Column Names
3. Create a Data Row
4. Add Data in to DataRow
5. Add DataRow to DataTable
Thats it...
Here some Extended Method to how to use this method
https://github.com/cbjpdev/DataTableX

Saturday, September 29, 2012

Unicast example in Contiki

Simple unicast example, Click button in each node to unicast message.

Please consider that this code is written for cooja simulator.

UniA.c for node 1
#include "contiki.h"
#include "net/rime.h"
#include "dev/button-sensor.h"
#include "dev/leds.h"
#include <stdio.h>

PROCESS(example_unicast_process, "Example unicast");
AUTOSTART_PROCESSES(&example_unicast_process);

static void
recv_uc(struct unicast_conn *c, const rimeaddr_t *from)
{
  printf("broadcast message received from %d.%d: '%s'\n",from->u8[0], from->u8[1], (char *)packetbuf_dataptr());
}

static const struct unicast_callbacks unicast_callbacks = {recv_uc};

static struct unicast_conn uc;

static void unicast_message()
{
    unicast_open(&uc, 146, &unicast_callbacks);

    rimeaddr_t addr;
    
    packetbuf_copyfrom("AAAAA", 5);
    addr.u8[0] = 2;
    addr.u8[1] = 0;
    if(!rimeaddr_cmp(&addr, &rimeaddr_node_addr))
    {
      unicast_send(&uc, &addr);
    }
}

PROCESS_THREAD(example_unicast_process, ev, data)
{
  PROCESS_EXITHANDLER(unicast_close(&uc);)
    
  PROCESS_BEGIN();
  
  while(1) {
    PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event && data == &button_sensor);
    unicast_message();
    printf("message sent.\n");
  }  
    
  PROCESS_END();
}

UniB.c for node2
#include "contiki.h"
#include "net/rime.h"
#include "dev/button-sensor.h"
#include "dev/leds.h"
#include <stdio.h>

PROCESS(example_unicast_process, "Example unicast");
AUTOSTART_PROCESSES(&example_unicast_process);

static void
recv_uc(struct unicast_conn *c, const rimeaddr_t *from)
{
  printf("broadcast message received from %d.%d: '%s'\n",from->u8[0], from->u8[1], (char *)packetbuf_dataptr());
}

static const struct unicast_callbacks unicast_callbacks = {recv_uc};

static struct unicast_conn uc;

static void unicast_message()
{
    unicast_open(&uc, 146, &unicast_callbacks);

    rimeaddr_t addr;
    
    packetbuf_copyfrom("BBBBB", 5);
    addr.u8[0] = 1;
    addr.u8[1] = 0;
    if(!rimeaddr_cmp(&addr, &rimeaddr_node_addr))
    {
      unicast_send(&uc, &addr);
    }
}

PROCESS_THREAD(example_unicast_process, ev, data)
{
  PROCESS_EXITHANDLER(unicast_close(&uc);)
    
  PROCESS_BEGIN();
  
  while(1) {
    PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event && data == &button_sensor);
    unicast_message();
    printf("message sent.\n");
  }  
    
  PROCESS_END();
}