logo.png

Operating systems :
WINDOWS
FEDORA
SCIENTIFIC LINUX
DEBIAN

SWITCH

Tools:
CVS
TCPDUMP
NETCAT
NETBEANS
JAR
APPLET

Home Up


Contents


netcat is a more performant telnet application:

  • it allow to use UDP transport layer.
  • it allow to capture response without using sleep (but we don't need it here).


1 Listenning and sending

There are two differents implémentation under RED-HAT and DEBIAN families.

  • using FEDORA:
    $ nc -u -l 1235
                                        $ nc -u 127.0.0.1 1235 
                                        coucou
    coucou
    
  • using DEBIAN:
    $ nc -u -l -p 1235
                                        $ nc -u 127.0.0.1 1235 
                                        coucou
    coucou
    


2 Sending and receiving bytes

$ nc -u -l 1235 < hexaQuery
                                    $ nc -u 127.0.0.1 1235 > hexaResponse


2.1 Building an hexa file

  • We first have to build an empty file:
    $ dd if=/dev/zero of=/hexaQuery bs=4 count=4
    
    We use data block of 32 bits.

  • Next we have to edit it:
    $ hexedit hexaQuery 
    ^Q
    (or)
    $ hexcurse hexaQuery
    ^S ^Q
    
    As Java is using big-endian and PC little-endian, we have to translate each 4 bytes as : abcd => dcba.
    IE: 67 45 23 01 should be translate as 01 23 45 67.


2.2 Reading an hexa file

$ hexdump hexaResponse
Warning: on PC, hexdump and tcpdump permute each block of 2 bytes (I don't know why). IE: 23 01 67 45 should be translate as 01 23 45 67.


3 Testing the GEDEK

Please consider this code: there is only 5 register working on the 256 allowed ?!

$ ./go
] Monitoring UDP Port 0x04d3 for registers
reg 0x00: OK
reg 0x01: OK
reg 0x02: OK
reg 0x42: OK
reg 0xff: OK
] Done !

  • Capture the NECTAR outputs:
    $ nc -u -l 1234 > outData
    

  • (todo) Sending NECTAR order:
    $ nc -u 192.168.1.18 1234 < inOrder
    

  • Updating GEDEK virtuals registers:
    Build the inRegister query file with these bytes:
    00 FF 08 01 78 56 34 12
    $ nc -u 1235 < putRegister
    

  • Reading GEDEK virtuals registers:
    Build the inRegister query file with these bytes:
    00 FF 04 01
                                     $ nc -u -l 1235 > outData
    $ nc -u -l 1235 < getRegister
                                     $ hexdump outData
                                      0000 0104 3412 7856
    

Home Up

This document is also available in PDF and PostScript format.



2016-02-15