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.Msg;
9 import org.simgrid.msg.MsgException;
10 import org.simgrid.msg.NativeException;
11 import org.simgrid.msg.HostNotFoundException;
12 import org.simgrid.msg.Task;
13 import org.simgrid.msg.Process;
14 import org.simgrid.trace.Trace;
16 public class Receiver extends Process {
17 private static final double commSizeLat = 1;
18 private static final double commSizeBw = 100000000;
20 public Receiver(String hostname, String name, String[]args) throws HostNotFoundException, NativeException{
21 super(hostname,name,args);
24 public void main(String[] args) throws MsgException {
26 Trace.hostPushState (getHost().getName(), "PM_STATE", "waitingPing");
28 /* Wait for the ping */
29 Msg.info("try to get a task");
31 PingPongTask ping = (PingPongTask)Task.receive(getHost().getName());
32 double timeGot = Msg.getClock();
33 double timeSent = ping.getTime();
35 Msg.info("Got at time "+ timeGot);
36 Msg.info("Was sent at time "+timeSent);
39 double communicationTime=timeGot - time;
40 Msg.info("Communication time : " + communicationTime);
42 Msg.info(" --- bw "+ commSizeBw/communicationTime + " ----");
45 Trace.hostPushState (getHost().getName(), "PM_STATE", "sendingPong");
46 double computeDuration = 0;
47 PingPongTask pong = new PingPongTask("no name",computeDuration,commSizeLat);
49 pong.send(ping.getSource().getName());
51 /* Pop the two states */
52 Trace.hostPopState (getHost().getName(), "PM_STATE");
53 Trace.hostPopState (getHost().getName(), "PM_STATE");