CDP ECE 291 -- Spring 2000 ECE 291 Spring 2000 Lecture 18: Networking Constantine D....

16
CDP ECE 291 -- Spring 2000 ECE 291 Spring 2000 Lecture 18: Networking Constantine D. Polychronopoulos Office: 463 CSRL

Transcript of CDP ECE 291 -- Spring 2000 ECE 291 Spring 2000 Lecture 18: Networking Constantine D....

Page 1: CDP ECE 291 -- Spring 2000 ECE 291 Spring 2000 Lecture 18: Networking Constantine D. Polychronopoulos Office: 463 CSRL.

CDP ECE 291 -- Spring 2000

ECE 291

Spring 2000

Lecture 18:

Networking

Constantine D. Polychronopoulos

Office: 463 CSRL

Page 2: CDP ECE 291 -- Spring 2000 ECE 291 Spring 2000 Lecture 18: Networking Constantine D. Polychronopoulos Office: 463 CSRL.

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.

Page 3: CDP ECE 291 -- Spring 2000 ECE 291 Spring 2000 Lecture 18: Networking Constantine D. Polychronopoulos Office: 463 CSRL.

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)

Page 4: CDP ECE 291 -- Spring 2000 ECE 291 Spring 2000 Lecture 18: Networking Constantine D. Polychronopoulos Office: 463 CSRL.

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)

Page 5: CDP ECE 291 -- Spring 2000 ECE 291 Spring 2000 Lecture 18: Networking Constantine D. Polychronopoulos Office: 463 CSRL.

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.

Page 6: CDP ECE 291 -- Spring 2000 ECE 291 Spring 2000 Lecture 18: Networking Constantine D. Polychronopoulos Office: 463 CSRL.

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.

Page 7: CDP ECE 291 -- Spring 2000 ECE 291 Spring 2000 Lecture 18: Networking Constantine D. Polychronopoulos Office: 463 CSRL.

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).

Page 8: CDP ECE 291 -- Spring 2000 ECE 291 Spring 2000 Lecture 18: Networking Constantine D. Polychronopoulos Office: 463 CSRL.

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

Page 9: CDP ECE 291 -- Spring 2000 ECE 291 Spring 2000 Lecture 18: Networking Constantine D. Polychronopoulos Office: 463 CSRL.

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)

Page 10: CDP ECE 291 -- Spring 2000 ECE 291 Spring 2000 Lecture 18: Networking Constantine D. Polychronopoulos Office: 463 CSRL.

CDP ECE 291 -- Spring 2000

NetBIOS: Unicast & Multicast

Multicast (Datagrams)

• Sender & receiver ADD NAME

• LOOP

•Sender SENDS (broadcast datagram)

•Receiver RECEIVES datagram

• Sender & receiver REMOVE NAME

Unicast Connection

• Sender & receiver ADD NAME

• Receiver LISTENS

• Sender CALLS (connection estbl)

• LOOP

•Sender SENDS

•Receiver RECEIVES

• Sender or receiver HANGUP (connection terminates)

• Sender & receiver REMOVE NAME

Page 11: CDP ECE 291 -- Spring 2000 ECE 291 Spring 2000 Lecture 18: Networking Constantine D. Polychronopoulos Office: 463 CSRL.

CDP ECE 291 -- Spring 2000

NetBIOS: Callback routine

• Callback subroutine is called from NetBIOS interrupt and handles incoming messages on behalf of the application

Netpost proc near; BX=receive buffer; AX=message length; Must preserve all regs ; Avoid DOS and ; LIB291 callsPUSH SIMOV SI, ReceiveIndex ;Index

;into ReceiveStringSTRCPY ReceiveString[SI], BX, AXADD ReceiveIndex, AX ; Index

; for next incoming; message

POP SI RETNetpost endp

Page 12: CDP ECE 291 -- Spring 2000 ECE 291 Spring 2000 Lecture 18: Networking Constantine D. Polychronopoulos Office: 463 CSRL.

CDP ECE 291 -- Spring 2000

NetBIOS: NetLIB

• 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

; Sample main for using NetLIBmain proc far. . .CALL NetINITMOV my_num, AL. . .; Send messageSTRCPY TXBuffer, TransmitString,

SIZEOF TransmitStringMOV AX, SIZEOF TransmitStringCALL SendPacket. . .CALL NetRelease. . .main endp

Page 13: CDP ECE 291 -- Spring 2000 ECE 291 Spring 2000 Lecture 18: Networking Constantine D. Polychronopoulos Office: 463 CSRL.

CDP ECE 291 -- Spring 2000

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.

Page 14: CDP ECE 291 -- Spring 2000 ECE 291 Spring 2000 Lecture 18: Networking Constantine D. Polychronopoulos Office: 463 CSRL.

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)

Page 15: CDP ECE 291 -- Spring 2000 ECE 291 Spring 2000 Lecture 18: Networking Constantine D. Polychronopoulos Office: 463 CSRL.

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

Page 16: CDP ECE 291 -- Spring 2000 ECE 291 Spring 2000 Lecture 18: Networking Constantine D. Polychronopoulos Office: 463 CSRL.

CDP ECE 291 -- Spring 2000

Example:

1 -Set source segment and offset: use DS to point to sourcemov AX, SEG ScratchSeg ; from a defined segmentmov DS, AX

2 - Set ES to the destination segmentmov AX, 0A000h ; graphics segmentmov ES, AX

3 - Specify direction of processingcld ; set direction flag forward

4 - Specify the source offsetmov ESI, offset ScratchSeg ; set source offset

5- Specify the destination offsetmov EDI, 0 ; set destination offset

Specify # of times to repeat opetationmov ECX, 16000

Specify the operationrep movsd