Skip to content
Snippets Groups Projects
Commit 02847697 authored by brutzman's avatar brutzman
Browse files

finish all tests, avoid duplicate sends when synonyms created

parent 81a67e34
No related branches found
No related tags found
No related merge requests found
package OpenDis7Examples; package OpenDis7Examples;
import java.io.*; import java.io.*;
import java.net.*; import java.net.*;
import java.util.*; import java.util.*;
import edu.nps.moves.dis7.*; import edu.nps.moves.dis7.*;
import edu.nps.moves.dis7.enumerations.*; import edu.nps.moves.dis7.enumerations.*;
/** /**
* This is an example that sends many/most types of PDUs. Useful for testing standards * This is an example that sends many/most types of PDUs. Useful for testing standards
* compliance or getting a full set of PDUs. It also writes the generated PDUs to an XML file. * compliance or getting a full set of PDUs. It also writes the generated PDUs to an XML file.
* Adapted from OpenDIS library example package edu.nps.moves.examples * Adapted from OpenDIS library example package edu.nps.moves.examples
* *
* @author DMcG * @author DMcG
* @version $Id:$ * @version $Id:$
*/ */
public class PduSender public class PduSender
{ {
/** Default multicast group address we send on. */ /** Default multicast group address we send on. */
public static final String DEFAULT_MULTICAST_ADDRESS = "239.1.2.3"; public static final String DEFAULT_MULTICAST_ADDRESS = "239.1.2.3";
/** Default multicast port used, matches Wireshark DIS capture default */ /** Default multicast port used, matches Wireshark DIS capture default */
public static final int DEFAULT_MULTICAST_PORT = 3000; public static final int DEFAULT_MULTICAST_PORT = 3000;
private int port; private int port;
InetAddress multicastAddress; InetAddress multicastAddress;
public PduSender(int port, String multicast) { public PduSender(int port, String multicast) {
try try
{ {
this.port = port; this.port = port;
multicastAddress = InetAddress.getByName(multicast); multicastAddress = InetAddress.getByName(multicast);
if (!multicastAddress.isMulticastAddress()) if (!multicastAddress.isMulticastAddress())
{ {
System.out.println("Not a multicast address: " + multicast); System.out.println("Not a multicast address: " + multicast);
} }
} }
catch (UnknownHostException e) { catch (UnknownHostException e) {
System.out.println("Unable to open socket: " + e); System.out.println("Unable to open socket: " + e);
} }
} }
public void run() public void run()
{ {
System.out.println("DisExamplesOpenDis7.PduSender started..."); System.out.println("DisExamplesOpenDis7.PduSender started...");
try { try
List<Pdu> generatedPdusList = new ArrayList<>(); {
System.out.println("Generate PDUs and note issues (if any)...");
// Loop through all the enumerated PDU types, create a PDU for each type, List<Pdu> generatedPdusList = new ArrayList<>();
// add that PDU to generatedPdusList, and send each one
for (DISPDUType pdu : DISPDUType.values()) // Loop through all the enumerated PDU types, create a PDU for each type,
{ // add that PDU to generatedPdusList, and send each one
// System.out.println("PDU " + pdu.getValue() + " " + pdu.name() + " " + pdu.getDescription()); // diagnostic for (DISPDUType pdu : DISPDUType.values())
{
Pdu aPdu = null; // edu.​nps.​moves7.​dis.PDU superclass for all PDUs, in preparation for custom assignment // System.out.println("PDU " + pdu.getValue() + " " + pdu.name() + " " + pdu.getDescription()); // diagnostic
try { Pdu aPdu = null; // edu.​nps.​moves7.​dis.PDU superclass for all PDUs, in preparation for custom assignment
switch (pdu) // using enumeration values from edu.​nps.​moves.​dis7.​enumerations.​DISPDUType
{ try {
case OTHER: // 0 switch (pdu) // using enumeration values from edu.​nps.​moves.​dis7.​enumerations.​DISPDUType
System.out.println ("DISPDUType." + pdu.name() + " not supported"); // TODO explain {
break; case OTHER: // 0
System.out.println ("*** Note: DISPDUType." + pdu.name() + " not supported"); // TODO explain
case ENTITY_STATE: //1 // nothing to send
aPdu = new EntityStatePdu(); break;
EntityStatePdu espdu = (EntityStatePdu) aPdu; case ENTITY_STATE: //1
EntityMarking entityMarking = new EntityMarking (); aPdu = new EntityStatePdu();
entityMarking.setCharacters("PduSender".getBytes()); //entityMarking.setCharacters(Byte.valueOf("0")); // 11 characters max?
EntityStatePdu espdu = (EntityStatePdu) aPdu;
espdu.setMarking(entityMarking); EntityMarking entityMarking = new EntityMarking ();
Vector3Double espduLocation = new Vector3Double(); entityMarking.setCharacters("PduSender".getBytes()); //entityMarking.setCharacters(Byte.valueOf("0")); // 11 characters max?
espduLocation.setX(1.0);
espduLocation.setY(2.0); espdu.setMarking(entityMarking);
espduLocation.setZ(3.0); Vector3Double espduLocation = new Vector3Double();
espdu.setEntityLocation(espduLocation); espduLocation.setX(1.0);
// it is important to identify questions as you think of them espduLocation.setY(2.0);
// TODO how to set azimuth, i.e. course direction over ground? espduLocation.setZ(3.0);
break; espdu.setEntityLocation(espduLocation);
// it is important to identify questions as you think of them
case FIRE: // 2 // TODO how to set azimuth, i.e. course direction over ground?
aPdu = new FirePdu(); break;
break;
case FIRE: // 2
case DETONATION: // 3 aPdu = new FirePdu();
aPdu = new DetonationPdu(); break;
break;
case DETONATION: // 3
case COLLISION: // 4 aPdu = new DetonationPdu();
aPdu = new CollisionPdu(); break;
break;
case COLLISION: // 4
case SERVICE_REQUEST: // 5 aPdu = new CollisionPdu();
aPdu = new ServiceRequestPdu(); break;
break;
case SERVICE_REQUEST: // 5
case RESUPPLY_OFFER: // 6 aPdu = new ServiceRequestPdu();
aPdu = new ResupplyOfferPdu(); break;
break;
case RESUPPLY_OFFER: // 6
case RESUPPLY_RECEIVED: // 7 aPdu = new ResupplyOfferPdu();
aPdu = new ResupplyReceivedPdu(); break;
break;
case RESUPPLY_RECEIVED: // 7
case RESUPPLY_CANCEL: //8 aPdu = new ResupplyReceivedPdu();
System.out.println ("DISPDUType." + pdu.name() + " not supported, throws exception"); break;
// aPdu = new ResupplyCancelPdu(); // TODO exception
break; case RESUPPLY_CANCEL: //8
aPdu = new ResupplyCancelPdu();
case REPAIR_COMPLETE: // 9 break;
aPdu = new RepairCompletePdu();
break; case REPAIR_COMPLETE: // 9
aPdu = new RepairCompletePdu();
case REPAIR_RESPONSE: // 10 break;
aPdu = new RepairResponsePdu();
break; case REPAIR_RESPONSE: // 10
aPdu = new RepairResponsePdu();
case CREATE_ENTITY: // 11 break;
aPdu = new CreateEntityPdu();
break; case CREATE_ENTITY: // 11
aPdu = new CreateEntityPdu();
case REMOVE_ENTITY: // 12 break;
aPdu = new RemoveEntityPdu();
break; case REMOVE_ENTITY: // 12
aPdu = new RemoveEntityPdu();
case START_RESUME: // 13 break;
aPdu = new StartResumePdu();
break; case START_RESUME: // 13
aPdu = new StartResumePdu();
case STOP_FREEZE: // 14 break;
aPdu = new StopFreezePdu();
break; case STOP_FREEZE: // 14
aPdu = new StopFreezePdu();
case ACKNOWLEDGE: // 15 break;
aPdu = new AcknowledgePdu();
break; case ACKNOWLEDGE: // 15
aPdu = new AcknowledgePdu();
case ACTION_REQUEST: // 16 break;
aPdu = new ActionRequestPdu();
break; case ACTION_REQUEST: // 16
aPdu = new ActionRequestPdu();
case ACTION_RESPONSE: // 17 break;
aPdu = new ActionResponsePdu();
break; case ACTION_RESPONSE: // 17
aPdu = new ActionResponsePdu();
case DATA_QUERY: // 18 break;
aPdu = new DataQueryPdu();
break; case DATA_QUERY: // 18
aPdu = new DataQueryPdu();
case SET_DATA: // 19 break;
aPdu = new SetDataPdu();
break; case SET_DATA: // 19
aPdu = new SetDataPdu();
case DATA: // 20 break;
aPdu = new DataPdu();
break; case DATA: // 20
aPdu = new DataPdu();
case EVENT_REPORT: // 21 break;
aPdu = new EventReportPdu();
break; case EVENT_REPORT: // 21
aPdu = new EventReportPdu();
case ELECTROMAGNETIC_EMISSION: // 23 break;
aPdu = new ElectromagneticEmissionPdu();
break; case ELECTROMAGNETIC_EMISSION: // 23
aPdu = new ElectromagneticEmissionPdu();
case DESIGNATOR: // 24 break;
aPdu = new DesignatorPdu();
break; case DESIGNATOR: // 24
aPdu = new DesignatorPdu();
case TRANSMITTER: // 25 break;
aPdu = new TransmitterPdu();
break; case TRANSMITTER: // 25
aPdu = new TransmitterPdu();
case SIGNAL: // 26 break;
aPdu = new SignalPdu();
break; case SIGNAL: // 26
aPdu = new SignalPdu();
case RECEIVER: // 27 break;
aPdu = new ReceiverPdu();
break; case RECEIVER: // 27
aPdu = new ReceiverPdu();
case IFF: // 28 break;
aPdu = new IFFPdu();
break; case IDENTIFICATION_FRIEND_OR_FOE: // 28
aPdu = new IdentificationFriendOrFoePdu();
case UNDERWATER_ACOUSTIC: // 29 break;
aPdu = new UnderwaterAcousticPdu(); case IFF: // 28
break; // aPdu = new IFFPdu(); // ignore, avoid sending duplicate
break;
case SUPPLEMENTAL_EMISSION_ENTITY_STATE: // 30
aPdu = new SEESPdu(); case UNDERWATER_ACOUSTIC: // 29
break; aPdu = new UnderwaterAcousticPdu();
break;
case INTERCOM_SIGNAL: // 31
aPdu = new IntercomSignalPdu(); case SUPPLEMENTAL_EMISSION_ENTITY_STATE: // 30
break; aPdu = new SupplementalEmissionEntityStatePdu();
break;
case INTERCOM_CONTROL: // 32
aPdu = new IntercomControlPdu(); case SEES: // 30
break; // aPdu = new SEESPdu(); // ignore, avoid sending duplicate
break;
case AGGREGATE_STATE: // 33
aPdu = new AggregateStatePdu(); case INTERCOM_SIGNAL: // 31
break; aPdu = new IntercomSignalPdu();
break;
case ISGROUPOF: // 34
aPdu = new IsGroupOfPdu(); case INTERCOM_CONTROL: // 32
break; aPdu = new IntercomControlPdu();
break;
case TRANSFER_OWNERSHIP: // 35
aPdu = new TransferOwnershipPdu(); case AGGREGATE_STATE: // 33
break; aPdu = new AggregateStatePdu();
break;
case ISPARTOF: // 36
aPdu = new IsPartOfPdu(); case ISGROUPOF: // 34
break; aPdu = new IsGroupOfPdu();
break;
case MINEFIELD_STATE: // 37
aPdu = new MinefieldStatePdu(); case TRANSFER_OWNERSHIP: // 35
break; aPdu = new TransferOwnershipPdu();
break;
case MINEFIELD_QUERY: // 38
aPdu = new MinefieldQueryPdu(); case ISPARTOF: // 36
break; aPdu = new IsPartOfPdu();
break;
case MINEFIELD_DATA: // 39
aPdu = new MinefieldDataPdu(); case MINEFIELD_STATE: // 37
break; aPdu = new MinefieldStatePdu();
break;
case MINEFIELD_RESPONSE_NACK: // 40
aPdu = new MinefieldResponseNACKPdu(); case MINEFIELD_QUERY: // 38
break; aPdu = new MinefieldQueryPdu();
break;
case ENVIRONMENTAL_PROCESS: // 41
aPdu = new EnvironmentalProcessPdu(); case MINEFIELD_DATA: // 39
break; aPdu = new MinefieldDataPdu();
break;
case GRIDDED_DATA: // 42
aPdu = new GriddedDataPdu(); case MINEFIELD_RESPONSE_NACK: // 40
break; aPdu = new MinefieldResponseNACKPdu();
break;
case POINT_OBJECT_STATE: // 43
aPdu = new PointObjectStatePdu(); case ENVIRONMENTAL_PROCESS: // 41
break; aPdu = new EnvironmentalProcessPdu();
break;
case LINEAR_OBJECT_STATE: // 44
aPdu = new LinearObjectStatePdu(); case GRIDDED_DATA: // 42
break; aPdu = new GriddedDataPdu();
break;
case AREAL_OBJECT_STATE: // 45
aPdu = new ArealObjectStatePdu(); case POINT_OBJECT_STATE: // 43
break; aPdu = new PointObjectStatePdu();
break;
case TSPI: // 46
aPdu = new TSPIPdu(); case LINEAR_OBJECT_STATE: // 44
break; aPdu = new LinearObjectStatePdu();
break;
case APPEARANCE: // 47
aPdu = new AppearancePdu(); case AREAL_OBJECT_STATE: // 45
break; aPdu = new ArealObjectStatePdu();
break;
case ARTICULATED_PARTS: // 48
aPdu = new ArticulatedPartsPdu(); case TIME_SPACE_POSITION_INFORMATION: // 46
break; aPdu = new TimeSpacePositionInformationPdu();
break;
case LE_FIRE: // 49 case TSPI: // 46
aPdu = new LEFirePdu(); // aPdu = new TSPIPdu(); // ignore, avoid sending duplicate
break; break;
case LE_DETONATION: // 50 case APPEARANCE: // 47
aPdu = new LEDetonationPdu(); aPdu = new AppearancePdu();
break; break;
case CREATE_ENTITY_R: // 51 case ARTICULATED_PARTS: // 48
aPdu = new CreateEntityReliablePdu(); aPdu = new ArticulatedPartsPdu();
break; break;
case REMOVE_ENTITY_R: // 52 case LIVE_ENTITY_FIRE: // 49
aPdu = new RemoveEntityReliablePdu(); aPdu = new LiveEntityFirePdu();
break; break;
case LE_FIRE: // 49
case START_RESUME_R: // 53 // aPdu = new LEFirePdu(); // ignore, avoid sending duplicate
aPdu = new StartResumeReliablePdu(); break;
break;
case LIVE_ENTITY_DETONATION: // 50
case STOP_FREEZE_R: // 54 aPdu = new LiveEntityDetonationPdu();
aPdu = new StopFreezeReliablePdu(); break;
break; case LE_DETONATION: // 50
// aPdu = new LEDetonationPdu(); // ignore, avoid sending duplicate
case ACKNOWLEDGE_R: // 55 break;
aPdu = new AcknowledgeReliablePdu();
break; case CREATE_ENTITY_RELIABLE: // 51
aPdu = new CreateEntityReliablePdu();
case ACTION_REQUEST_R: // 56 break;
aPdu = new ActionRequestReliablePdu(); case CREATE_ENTITY_R: // 51
break; // aPdu = new CreateEntityRPdu(); // ignore, avoid sending duplicate
break;
case ACTION_RESPONSE_R: // 57
aPdu = new ActionResponseReliablePdu(); case REMOVE_ENTITY_RELIABLE: // 52
break; aPdu = new RemoveEntityReliablePdu();
break;
case DATA_QUERY_R: // 58 case REMOVE_ENTITY_R: // 52
aPdu = new DataQueryReliablePdu(); // aPdu = new RemoveEntityRPdu(); // ignore, avoid sending duplicate
break; break;
case SET_DATA_R: // 59 case START_RESUME_RELIABLE: // 53
aPdu = new SetDataReliablePdu(); aPdu = new StartResumeReliablePdu();
break; break;
case START_RESUME_R: // 53
case DATA_R: // 60 // aPdu = new StartResumeRPdu(); // ignore, avoid sending duplicate
aPdu = new DataReliablePdu(); break;
break;
case STOP_FREEZE_RELIABLE: // 54
case EVENT_REPORT_R: // 61 aPdu = new StopFreezeReliablePdu();
aPdu = new EventReportReliablePdu(); break;
break; case STOP_FREEZE_R: // 54
// aPdu = new StopFreezeRPdu(); // ignore, avoid sending duplicate
case COMMENT_R: // 62 break;
aPdu = new CommentReliablePdu();
break; case ACKNOWLEDGE_RELIABLE: // 55
aPdu = new AcknowledgeReliablePdu();
case RECORD_R: // 63 break;
aPdu = new RecordReliablePdu(); case ACKNOWLEDGE_R: // 55
break; // aPdu = new AcknowledgeRPdu(); // ignore, avoid sending duplicate
break;
case SET_RECORD_R: // 64
aPdu = new SetRecordReliablePdu(); case ACTION_REQUEST_RELIABLE: // 56
break; aPdu = new ActionRequestReliablePdu();
break;
case RECORD_QUERY_R: // 65 case ACTION_REQUEST_R: // 56
aPdu = new RecordQueryReliablePdu(); // aPdu = new ActionRequestRPdu(); // ignore, avoid sending duplicate
break; break;
case COLLISION_ELASTIC: // 66 case ACTION_RESPONSE_RELIABLE: // 57
aPdu = new CollisionElasticPdu(); aPdu = new ActionResponseReliablePdu();
break; break;
case ACTION_RESPONSE_R: // 57
case ENTITY_STATE_UPDATE: // 67 // aPdu = new ActionResponseRPdu(); // ignore, avoid sending duplicate
aPdu = new EntityStateUpdatePdu(); break;
break;
case DATA_QUERY_RELIABLE: // 58
case DIRECTED_ENERGY_FIRE: // 68 aPdu = new DataQueryReliablePdu();
aPdu = new DirectedEnergyFirePdu(); break;
break; case DATA_QUERY_R: // 58
// aPdu = new DataQueryRPdu(); // ignore, avoid sending duplicate
case ENTITY_DAMAGE_STATUS: // 69 break;
aPdu = new EntityDamageStatusPdu();
break; case SET_DATA_RELIABLE: // 59
aPdu = new SetDataReliablePdu();
case INFORMATION_OPERATIONS_ACTION: // 70 break;
aPdu = new InformationOperationsActionPdu(); case SET_DATA_R: // 59
break; // aPdu = new SetDataRPdu(); // ignore, avoid sending duplicate
break;
case INFORMATION_OPERATIONS_REPORT: // 71
aPdu = new InformationOperationsReportPdu(); case DATA_RELIABLE: // 60
break; aPdu = new DataReliablePdu();
break;
case ATTRIBUTE: // 72 case DATA_R: // 60
aPdu = new AttributePdu(); // aPdu = new DataRPdu(); // ignore, avoid sending duplicate
break; break;
case COMMENT: case EVENT_REPORT_RELIABLE: // 61
aPdu = new CommentPdu(); aPdu = new EventReportReliablePdu();
CommentPdu newCommentPdu = (CommentPdu)aPdu; break;
VariableDatum newVariableDatum = new VariableDatum(); case EVENT_REPORT_R: // 61
// etc. see Garrett and Pete's code // aPdu = new EventReportRPdu(); // ignore, avoid sending duplicate
break; break;
default: case COMMENT_RELIABLE: // 62
System.out.print("PDU " + pdu.getValue() + " " + pdu + " not supported, created or sent "); aPdu = new CommentReliablePdu();
break;
// code generation block for this class follow: case COMMENT_R: // 62
// System.out.println(" case " + pdu + ": // " + pdu.getValue()); // aPdu = new CommentRPdu(); // ignore, avoid sending duplicate
// System.out.println(" aPdu = new " + pdu.getDescription().replace(" ","").replace("-","").replace("/","") + break;
// "Pdu();");
// System.out.println(" break;"); case RECORD_RELIABLE: // 63
// System.out.println(); aPdu = new RecordReliablePdu();
} break;
if (aPdu != null) case RECORD_R: // 63
{ // aPdu = new RecordRPdu(); // ignore, avoid sending duplicate
generatedPdusList.add(aPdu); break;
}
} case SET_RECORD_RELIABLE: // 64
catch (Exception e) aPdu = new SetRecordReliablePdu();
{ break;
System.out.print("Exception thrown for PDU " + pdu.getValue() + " " + pdu); case SET_RECORD_R: // 64
System.out.print(Arrays.toString(e.getStackTrace())); // aPdu = new SetRecordRPdu(); // ignore, avoid sending duplicate
// continue looping break;
}
} case RECORD_QUERY_RELIABLE: // 65
System.out.println("Send the " + generatedPdusList.size() + " PDUs we created..."); aPdu = new RecordQueryReliablePdu();
break;
// Send the PDUs we created case RECORD_QUERY_R: // 65
InetAddress localMulticastAddress = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS); // aPdu = new RecordQueryRPdu(); // ignore, avoid sending duplicate
MulticastSocket socket = new MulticastSocket(DEFAULT_MULTICAST_PORT); break;
socket.joinGroup(localMulticastAddress);
case COLLISION_ELASTIC: // 66
for (int idx = 0; idx < generatedPdusList.size(); idx++) aPdu = new CollisionElasticPdu();
{ break;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos); case ENTITY_STATE_UPDATE: // 67
byte[] buffer; aPdu = new EntityStateUpdatePdu();
break;
Pdu aPdu = generatedPdusList.get(idx);
aPdu.marshal(dos); case DIRECTED_ENERGY_FIRE: // 68
aPdu = new DirectedEnergyFirePdu();
buffer = baos.toByteArray(); break;
DatagramPacket packet = new DatagramPacket(buffer, buffer.length, localMulticastAddress, DEFAULT_MULTICAST_PORT);
socket.send(packet); case ENTITY_DAMAGE_STATUS: // 69
System.out.println("Sent PDU of type " + aPdu.getClass().getName()); aPdu = new EntityDamageStatusPdu();
} break;
// write the PDUs out to an XML file.
//PduContainer container = new PduContainer(); case INFORMATION_OPERATIONS_ACTION: // 70
//container.setPdus(generatedPdus); aPdu = new InformationOperationsActionPdu();
//container.marshallToXml("examplePdus.xml"); break;
}
catch (IOException e) case INFORMATION_OPERATIONS_REPORT: // 71
{ aPdu = new InformationOperationsReportPdu();
System.out.println(e); break;
}
} case ATTRIBUTE: // 72
aPdu = new AttributePdu();
public static void main(String args[]) break;
{
if (args.length == 2) case COMMENT:
{ aPdu = new CommentPdu();
PduSender sender = new PduSender(Integer.parseInt(args[0]), args[1]); CommentPdu newCommentPdu = (CommentPdu)aPdu;
sender.run(); VariableDatum newVariableDatum = new VariableDatum();
} // etc. see Garrett and Pete's code
else break;
{
System.out.println("Usage: PduSender <port> <multicast group>"); default:
System.out.println("Default: PduSender " + DEFAULT_MULTICAST_PORT + " " + DEFAULT_MULTICAST_ADDRESS); System.out.println("*** Warning: PDU " + pdu.getValue() + " " + pdu + " not supported, created or sent ");
PduSender sender = new PduSender(DEFAULT_MULTICAST_PORT, DEFAULT_MULTICAST_ADDRESS);
sender.run(); // code generation block for this class follows:
} // System.out.println(" case " + pdu + ": // " + pdu.getValue());
} // System.out.println(" aPdu = new " + pdu.getDescription().replace(" ","").replace("-","").replace("/","") +
} // "Pdu();");
// System.out.println(" break;");
// System.out.println();
}
if (aPdu != null)
{
generatedPdusList.add(aPdu);
}
}
catch (Exception e)
{
System.out.print("Exception thrown for PDU " + pdu.getValue() + " " + pdu);
System.out.print(Arrays.toString(e.getStackTrace()));
// continue looping
}
}
// Send the PDUs we created
System.out.println("Send the " + generatedPdusList.size() + " PDUs we created...");
InetAddress localMulticastAddress = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS);
MulticastSocket socket = new MulticastSocket(DEFAULT_MULTICAST_PORT);
socket.joinGroup(localMulticastAddress);
for (int idx = 0; idx < generatedPdusList.size(); idx++)
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
byte[] buffer;
Pdu aPdu = generatedPdusList.get(idx);
aPdu.marshal(dos);
buffer = baos.toByteArray();
DatagramPacket packet = new DatagramPacket(buffer, buffer.length, localMulticastAddress, DEFAULT_MULTICAST_PORT);
socket.send(packet);
System.out.println("Sent PDU " + aPdu.getPduType().getValue() + " " + aPdu.getPduType() + " of type " + aPdu.getClass().getName());
}
// write the PDUs out to an XML file.
//PduContainer container = new PduContainer();
//container.setPdus(generatedPdus);
//container.marshallToXml("examplePdus.xml");
}
catch (IOException e)
{
System.out.println(e);
}
}
public static void main(String args[])
{
if (args.length == 2)
{
PduSender sender = new PduSender(Integer.parseInt(args[0]), args[1]);
sender.run();
}
else
{
System.out.println("Usage: PduSender <port> <multicast group>");
System.out.println("Default: PduSender " + DEFAULT_MULTICAST_PORT + " " + DEFAULT_MULTICAST_ADDRESS);
PduSender sender = new PduSender(DEFAULT_MULTICAST_PORT, DEFAULT_MULTICAST_ADDRESS);
sender.run();
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment