8. SLIP and tdc.dip

If you use PPP you don't want this section.

Serial Line IP, is the string and glue needed to make a modem behave as an IP device. It converts packaets to and from byte streams, and it adds checksums, that eth0 normally does.

If you have a dedicated (null modem) serial line, there is no dialing to be done, and you simply say (at both ends)

slattach ...
ifconfig ...
route ...

Of course you also need stty and setserial, to preconfigure the UART. With a modem, you also need to do the dialing, select the IP_ADDR's of BOTH ends, and disconnect eventually.

If you want to, you can use minicom to get past the remote hosts login (with the correct BAUD rate and rtscts), suspend minicom and run the commands manually (slattach, ifconfig, route).

However, after trying that, it is easier to use DIP to do all of that, and write a dip_script to drive it.

NOTE: If you use PPP, deep down it uses SLIP, but you use CHAT and pppd instead of dip, so the following script is not for you. In addition, PPP does various link-estabishment protocol discussions, and packet framing. EG PPP can exchange IP_ADDRESSES, so that one end can tell the other end what address to take. PPP also supports other protocols, SLIP only does IP.

8.1 /usr/local/lib/tdc.dip
8.2 tdc.dip
8.3 /usr/local/bin/dip_in
8.4 /usr/local/bin/dip_out
8.5 Now test it!

8.1

/usr/local/lib/tdc.dip

This file must NOT be world readable, as it contains the password to your Internet account.

DIP scripts are much more frightening than CHAT scripts, but that is because the chat program is very cleverly designed. You could probably use chat with SLIP, but that's going against tradition.

tdc is the name of my ISP. To make life easier, I use two pseudonyms 'tdc_me' and 'tdc_gw' in /etc/hosts.

Copy and modify the example 'dip' script and write a shell script that calls it. My calling script wakes up my sendmail, and the ISP's sendmail.

AT S95=47 -or- AT S95=46

When V34 modems CONNECT, they return the BAUD rate, reporting either the speed of the wire to the computer (DCE), or the speed of the phone wire (DTE). They should be different, the computer talks to the modem, four times faster than the modem can talk down the phone wire.

You should run once with (AT S95=47) so that it shows the DCE speed. This confirms that setserial really did work.

Then modify it to use (AT S95=46), so that the modem reports the CONNECT speed. This varies beteen 28800 26400 24000, depending on luck, and the quality of the line.

V34 isn't byte by byte

The V34 modem gathers complete 'V34 packets' from the remote modem at 28.8k baud. It then checksums the packet before passing it to the computer at 115.2k (4 times faster).

IE Bytes are not passed straight through, one at a time, they are collected by the modem into checksum-able clumps. Once that checksum has been validated, you want the data to get to the computer as fast as possible.

These V34 packets have nothing to do with TCP/IP packets, and apart from the effect on the delivery timings, the computer never sees them. The benefit, is that a V34 link is a "perfect" link, with no corrupted data, but occasional delays, or complete line drop.

Consult your modem manual for options.

Typical throughput 2.8 KPS

For comparison figures, FTP often reports text file transfers at 4 K/s and compressed binaries at 2.5 K/s. It seems that the modem's compression doesn't improve on gzip, but helps a lot with text files.

8.2

tdc.dip

If you use this script unattended, you MUST make it robust. I watch it run, and use CTRL-C (TWICE!) if it fails.

NOTE: You can't have comments on the same line as commands.

You will have to edit this.

----------------------------------------------------------------------
#!/sbin/dip
#	/usr/local/lib/tdc.dip

#######
# label: first word on line
# comments must be on own line # cmd # cmnt causes usage -1
#######
# wait string [ timeout ] # returns OK_ZERO
# if $errlvl == 0 goto OK
# if $errlvl != 0 goto TIMEOUT
#######
# dial tel_string [ TIMEOUT ] # returns OK_ONE
# if $errlvl == 1 goto CONNECTED
# if $errlvl != 1 goto TIMEOUT
# 1 - CONNECT 
# 2 - ERROR
# 0 - OK   ## BUT NOT CONNECT 28800/ARQ
#######

	main:

			echo on
			print DIP_SCRIPT ........ tdc.dip ........

			get $local  tdc_me.dircon.co.uk
			get $remote tdc_gw.dircon.co.uk

			netmask 255.255.255.0

# speed $speed  # it does the setserial IOCTL # defaults if fails # cmnt
# speed 0 	# probably drops DCR ON_LINE -> ON_HOOK # 
# speed 9600 	# BAUD 
# speed 19200	# 19200
# speed 38400	# 38400 -or- setserial /dev/modem spd_hi  for  57600
# speed 38400	# 38400 -or- setserial /dev/modem spd_vhi for 115200
# speed exta	# 19200
# speed extb	# 38400 
# speed 115200	# 115200 DIP does spd_vhi # tested #
# speed 115200	# 115200/28800 = 11 kps / 2.8 = 4/1

# throughput calcs (in 1000 or 1024 - close to same)
# 8 bit no parity 1 stop bit + 1 start bit = 10 bits per byte #
# divide 10.1000 # 11.52 / 2.88   approx 4 times modem rate
# divide 10.1024 # 11.25 / 2.8125 k-bytes
# stty /dev/modem - has a POSIX limitation no named baud rate > 38400
# linux uses setserial spd_vhi (internal modem - as fast a bus)
# DIP recognises problem and does the setserial # tested #
# but comments on speed line cause another default to be used!

# AT_OK Modem codes used ------------------------------
# AT Q0 V1 E1 X4 L2 W1 S95=47 M1 I4 \r
# AT Q0 - enable result codes to be issued to the screen.
# V1 - Result codes in verbal format not numeric
# E1 - AT command line echo : on
# X4 - monitor dial tones : all
# L2 - speaker volume : 0,1,2,3 low,default,medium,high
# W1 - error correction message shown in CONNECT line
# S95=47 - CONNECT shows Extended Results. Selector codes
# 01 - CONNECT shows DCE (spd_vhi) or DTE (modem-to-modem)
# 02 - CONNECT shows ARQ - Automatic Repeat request
# 04 - CARRIER XXXX
# 08 - PROTOCOL XXXX
# 32 - COMPRESSION
# 47 = 32 + -- + 08 + 04 + 02 + 01
# 46 = 32 + -- + 08 + 04 + 02 + --
# M1 - Speaker On - until carrier detected
# I4 - OEM-STR(28,800 BPS; V.34; 16FEB95; 1.021a)

	get_modem_lock:
			print DIP_SCRIPT getting UUCP device LOCK
			port modem
			speed 115200

	expect_AT_OK:
			# reset	# reset done by init str
			# want: detect modem line levels
			print DIP_SCRIPT looking for AT_OK modem

	# show DCE 	send AT Q0 V1 E1 X4 L2 W1 S95=46 M1 \r
	# show DTE 	send AT Q0 V1 E1 X4 L2 W1 S95=47 M1 \r

			send AT Q0 V1 E1 X4 L1 W1 S95=47 M1 I4 \r
			wait OK 2	
			if $errlvl == 0 goto got_a_modem
			print DIP_SCRIPT errlvl $errlvl 

	modem_not_talking_to_me:
			print DIP_SCRIPT modem not talking to me
			print DIP_SCRIPT or not an AT_OK device
			goto error

	got_a_modem:
			print DIP_SCRIPT Modem online - ok

# OK got a modem

	dial_and_connect:
	now_connect:
			# 0 - OK
			# 1 - CONNECT
			# 2 - ERROR
			print  DIP_SCRIPT dial 0181-265-2211 -	tdc Video Tron V34
			                  dial 0181-265-2211 

			if $errlvl == 1 goto got_connect
			print DIP_SCRIPT errlvl $errlvl 
			print DIP_SCRIPT MODEM <-- CONNECTED --> MODEM
			print DIP_SCRIPT Expecting login banner
			sleep 2
	dial_failed:
			print DIP_SCRIPT Dial Failed
			goto error
	got_connect:

	## DIP is not exactly bullet proof
	## it was not reading text through properly
	## stopeed using if errlvl codes
	## so made simply a timeout 
	## ie hightly visible to operator
	## echo on allows view of tty during login
	## currently seen CONNECT:

	now_login_prompt:
	#		wait login: 20
			wait ogin: 20
			if $errlvl == 0 goto got_login_prompt
			print DIP_SCRIPT errlvl $errlvl 

		fail_no_login_prompt_timeout:

			print DIP_SCRIPT TIMEOUT(login)
			goto got_login_propmt # POSSIBLY UNSEEN
			goto error
	got_login_prompt:

-EDIT->			send SLIP_LOGIN\n

	now_password_prompt:
		#	wait Password: 20
			wait ord: 20
			if $errlvl == 0 goto got_password_prompt
			print DIP_SCRIPT errlvl $errlvl 

		fail_no_password_prompt_timeout:

			print DIP_SCRIPT TIMEOUT(password)
			goto got_password_propmt # POSSIBLY UNSEEN
			goto error
	got_password_prompt:

-EDIT->			send SLIP_PASSWORD\n

# this is an optional switch for SLIP -or- PPP select
#	goto look_for_signs_of_succesful_login
#	goto now_enabled_sign 

	now_protocol_prompt:
-EDIT->			wait Protocol: 20
			if $errlvl == 0 goto got_protocol_prompt
			print DIP_SCRIPT errlvl $errlvl 
			# goto error
	got_protocol_prompt:

			send SLIP\n

	look_for_signs_of_succesful_login:
	now_enabled_sign:
		#	tdc says "Packet mode enabled" # grp fmt || fd=tdc
		#	tdc says "Packet mode enabled..." # grp fmt || fd=tdc
-EDIT->		wait Packet 20
			if $errlvl == 0 goto got_remote_SLIP
			print DIP_SCRIPT errlvl $errlvl 
	got_enabled_sign:
	got_remote_SLIP:

			print DIP_SCRIPT Logged in to terminal sserver
			get $mtu 1500
		route_before_slattach:
			default
		does_this_do_slattach:
			mode CSLIP

	# get $mtu 296
	# 1500 is great for ethernet to backbone
	# try 296 for point to point
	# try V34 packet sizes +- compression, q depth, etc

	connected_to_slip:
			print DIP_SCRIPT CONNECTED $locip <---> $rmtip
			print DIP_SCRIPT /dev/$port at $speed baud
			goto exit_ok

	error:
			print DIP_SCRIPT errlvl $errlvl 
			print DIP_SCRIPT ERROR - CALL ABORTED
			print DIP_SCRIPT /dev/$port at $speed baud
			print DIP_SCRIPT local $local $locip
			print DIP_SCRIPT remote $remote $rmtip
			print DIP_SCRIPT FAILED
			quit

	exit_ok:
	exit:
			exit

---------------------------------------------------------------------
For some reason dip seems to require TWO CTRL-C's to exit. As will any script that calls it.

dip does the dialing, and it also does the ifconfig and route'ing.

8.3

/usr/local/bin/dip_in

You will need an extra few commands to tickle sendmail to life, and so-on. How you tell your ISP's mailhost (felix), to start email transmission will vary. Ditto for your self.

If you have smail, you need runq. If you have POP-3 mail you need something else. If you have a working news feed, you will also want to run procnews when the link is up, and maybe a batch-em-up script before the link comes up.

You might also want to connect WITHOUT transferring email, eg if you are booting a second test host, or if the transaction would take to long.

#!/bin/sh
# dip_in #
# see also /usr/local/lib/tdc.dip

PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:

mailq	# show mail that is queued to go out
setserial /dev/modem # already done in /etc/rc.d/rc.local

dip /usr/local/lib/tdc.dip 2>&1 | tee -a /tmp/dip_craps_out_$$ # || exit $?
echo

tail -1f /var/adm/messages &	# shows all sorts of info
sleep 2				# nameserver not debugged
sendmail -q			# send outgoing mail
finger @felix 			# pull incoming mail
# /usr/local/bin/procnews	# pull news - if working
finger @felix			# confirm all received
mailq				# usually all sent by now

8.4

/usr/local/bin/dip_out

I only have one dip connection. You might have several, and be more selective about which you want to kill.

I don't like using the 'dummy' interface to prop-up a non-existent slip interface. I prefer to get 'network unreachable' errors, which is the correct diagnosis when the SLIP link is switched off. Some apps may need it.

The ifconfig and route commands, substitute the dummy device at the address where the sl0 device was. I don't know if this is a good idea, or what exactly happens, but it can help. It would effect commands that use the nameservice, such as smail, and find the unreachability of the nameserver as a sign that the actual name (being looked up) is bad.

It also effects daemons that listen/attach to specific interface addresses. eg samba has to be configred for each of its eth0 and sl0 addresses.

Really those two lines should be put into /etc/rc.d/rc.dummy_tdc, where the other devices are.

The tdc_me parameter gets looked up in /etc/hosts, to be the IP_ADDR to use. If your /etc/hosts file is shared between multiple hosts, you may need to rethink it.

# dip_out #

dip -k		# for single dip session 

# killall dip	# slightly more drastic option

PATH=$PATH:/sbin
ifconfig dummy tdc_me
route add tdc_me
The ifconfig and route commands in rc.inet1 (rc.eth0), are much the same as those used for the dummy, and called internally by DIP.

/dev/eth0 exists (on SVR4 machines at least), but with route and ifconfig, eth0 eth1 sl0 ppp0 dummy0 are names not filenames or devices (but they are devices!)

sl0 is a TCP/IP device, like eth0, but customised to handle serial lines, where data comes in waves of bytes, not packets.

8.5

Now test it!

You may wish to set up sendmail first, and get a result first time.

As the root user run dip_in - it is on your path! You did do chomd 755 on it! I hope you used the dip-example files (not mine), and modified the values for your machine.

Note, these texts have been edited after importing to HTML. Sorry for any errors introduced!

Naturally, this worked first time! To confirm this use ping tdc_gw or the name you used as the other end of the SLIP connection.

Now test that DNS is working using ping sunsite.unc.edu, or src.doc.ic.ac.uk (Imperial College, Academic, UK ). Since you didn't type in those addressess, they must have come from (or via) your nameserver.

Note for UK users: Imperial College has a shocking cd sunsite prefix, but ftp runs a tad faster, it also has many categories in /pub/packages, including TCL/TK for MS-WIN.

Now try:

mkdir /tmp/ftp
cd    /tmp/ftp
ftp sunsite.unc.edu	(or src.doc.ic.ac.uk)
	ftp-login: anonymous
	password: abc@		(your login, be polite)
	cd /pub/Linux/system/Network/info-systems
	pwd
	ls

# on src.doc.ic.ac.uk try something like
# /packages/linux/sunsite.unc-mirror first, us ls

	hash			# show 1 K progress
	mget mosaic*		# takes ages, so make your choice
	mget netscape*		# has problems when remote X11 display

	dip_out

If you have mc-3, you can also run

mc /tmp/ftp ftp://src.doc.ic.ac.uk/pub/packages

ftp netscape, mosaic, arena, grail, ...

With Slackware, you already have Lynx on the disk, and with Infomagic/sunsite, you already have arena, ready to untar and link. Netscape and Mosaic are NOT on the disks! You have to have Internet access to get them.

Lynx runs on a text tty, arena needs X11 to run. Configuring X11 needs a bit of work to get just right.

If you find FTP is a bit slow, eg to a site connected by modem, or an overloaded host, you can setup sendmail, then ask a kind third party (probably near rtfm.mit.edu) to ftp it for you, and send it uuencoded as email.

uuencode makes a binary file into a text file, expanding it by 40%, but V34 modems will compress SOME of that down again. netscape is 1.6 Mbytes big! which takes 10-20 minutes to download. Getting it from a slow host will take longer, and your local ISP machine SHOULD be faster! To see if your SMTP line is active, use netstat.