Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - _moon

Pages: [1]
1
Java / Re: Question about java
« on: January 25, 2012, 12:44:43 am »
 @darkwolfzero :


I believe I have an example that may help you get started.


A few years ago, I had to code an implementation of an ad-hoc routing protocol (AODV) for a set of wireless sensors. These sensors were running TinyOS, an open source operating system written in a C variant called nesC (network embedded systems C). They were able to measure light, temperature and sound from external sensors, and used a tiny wifi antenna to transmit data packets.
Code: [Select]
http://www.cmt-gmbh.de/Produkte/WirelessSensorNetworks/MICAz_2.4_GHz.html

The actual challenge was the routing protocol, probably not very interesting to you. Nonetheless, to measure the effectiveness of the protocol, I had to be able to receive and display all the data sent by the sensors on a computer.


So, how would you do that ?


The first step was to code the sensor application using the proprietary language nesC. In my case, each node had to regularly retrieve external temperature, pressure, and luminosity from the sensor, and then send the information to the base station using the wifi antenna. They also served as relays for other nodes.


The sensors were programmed using an ethernet board like this one :
Code: [Select]
http://www.cmt-gmbh.de/Produkte/WirelessSensorNetworks/MIB600_Ethernet_Gateway.html

Finally, the data packet sent by the sensor looked like something like that :
Code: [Select]
typedef nx_struct Msg {
  nx_uint8_t id;     // emitting node id
  nx_uint8_t src;    // source node id
  nx_uint8_t dest;   // destination node id
  nx_uint8_t ttl;    // Time To Live
  [...]
  nx_uint16_t valL;  // luminosity sensor value
  nx_uint16_t valS;  //  sound sensor value
  nx_uint16_t valT;  //  temperature sensor value
} Msg;


Then, all I had to do was to write a Java application that could read such messages when listening to a specific port.
Code: [Select]
public Msg(byte[] data) {
  ...
}
...
public int getId() {
  return (int) funtionToGetContentFromByteArray(0, 8);
}


 I could then draw a map of sensors, display the local temperatures etc to my liking, and most importantly see how effective my protocol was just by looking at the packets.
 


This is a very simple example, but you can adapt to your use case. You'll probably have to write a Java class for sending/receiving packets with Bluetooth. You'll have to code different types of control messages, and since Bluetooth isn't restricted to your own device, you'll need a reliable way to check what you receive.


As for the device, well everything depends on what it is ! ;)

2
Java / Re: Question about java
« on: January 24, 2012, 10:50:46 pm »
Technically yes. Java can be used to program anything, as long as you have the resources to run the jvm, as ca0s said.


However, to use Java to program something like a microwave, you need a jvm that knows how to translate the java bytecode (compiled java classes) to the underlying hardware components.


There are many existing jvms, which goals vary from increased performance on specific processor architectures to reduced footprint. You can try to take a look at this page :
Code: [Select]
http://en.wikipedia.org/wiki/List_of_Java_virtual_machines



3
Java / Re: [Help] Java development
« on: January 24, 2012, 10:13:08 pm »
I wonder how you can say with such assurance which of Eclipse or Netbeans is the best.


Both are good, yet Netbeans is faster, lighter, richer, and much much more nicely coded than Eclipse. However, it falls far behind plugins-wise.


I've been working with Java for four years now and still use both, depending on the project and/or my needs ;)

4
C - C++ / Re: [C] Reverse a string
« on: January 13, 2012, 11:47:09 pm »
Thanks, nice topic.

5
Tutorials / Re: Hacking WEP with Backtrack4 Final and Airoscript
« on: January 12, 2012, 12:33:40 am »
aircrack-ng can can crack WPA using pre-shared key (PSK).


More information.

6
C - C++ / [C] Reverse a string
« on: January 12, 2012, 12:00:15 am »
I read an interesting article about Guerilla Interview this afternoon.. Which prompted me to check if I could still write some half-decent C, like reversing linked lists or detecting loops in a tree, as mentioned in this article.


That didn't go that well :] Anyway, at some point I stumbled upon a nice string reversing function. Some of you may find it interesting.


Code: [Select]
char* rev(char* str) {
        int end = strlen(str) - 1;
        int start = 0;

        while (start < end) {

                str[start] ^= str[end];
                str[end] ^= str[start];
                str[start] ^= str[end];

                ++start;
                --end;

        }

        return str;
}


The logic behind this being :
Quote
Let A = x and B = y.

 So,
 A = A XOR B
   then A = x XOR y
             B = y
 B = A XOR B
   then A = x XOR y
             B = (x XOR y) XOR y
                 = x XOR (y XOR y)
                 = x
 A = A XOR B
   then A = (x XOR y) XOR x
               = (y XOR x) XOR x
               = y XOR (x XOR x)
               = y

 now B = x and A = y

Source: http://discuss.fogcreek.com/techInterview/default.asp?cmd=show&ixPost=2077

7
Members introduction / Hello
« on: January 06, 2012, 06:26:14 pm »

Not much to say.. I stumbled upon this site a few weeks ago when looking for information on nmap, so I could secure my home network..

I figured I could afford the effort to register and say hello since I kept lurking around. Best registration form I ever saw btw, simple & efficient :)


See you on the boards.





Pages: [1]


Intern0t SoldierX SecurityOverride programisiai
Want to be here? Contact Ande, Bluechill or Kulverstukas on the forum or at IRC.