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.HostNotFoundException;
9 import org.simgrid.msg.Msg;
10 import org.simgrid.msg.MsgException;
11 import org.simgrid.msg.Process;
12 import org.simgrid.msg.Task;
13 import org.simgrid.trace.Trace;
15 public class Receiver extends Process {
16 private static final double COMM_SIZE_LAT = 1;
17 private static final double COMM_SIZE_BW = 100000000;
19 public Receiver(String hostname, String name, String[]args) throws HostNotFoundException {
20 super(hostname,name,args);
23 public void main(String[] args) throws MsgException {
25 Trace.hostPushState (getHost().getName(), "PM_STATE", "waitingPing");
27 /* Wait for the ping */
28 Msg.info("try to get a task");
30 PingPongTask ping = (PingPongTask)Task.receive(getHost().getName());
31 double timeGot = Msg.getClock();
32 double timeSent = ping.getTime();
34 Msg.info("Got at time "+ timeGot);
35 Msg.info("Was sent at time "+timeSent);
38 double communicationTime=timeGot - time;
39 Msg.info("Communication time : " + communicationTime);
41 Msg.info(" --- bw "+ COMM_SIZE_BW/communicationTime + " ----");
44 Trace.hostPushState (getHost().getName(), "PM_STATE", "sendingPong");
45 double computeDuration = 0;
46 PingPongTask pong = new PingPongTask("no name",computeDuration,COMM_SIZE_LAT);
48 pong.send(ping.getSource().getName());
50 /* Pop the two states */
51 Trace.hostPopState (getHost().getName(), "PM_STATE");
52 Trace.hostPopState (getHost().getName(), "PM_STATE");