1 /* Copyright (c) 2006-2014, 2016. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
8 import org.simgrid.msg.Msg;
9 import org.simgrid.msg.Host;
10 import org.simgrid.msg.Task;
11 import org.simgrid.msg.Process;
12 import org.simgrid.msg.MsgException;
13 import org.simgrid.msg.HostNotFoundException;
14 import org.simgrid.trace.Trace;
16 public class Sender extends Process {
17 private final double commSizeLat = 1;
18 private final double commSizeBw = 100000000;
20 public Sender(Host host, String name, String[] args) {
21 super(host,name,args);
24 public void main(String[] args) throws MsgException {
26 Trace.hostPushState (getHost().getName(), "PM_STATE", "sendingPing");
28 int hostCount = args.length;
29 Msg.info("host count: " + hostCount);
30 String mailboxes[] = new String[hostCount];
32 double computeDuration = 0;
33 PingPongTask ping, pong;
35 for(int pos = 0; pos < args.length ; pos++) {
37 mailboxes[pos] = Host.getByName(args[pos]).getName();
38 } catch (HostNotFoundException e) {
39 Msg.info("Invalid deployment file: " + e.toString());
44 for (int pos = 0; pos < hostCount; pos++) {
45 time = Msg.getClock();
46 Msg.info("sender time: " + time);
47 ping = new PingPongTask("no name",computeDuration,commSizeLat);
49 ping.send(mailboxes[pos]);
51 Trace.hostPushState (getHost().getName(), "PM_STATE", "waitingPong");
52 pong = (PingPongTask)Task.receive(getHost().getName());
53 double timeGot = Msg.getClock();
54 double timeSent = ping.getTime();
55 double communicationTime=0;
57 Msg.info("Got at time "+ timeGot);
58 Msg.info("Was sent at time "+timeSent);
61 communicationTime=timeGot - time;
62 Msg.info("Communication time : " + communicationTime);
64 Msg.info(" --- bw "+ commSizeBw/communicationTime + " ----");
66 /* Pop the last state (going back to sending ping) */
67 Trace.hostPopState (getHost().getName(), "PM_STATE");
70 /* Pop the sendingPong state */
71 Trace.hostPopState (getHost().getName(), "PM_STATE");