4 * Copyright 2006,2007 Martin Quinson, Malek Cherier
5 * Copyright (c) 2012-2013. The SimGrid Team.
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the license (GNU LGPL) which comes with this package.
12 import org.simgrid.msg.Host;
13 import org.simgrid.msg.Msg;
14 import org.simgrid.msg.MsgException;
15 import org.simgrid.msg.Task;
16 import org.simgrid.msg.Process;
17 import org.simgrid.trace.Trace;
19 public class Receiver extends Process {
21 private final double commSizeLat = 1;
22 private final double commSizeBw = 100000000;
24 public Receiver(Host host, String name, String[]args) {
25 super(host,name,args);
28 public void main(String[] args) throws MsgException {
31 Trace.hostPushState (host.getName(), "PM_STATE", "waitingPing");
32 double communicationTime=0;
34 double time = Msg.getClock();
36 /* Wait for the ping */
37 Msg.info("try to get a task");
39 PingPongTask ping = (PingPongTask)Task.receive(getHost().getName());
40 double timeGot = Msg.getClock();
41 double timeSent = ping.getTime();
43 Msg.info("Got at time "+ timeGot);
44 Msg.info("Was sent at time "+timeSent);
47 communicationTime=timeGot - time;
48 Msg.info("Communication time : " + communicationTime);
50 Msg.info(" --- bw "+ commSizeBw/communicationTime + " ----");
53 Trace.hostPushState (host.getName(), "PM_STATE", "sendingPong");
54 double computeDuration = 0;
55 PingPongTask pong = new PingPongTask("no name",computeDuration,commSizeLat);
57 pong.send(ping.getSource().getName());
59 /* Pop the two states */
60 Trace.hostPopState (host.getName(), "PM_STATE");
61 Trace.hostPopState (host.getName(), "PM_STATE");