logo.png

Tests
Log
Gui
In/Out

UDP sockets
XML configuration
JAIDA data analysis

Home Up


Contents



1 Include

UDP are include in the JAVA languages classes :

import java.net.*;


2 ICMP client

ICMP ECHO REQUESTs is used if the privilege can be obtained, otherwise it will try to establish a TCP connection on port 7 (Echo) of the destination host.
String host;
boolean status;
status = InetAddress.getByName(host).isReachable(timeOut);
comments: the GEDEX wait for an ICMP ECHO REQUEST in order to set the internals registers @2 (Destination MAC Address (32 LSB)), @3 (Destination MAC Address (16 MSB)) and @4 (Destination IP Address).


3 UDP client

String          host;
int             port;
byte[]          buffer = new byte[1024];
InetAddress     address = InetAddress.getByName(host);
DatagramSocket  socket = new DatagramSocket();
DatagramPacket  packet = new DatagramPacket(buffer, buffer.length, address, port);

socket.send(packet);
socket.close();


4 UDP server

String          host;
int             port;
byte[]          buffer = new byte[1024];

DatagramSocket serverSocket = new DatagramSocket(port);

while(1) {
   DatagramPacket serverPacket = new DatagramPacket(buffer, buffer.length);
   serverSocket.receive(serverPacket);
}

serverSocket.close();

Home Up

This document is also available in PDF and PostScript format.



2016-02-15