1 /* Copyright (c) 2006-2007, 2012-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. */
7 package trace.pingpong;
8 import org.simgrid.msg.Host;
9 import org.simgrid.msg.Msg;
10 import org.simgrid.msg.MsgException;
11 import org.simgrid.msg.NativeException;
12 import org.simgrid.msg.HostNotFoundException;
13 import org.simgrid.msg.Task;
14 import org.simgrid.msg.Process;
15 import org.simgrid.trace.Trace;
17 public class Receiver extends Process {
18 private final double commSizeLat = 1;
19 private final double commSizeBw = 100000000;
21 public Receiver(String hostname, String name, String[]args) throws HostNotFoundException, NativeException{
22 super(hostname,name,args);
25 public void main(String[] args) throws MsgException {
27 Trace.hostPushState (getHost().getName(), "PM_STATE", "waitingPing");
29 /* Wait for the ping */
30 Msg.info("try to get a task");
32 PingPongTask ping = (PingPongTask)Task.receive(getHost().getName());
33 double timeGot = Msg.getClock();
34 double timeSent = ping.getTime();
36 Msg.info("Got at time "+ timeGot);
37 Msg.info("Was sent at time "+timeSent);
40 double communicationTime=timeGot - time;
41 Msg.info("Communication time : " + communicationTime);
43 Msg.info(" --- bw "+ commSizeBw/communicationTime + " ----");
46 Trace.hostPushState (getHost().getName(), "PM_STATE", "sendingPong");
47 double computeDuration = 0;
48 PingPongTask pong = new PingPongTask("no name",computeDuration,commSizeLat);
50 pong.send(ping.getSource().getName());
52 /* Pop the two states */
53 Trace.hostPopState (getHost().getName(), "PM_STATE");
54 Trace.hostPopState (getHost().getName(), "PM_STATE");