jist.swans.net
Class NetIp

java.lang.Object
  extended by jist.swans.net.NetIp
All Implemented Interfaces:
JistAPI.Proxiable, JistAPI.Timeless, NetInterface

public class NetIp
extends java.lang.Object
implements NetInterface

IPv4 implementation based on RFC 791. Performs protocol multiplexing, and prioritized packet queuing, but no RED or packet fragmentation.

Since:
SWANS1.0
Version:
$Id: NetIp.java,v 1.45 2004/11/03 23:53:22 barr Exp $
Author:
Rimon Barr <barr+jist@cs.cornell.edu>

Nested Class Summary
static class NetIp.NicInfo
          Information about each network interface.
 
Nested classes/interfaces inherited from interface jist.swans.net.NetInterface
NetInterface.NetHandler
 
Field Summary
protected  PacketLoss incomingLoss
          packet loss models.
protected  NetAddress localAddr
          local network address.
static org.apache.log4j.Logger log
          IP logger.
static byte MAX_QUEUE_LENGTH
          Maximum packet queue length.
protected  NetIp.NicInfo[] nics
          network interfaces.
protected  PacketLoss outgoingLoss
          packet loss models.
protected  NetInterface.NetHandler[] protocolHandlers
          protocol handlers.
protected  Mapper protocolMap
          protocol number mapping.
protected  RouteInterface routing
          routing protocol.
protected  NetInterface self
          self-referencing proxy entity.
static int THRESHOLD_FRAGMENT
          Packet fragmentation threshold.
 
Constructor Summary
NetIp(NetAddress addr, Mapper protocolMap, PacketLoss in, PacketLoss out)
          Initialize IP implementation with given address and protocol mapping.
 
Method Summary
 byte addInterface(MacInterface macEntity)
          Add network interface with default queue.
 byte addInterface(MacInterface macEntity, MessageQueue q)
          Add network interface.
 NetAddress getAddress()
          Return local network address.
private  NetInterface.NetHandler getProtocolHandler(int protocolId)
          Return network protocol handler.
 NetInterface getProxy()
          Return self-referencing proxy entity.
private  boolean isForMe(NetMessage.Ip msg)
          Whether packet is for local consumption.
 void pump(int interfaceId)
          Request next packet to send, if one exists; indicate that interface has completed processing previous request.
 void receive(Message msg, MacAddress lastHop, byte macId, boolean promisc)
          Receive a message from the link layer.
 void send(Message msg, NetAddress dst, short protocol, byte priority, byte ttl)
          Route, if necessary, and send a message (from TRANSPORT).
 void send(NetMessage.Ip msg, int interfaceId, MacAddress nextHop)
          Send a message along given interface (usually from ROUTING).
private  void sendIp(NetMessage.Ip msg)
          Send an IP packet.
 void setAddress(NetAddress addr)
          Set local network address.
 void setProtocolHandler(int protocolId, NetInterface.NetHandler handler)
          Set network protocol handler.
 void setRouting(RouteInterface routingEntity)
          Set routing implementation.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

public static final org.apache.log4j.Logger log
IP logger.


THRESHOLD_FRAGMENT

public static final int THRESHOLD_FRAGMENT
Packet fragmentation threshold.

See Also:
Constant Field Values

MAX_QUEUE_LENGTH

public static final byte MAX_QUEUE_LENGTH
Maximum packet queue length.

See Also:
Constant Field Values

self

protected NetInterface self
self-referencing proxy entity.


localAddr

protected NetAddress localAddr
local network address.


routing

protected RouteInterface routing
routing protocol.


protocolMap

protected Mapper protocolMap
protocol number mapping.


protocolHandlers

protected NetInterface.NetHandler[] protocolHandlers
protocol handlers.


nics

protected NetIp.NicInfo[] nics
network interfaces.


incomingLoss

protected PacketLoss incomingLoss
packet loss models.


outgoingLoss

protected PacketLoss outgoingLoss
packet loss models.

Constructor Detail

NetIp

public NetIp(NetAddress addr,
             Mapper protocolMap,
             PacketLoss in,
             PacketLoss out)
Initialize IP implementation with given address and protocol mapping.

Parameters:
addr - local network address
protocolMap - protocol number mapping
in - incoming packet loss model
out - outgoing packet loss model
Method Detail

getProxy

public NetInterface getProxy()
Return self-referencing proxy entity.

Returns:
self-referencing proxy entity

setAddress

public void setAddress(NetAddress addr)
Set local network address.

Parameters:
addr - local network address

isForMe

private boolean isForMe(NetMessage.Ip msg)
Whether packet is for local consumption.

Parameters:
msg - packet to inspect
Returns:
whether packet is for local consumption

setRouting

public void setRouting(RouteInterface routingEntity)
Set routing implementation.

Parameters:
routingEntity - routing entity

addInterface

public byte addInterface(MacInterface macEntity)
Add network interface with default queue.

Parameters:
macEntity - link layer entity
Returns:
network interface identifier

addInterface

public byte addInterface(MacInterface macEntity,
                         MessageQueue q)
Add network interface.

Parameters:
macEntity - link layer entity
Returns:
network interface identifier

setProtocolHandler

public void setProtocolHandler(int protocolId,
                               NetInterface.NetHandler handler)
Set network protocol handler.

Parameters:
protocolId - protocol identifier
handler - protocol handler

getProtocolHandler

private NetInterface.NetHandler getProtocolHandler(int protocolId)
Return network protocol handler.

Parameters:
protocolId - protocol identifier
Returns:
procotol handler

getAddress

public NetAddress getAddress()
                      throws JistAPI.Continuation
Return local network address.

Specified by:
getAddress in interface NetInterface
Returns:
local network address
Throws:
JistAPI.Continuation - never (blocking event)

receive

public void receive(Message msg,
                    MacAddress lastHop,
                    byte macId,
                    boolean promisc)
Receive a message from the link layer.

Specified by:
receive in interface NetInterface
Parameters:
msg - incoming network packet
lastHop - link-level source of incoming packet
macId - incoming interface
promisc - whether network interface is in promisc. mode

send

public void send(Message msg,
                 NetAddress dst,
                 short protocol,
                 byte priority,
                 byte ttl)
Route, if necessary, and send a message (from TRANSPORT).

Specified by:
send in interface NetInterface
Parameters:
msg - packet payload (usually from transport or routing layers)
dst - packet destination address
protocol - packet protocol identifier
priority - packet priority
ttl - packet time-to-live value

send

public void send(NetMessage.Ip msg,
                 int interfaceId,
                 MacAddress nextHop)
Send a message along given interface (usually from ROUTING).

Specified by:
send in interface NetInterface
Parameters:
msg - packet (usually from routing layer)
interfaceId - interface along which to send packet
nextHop - packet next hop address

sendIp

private void sendIp(NetMessage.Ip msg)
Send an IP packet. Knows how to broadcast, to deal with loopback. Will call routing for all other destinations.

Parameters:
msg - ip packet

pump

public void pump(int interfaceId)
Request next packet to send, if one exists; indicate that interface has completed processing previous request.

Specified by:
pump in interface NetInterface
Parameters:
interfaceId - interface identifier

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object