The ports and protocols used by the Samba service:
1) Port 137 (UDP)-NetBIOS name service; NMBD
2) port 138 (UDP)-NetBIOS Datagram Service 3) port 139 (TCP)-File and print sharing, SMBD (SMB (Server Message Block) protocol, mainly used on LAN, file sharing protocol) 4) port 3 (TCP)-for LDAP (Active Directory Mode) 5) port 445 (TCP)-NetBIOS service uses this port in WinDOS 2000 and later versions (Common Internet File System , CIFS, which is the SMB protocol that is extended to the Internet after you implement Internet File sharing)
6) Port 901 (TCP)-for SWAT, for Web management Samba
File sharing protocol between Windows systems: NetBEUI (NetBIOS Extend User Interface) protocol and Ipx/spx Protocol
The NetBEUI protocol is a compact, communication-efficient broadcast protocol that does not need to be set up after installation and is especially suitable for transmitting data in a "Network Neighborhood".
NetBEUI lack of Routing and Network layer addressing function is not only its greatest advantage, but also its biggest disadvantage. Because it does not require additional network addresses and network layer Kinsoku, it is fast and effective and works well for small workgroup environments that are bridged only by a single network or an entire environment.
Because routing is not supported, NetBEUI will never become the primary protocol for the corporate network. The only address in the NetBEUI frame is the data Link Layer media access control (MAC) address, which identifies the NIC but does not identify the network. The router forwards the frame to the final destination by the network address, and the NetBEUI frame lacks that information completely.
Ipx/spx (Internetwork Packet exchange/sequences Packet exchange,internet packet switching/sequential packet switching ipx/spx) is a set of communications protocols for Novell Corporation. The distinctive difference with NetBEUI is that ipx/spx is relatively large and has strong adaptability in complex environment. This is because ipx/spx in the beginning of the design to consider the problem of the network segment, so it has a powerful routing function, suitable for large-scale network use.
IPX mainly realizes the maintenance and termination of the connection between network devices. The SPX protocol is the auxiliary protocol of IPX, which mainly realizes the grouping of information, tracking packet transmission and guaranteeing the intact transmission of information. The IPX protocol is responsible for the transmission of the packet, and the SPX is responsible for the integrity of the packet transmission.
File sharing between Linux systems and Liunx files sharing with Windows systems: IBM SMB, Server Information block protocol
The server Information block (SMB) protocol is an IBM protocol that is used to share files, printers, serial ports, and so on between computers. The SMB protocol can be used on the TCP/IP protocol of the Internet or on other network protocols such as IPX and NetBEUI.
http://blog.csdn.net/wangsifu2009/article/details/6780749
------------------------------------------------------------------------------
shared file upload and download based on SMB/JCIFS protocol (shared files in local area network to get files)
SMBOriginally developed by the IBM Berry Feigenbaum (Barry Feigenbaum), the aim was to transform the local file interface "Interrupt 13" in the DOS operating system into a network file system. Microsoft later made a major change to this development, and this changed version is also the most common version. Microsoft has combined the SMB protocol with the network Management program it developed with 3Com and continues to add new features to Windows for Workgroups and later versions of Windows.
CIFS (Common Internet File System)Universal Internet File System
Network file sharing between Windows hosts is achieved by using Microsoft's own CIFS service.
CIFS is a newly proposed protocol that enables programs to access files on a remote internet computer and require services for this computer. CIFS uses client/server mode. The client program requests a server program on the server to service it. The server obtains the request and returns a response. CIFS is a public or open SMB protocol version and is used by Microsoft. The SMB protocol (see the last noun explanation) is now a protocol for server file access and printing on a local area network. Like the SMB protocol, CIFS runs at the top, rather than at the bottom, as the TCP/IP protocol does. CIFS can be seen as an implementation of application protocols such as file transfer protocols and hypertext transfer protocols.
CIFS enables you to achieve the following features:
1. Access the server local files and read and write these files
2. Share some file blocks with other users
3. Automatically restore the connection to the network when disconnected
4. Using Western European character filenames
In general, CIFS users get better control of files than FTP. It provides a potentially more direct interface to the server program, which is better than a browser using the HTTP protocol. The most typical application for CIFS is that Windows users can find other hosts on the network and access their shared folders from their web places.
CIFS is an open standard and has been submitted to the IETF as an Internet application standard.
jcifs is an implementation of CIFS in Java and is an open source project for the maintenance development of the Samba organization, focusing on the design and implementation of the CIFS protocol using the Java language. They designed jcifs as a complete, rich, scalable and thread-safe client library. This library can be applied to a variety of Java virtual machines to access network resources that follow the CIFS/SMB Network Transport protocol. Similar to the Java.io.File interface form, proved to be effective and easy to use in multi-threaded working mode
Java code
- Package COM.SMB;
- Import Java.io.BufferedInputStream;
- Import Java.io.BufferedOutputStream;
- Import Java.io.File;
- Import Java.io.FileInputStream;
- Import Java.io.FileOutputStream;
- Import java.io.IOException;
- Import Java.io.InputStream;
- Import Java.io.OutputStream;
- Import Jcifs.smb.SmbFile;
- Import Jcifs.smb.SmbFileInputStream;
- Import Jcifs.smb.SmbFileOutputStream;
- public class Smbtest {
- /**
- * Get files from shared files on LAN and save on Local disk
- * @param remoteurl shared computer path such as: Smb//administrator:[email Protected]/smb/1221.zip, SMB is a shared file
- * Note: If the connection is not on, there is an error message, and the wrong information is the user name Live password error Modify the shared machine folder options to see the removal of the shared simple folder check.
- * @param localdir Local path such as: d:/
- */
- public static void Smbget (String remoteurl,string localdir) {
- InputStream in = null;
- OutputStream out = null;
- try {
- Smbfile smbfile = new Smbfile (Remoteurl);
- String fileName = Smbfile.getname ();
- File LocalFile = new file (localdir+file.separator+filename);
- in = new Bufferedinputstream (new Smbfileinputstream (Smbfile));
- out = new Bufferedoutputstream (new FileOutputStream (LocalFile));
- byte []buffer = new byte[1024];
- while ((In.read (buffer))! =-1) {
- Out.write (buffer);
- Buffer = new byte[1024];
- }
- } catch (Exception e) {
- E.printstacktrace ();
- }finally{
- try {
- Out.close ();
- In.close ();
- } catch (IOException e) {
- E.printstacktrace ();
- }
- }
- }
- /**
- * Upload files from local disk to LAN shared file
- * @param remoteurl shared computer path such as: Smb//administrator:[email PROTECTED]/SMB
- * @param localfilepath Local path such as: d:/
- */
- public static void Smbput (String remoteurl,string localfilepath) {
- InputStream in = null;
- OutputStream out = null;
- try {
- File LocalFile = new file (Localfilepath);
- String fileName = Localfile.getname ();
- Smbfile remotefile = new Smbfile (remoteurl+ "/" +filename);
- in = new Bufferedinputstream (new FileInputStream (LocalFile));
- out = new Bufferedoutputstream (new Smbfileoutputstream (RemoteFile));
- byte []buffer = new byte[1024];
- while ((In.read (buffer))! =-1) {
- Out.write (buffer);
- Buffer = new byte[1024];
- }
- } catch (Exception e) {
- E.printstacktrace ();
- }finally{
- try {
- Out.close ();
- In.close ();
- } catch (IOException e) {
- E.printstacktrace ();
- }
- }
- }
- public static void Main (string[] args) {
- Smbput ("Smb://administrator:[email protected]/smb", "E:/1221.zip");
- Smbget ("Smb://administrator:[email protected]/smb/1221.zip", "d:/");
- }
- }
http://iteye.blog.163.com/blog/static/1863080962012111155514179/
------------------------------------------------------------------------------
The port and protocol used by Samba services (a combination of a set of TCP UDP protocols, mainly using the CIFS protocol, with a Java example)