mTCP PPP setup instructions
Michael Brutman (mbbrutman@gmail.com)


Introduction

  The following are instructions for how to use mTCP over a PPP connection.
  SLIP and CSLIP are similar but not discussed here.  (See SLIP.TXT)



Prerequisites:

  - A known good connection between the machines.  This is usually done
    with a null modem cable.  You need to verify this link works with
    terminal emulation software before you start with PPP - it makes
    debugging much easier if you start with a known good setup.

  - The DOSPPP packet driver.  Download a known working version from here:

      http://www.ibiblio.org/pub/micro/pc-stuff/freedos/
        files/net/dosppp/dosppp06.zip

    (Sorry, that URL had to split across two lines.)

    Other PPP drivers are possible; I used DOSPPP as an example.  One
    key point is that whatever PPP driver you use should emulate an
    Ethernet card for mTCP.  mTCP is expecting to use a packet driver
    that is designed for Ethernet; that is known as a "class 1" packet
    driver.  mTCP does not work with other classes of packet drivers,
    including serial (class 6) and Token Ring (class 3).  DOSPPP
    gets around this limitation by telling mTCP that it is an Ethernet
    card even though it is actually using the serial port.



Network setup for the examples provided here

  My house is connected to the outside world with a cable modem that
  gives me a dynamically allocated address on the global internet.  That
  is connected to a home router, which then feeds the machines in the
  house.  The router does network address translation (NAT) to provide
  private addresses within the house.

    Cable Modem  <->  Router       <->   Machines
    96.x.x.x          192.168.2.1        192.168.2.x

 
  Normally I use Ethernet connections on my DOS machines so they look
  like any other PC in the house and can connect to the router directly.

  To add a DOS machine using PPP one of the machines in the house has
  to convert from Ethernet to PPP.  I use an older Linux machine to do
  this.  Here is what the network diagram is going to look like:

    Cable Modem  <->  Router       <->  Linux
    96.x.x.x          192.168.2.1       192.168.2.10
                                            |
                                        192.168.2.17 <-> DOS (192.168.2.18)

  The Linux machine has an Ethernet card and it is assigned address
  192.168.2.10.  That is a static assignment; it never changes.  The DHCP
  server in the router is told not to give out any addresses below
  192.168.2.100 so there will not be a conflict.

  To enable PPP the Linux machine will take on a second network address.
  That network address must be chosen carefully.  Here is the process:

    - Pick a number that is divisible by 4.
    - No machine in your house should have a machine with that number or
      the next three numbers after it.
    - Your Linux machine will have that number + 1
    - Your DOS machine will have that number + 2
    - The other two numbers will be reserved and unused.
    - Do not start with 0 or 252.

  For example, the following addresses would be valid in this scheme:

    Linux            DOS               Reserved
    192.168.2.5      192.168.2.6       192.168.2.4 and 192.168.2.7
    192.168.2.17     192.168.2.18      192.168.2.16 and 192.168.2.19
    192.168.2.161    192.168.2.162     192.168.2.160 and 192.168.2.163


  Other options are available, but those require advanced routing tricks.
  Just find a block of four addresses divisible by four that are not in
  use, follow the rules above, and you will be fine.  (I'll tell you the
  hard way that adds new subnet for a beer or two.)



Establish the PPP connection between the two machines

  On the Linux side you will be using the PPP daemon.  The important
  parameters to specify are:

    - the serial port that will be used
    - the speed of the port
    - "local" to set the flow control
    - "lock" to ensure that other programs do not intefere with the port
    - "passive" or "silent" to tell PPPD to wait for a conection instead
       of timing out.  (Passive and silent are slightly different, but
       both should work.)
    - "proxyarp" to make your machine look as though it is visible on
      the network.
    - A reasonable MTU size.  576 should work fine.
    - IP addresses for the Linux side and the remote side


  Before you fire up the PPP daemon ensure that nothing else is using
  that serial port.  If you have a "getty" process running on that
  port to allow normal logins you will need to disable it.  The serial
  port has to be clear for PPP.  (Use the ps command to look for a
  getty process that might be using it.)

  For example, on my Linux system I use the following command line:

    pppd ttyS1 9600 local lock passive proxyarp defaultroute mtu 576
         192.168.2.17:192.168.2.18

    (All of that should be on the same line.)

  In this setup I'll be running at 9600 bps over my second serial port.
  The Linux machine will get a new network interface called ppp0 with
  address 192.168.2.17 and it will be talking to the DOS PC which will
  have an address of 192.168.2.18.

  If successful the Linux machine will return silently to the command
  line but the PPP daemon will be running in the background waiting
  for a new connection from the DOS machine.  You can verify this
  using the ps command.

  On the DOS machine we need to run EPPPD to complete the connection.
  Here we need to specify the serial port and the speed to use.  I use
  this command on my DOS machine:

    EPPPD com2 9600 local

  EPPPD is the PPP driver with Ethernet emulation.  This is necessary for
  mTCP because mTCP is written with Ethernet in mind and can not use a serial
  link directly.

  My DOS machine will be using the second serial port at 9600 bps using flow
  control suitable for directly connected machines.

  After a few seconds of delay EPPPD responds with:

    Installed packet driver handler at vector 0x60

  Now you have a live link between the two machines.  If you go back
  to the Linux machine and run "ifconfig" you will be able to
  see the new network interface:

    ppp0  Link encap:Point-to-Point Protocol  
          inet addr:192.168.2.17  P-t-P:192.168.2.18  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:576  Metric:1
          RX packets:11 errors:0 dropped:0 overruns:0 frame:0
          TX packets:13 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3 
          RX bytes:170 (170.0 b)  TX bytes:158 (158.0 b)


  EPPPD will also create a batch file called IP-UP.BAT which sets environment
  variables suitable for WATTCP programs.  mTCP won't use those environment
  variables but some of their values are useful to us to configure mTCP.



Configuring mTCP

  mTCP configuration is done as normal, but with a few changes:

    [1] You need to set the MTCPSLIP environment variable to something.
    The actual value does not matter; it just needs to exist.  At the
    DOS command line this command will do the trick:

      SET MTCPSLIP=true


    [2] You should ensure that your MTU setting in the mTCP configuration
    file matches what you told the PPP daemon on Linux.  I recommend using
    a value of 576.

    [3] You need to setup the IP addresses statically because you will
    not be using DHCP in this setup.  In particular you need to set the
    IPADDR, NETMASK, and GATEWAY variables:

      IPADDR: This is second IP address you used on the PPP daemon line
              in Linux.  In this example it is 192.168.2.18.

      NETMASK: Linux uses a netmask of 255.255.255.255 to signify a point-
               to-point link.  mTCP is thinking "Ethernet" so it wants
               a netmask that reflects the addressing scheme more closely.
               If you followed the rules above a netmask of 255.255.255.252
               is correct for mTCP.

               If you did not pick your addresses as per the rules above
               you might be able to ping the Linux machine, but not other
               machines.  Follow those rules carefully!

      GATEWAY: If you plan to send packets past your Linux machine to
               other machines the Linux machine will have to serve as
               your gateway.  Put its PPP0 address here.  In this example
               it is 192.168.2.17.

  If these are set correctly you should be able to run PING on the DOS
  machine and get a response back from the Linux machine.  At 9600 bps on
  a 386 class machine the time for a standard 32 byte PING packet should
  be around 150ms.

  (The math is pretty straight forward - at 9600 bps you get about one
  byte per millisecond.  The standard payload for ping is 32 bytes and
  you need an IP header, an ICMP header, and four more bytes for the ping
  identification number and sequence number.  The total bytes sent is
  that overhead (28 bytes) plus the ping payload bytes (32 default)
  for a total of 60 bytes.  PPP adds at least another 8 bytes of
  framing overhead to that, so the total being sent per packet is closer
  to 68 bytes.  68 bytes at 9600 bps takes 70.8ms to send and you need
  to wait for the response which is the same size.  So the minimum
  possible time with no additional overhead is 141ms.)

  If you ping from Linux to DOS you might not get a response; remember mTCP
  only response when an mTCP application is running.  If you want to try to
  ping from Linux run something simple on the mTCP machine.  Netcat in
  "listen" mode will do the trick:

    nc -listen 2000

  That will enable you to test PING from Linux to DOS.

  Now you have basic connectivity between the two machines.  Telnet, FTP,
  IRCjr and other applications will work if the target machine is your
  Linux machine.  Next we need to enable some advanced routing to go beyond
  your Linux machine to other machines on your network and the outside
  world.



Going past your Linux machine

  The "proxyarp" option on the pppd command should make your machine
  look like it is on the network.  If a remote machine tries to find
  the hardware address of your DOS machine running mTCP the Linux
  machine will substitute it's own hardware address.  In effect, it
  is your proxy on the network.

  This is not sufficient for getting to machines past your Linux
  machine though.  Your Linux machine still considers the PPP link
  to be a separate network.  All we need to do is to tell Linux to
  route packets from one network to the other.  This is done by
  turning on "IP forwarding."

    echo 1 > /proc/sys/net/ipv4/ip_forward

  Do that as root.  After that, when Linux sees a packet from an
  outside network it will route it to the DOS machine running mTCP.

  After that, you should be able to ping other machines on your home
  network.  If you setup your nameserver in mTCP you should be able to
  get to the outside world as well.  And other machines will be able
  to ping your machine.


Advanced options

  What has been presented above is the bare minimum to get a DOS
  machine running mTCP on a local home network.  Your home network
  might not look like this, requiring more work.  Some other options
  include:

  - Running IP masquerading (NAT) on the Linux machine
  - Running the PPP network on a different subnet and having Linux
    routing to that subnet.  This requires advanced routing on other
    machines in your network if you are using non-routable networks
    like 192.168.x.x.

  All of this is left as an exercise to the interested reader. ;-0



More information: http://www.brutman.com/mTCP

Created November 25th, 2011, Last updated April 26th, 2013
(C)opyright Michael B. Brutman, mbbrutman@gmail.com
