Transcript ppt
ECE 291
Lecture 18:
Networking
Constantine D. Polychronopoulos
Office: 463 CSRL
Spring 2000
CDP
ECE 291 -- Spring 2000
Computer Networks
• The “Network” is the means by which computers can communicate
with other computers and consists of the three components:
– Physical layer (cables and wireless channels connecting nodes)
– The (software) communication layer (includes the OS and basic data
send/receive services and network interface drivers)
– The protocol layer (defines the way data is assembled into units of
transmission - how data is interpreted by the communication layer).
• Examples of networks include the Internet, local-area networks
(LAN) and Ethernet networks.
• PCs are connected to other PCs via Ethernet (ECE291 lab) network
which is like a “bus”. PC nodes connect to the ethernet via an
Network Interface Card (NIC) connected to the I/O (PCI) bus.
CDP
ECE 291 -- Spring 2000
Computer Networks
• Programming network applications requires knowledge of the
protocol and the communication layers. From the perspective of
applications networking is a service that allows an application to
send and receive data from other computers.
• PCs connected to the network have unique addresses/names
known as the IP address, so they can be located by messages
travelling the network. All or some nodes in a network maintain
routing tables with IP addresses which are used to route
messages from a given source to a specific destination node.
• Three basic Networking services:
– SEND data (by source node)
– TRANSMIT data (on the actual physical link(s))
– RECEIVE data (at destination node)
• Transmission links: wire (twisted cable), optical, wireless (RF)
CDP
ECE 291 -- Spring 2000
Packet Switching Networks
• A sender can send any size data. The network interface chops
the data into specific-size packets that are prefixed with sender
and receiver ID, the payload (data) and a termination indicator.
The data is then transmitted (pushed) onto the network as a
sequence of packets which are transmitted asynchronously.
These are called packet-switching networks which include
virtually all computer networks.
• Internet as well as modern LANs, WANs are packet-switching.
• Transmission is done via:
– UNICAST (source-destination pair only - routing is done with the
help of routing tables)
– MULTICAST (source-to-many-destinations which is equivalent to
many simultaneous unicasts from the same source)
– BROADCAST (source-to-all other nodes communication)
CDP
ECE 291 -- Spring 2000
Data Transmission
• The transport layer or transport protocol defines the size and
format of data packets, the transmission/receiving policy, and
other higher-level actions and policies such as fault-tolerance.
• TCP/IP is the predominant transport protocol used in most
computer networks and implements reliable transmission
between two endpoints (specific nodes).
• Intermediate (router) nodes can be specialized switches or just
other PCs in the network. Routers keep routing information
which is used by the transport protocol to buffer temporarily
packets from an INPUT port to an OUTPUT port and on to the
next router, until data arrives at destination node where it is
consumed.
CDP
ECE 291 -- Spring 2000
PC Networking
• PCs are connected in a LAN often using Ethernet (R. Metcalf).
Each PC is connected to the network via a network interface
(NI) which attaches to the PCI bus.
• NI is where data to be sent or received are buffered, assembled
into packets or disassembled into raw data, and either put onto
the network links or read into memory respectively.
• A NI driver controls the operation of the NI and provides
SEND/RECEIVE user interface calls to applications.
CDP
ECE 291 -- Spring 2000
PC Communication
• To SEND a message, an application calls the network driver and
provides the data to be transmitted which is temp stored in NI
queues.
• When the NI adapter RECEIVES data, an interrupt is generated
which launches the network driver.
• Driver unpacks the data and then executes the user program’s
procedure that is supposed to take ownership of the data
(CALLBACK). The user application to be called is identified by the
header of the message.
• The NI API is known as the NetBIOS (which you will also have to
use in MP4).
CDP
ECE 291 -- Spring 2000
NetBIOS
• Networking primitives for DOS and Windows on x86.
• For a LAN, the NetBIOS provides:
– Global name space.
– Broadcast, multicast, unicast and the protocol that determines if a
packet is lost and retransmits.
• You can use the NetBIOS in windows through interrupt 05CH
• Network Control Block (NCB) is the basic NetBIOS data
structure
CDP
ECE 291 -- Spring 2000
NetBIOS (cont.)
• How to receive messages from the network:
– Blocking Function: waits for an event
– Callback Function: NetBIOS calls a registered procedure once a
message arrives (much like an interrupt)
• Names are 16 character identifiers:
– Local name: unique across LAN
– Group name: shared by multiple machines (used in multicast)
CDP
ECE 291 -- Spring 2000
NetBIOS: Unicast & Multicast
Multicast (Datagrams)
Unicast Connection
• Sender & receiver ADD NAME
• Sender & receiver ADD NAME
• LOOP
• Receiver LISTENS
•Sender SENDS (broadcast
datagram)
• Sender CALLS (connection estbl)
• LOOP
•Receiver RECEIVES
datagram
•Sender SENDS
• Sender & receiver REMOVE
NAME
•Receiver RECEIVES
• Sender or receiver HANGUP
(connection terminates)
• Sender & receiver REMOVE NAME
CDP
ECE 291 -- Spring 2000
NetBIOS: Callback routine
Netpost proc
near
; BX=receive buffer
; AX=message length
; Must preserve all regs
; Avoid DOS and
; LIB291 calls
PUSH SI
MOV
SI, ReceiveIndex ;Index
;into ReceiveString
STRCPY ReceiveString[SI], BX, AX
ADD
ReceiveIndex, AX ; Index
; for next incoming
; message
POP SI
RET
Netpost endp
CDP
ECE 291 -- Spring 2000
• Callback subroutine is
called from NetBIOS
interrupt and handles
incoming messages on
behalf of the application
NetBIOS: NetLIB
; Sample main for using NetLIB
main proc
far
. . .
CALL
MOV
NetINIT
my_num, AL
. . .
; Send message
STRCPY TXBuffer, TransmitString,
SIZEOF TransmitString
MOV
AX, SIZEOF TransmitString
CALL
SendPacket
. . .
CALL
NetRelease
. . .
main endp
CDP
ECE 291 -- Spring 2000
• NetLIB implements three
procedures for
transmitting packets, the
callback for receiving,
and provides an easy
interface for using
NetBIOS.
• You must also set
grp_name and
my_name
Data Link Communication
• In a communication protocol stack the data link communication
is at the lowest layer and implements a driver for the network
interface card.
• DLC can be used by higher layers to implement timed
acknowledgement, time-outs and re-transmission in order to
provide reliable connection/transmission of messages through
the network.
• Synchronized send/receive ops can be accomplished through
handshaking/ack protocols.
• For your MP4 and projects you can assume reliable connections
for unicast, multicast or broadcast.
CDP
ECE 291 -- Spring 2000
String Instructions
• Very useful in graphics or in general for applying same operation
on a region of locations in memory.
• Typical string ops copy from one range to another and filling a
range of memory locations with specified values;
• EXAMPLE of string ops:
– rep movsd
; copy one DWORD from one string to another
– rep stosd
; set the DWORD to the value in EAX
– (last “d” is for doubleword - replace for B, W)
CDP
ECE 291 -- Spring 2000
Plan your string operations clearly:
Always make sure you define the following 5 steps:
1 -Set source segment and offset
2 - Set the destination segment and offset
3 - Specify direction of processing (default is forward)
4 - Specify the number of units to apply each op (B, W, D)
5 - Specify the operation
CDP
ECE 291 -- Spring 2000
Example:
1 -Set source segment and offset: use DS to point to source
mov AX, SEG ScratchSeg
; from a defined segment
mov DS, AX
2 - Set ES to the destination segment
mov AX, 0A000h
; graphics segment
mov ES, AX
3 - Specify direction of processing
cld
; set direction flag forward
4 - Specify the source offset
mov ESI, offset ScratchSeg ; set source offset
5- Specify the destination offset
mov EDI, 0
; set destination offset
Specify # of times to repeat opetation
mov ECX, 16000
Specify the operation
rep movsd
CDP
ECE 291 -- Spring 2000